saga-2.3.1/0000775000175000017500000000000012737740002013570 5ustar00oconradoconrad00000000000000saga-2.3.1/src/0000775000175000017500000000000012737740003014360 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/0000775000175000017500000000000012737740010016026 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/shapes/0000775000175000017500000000000012737740006017316 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/shapes/shapes_points/0000775000175000017500000000000012737740006022175 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/shapes/shapes_points/remove_duplicates.h0000744000175000017500000001043412737416204026061 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Remove_Duplicates.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Remove_Duplicates_H #define HEADER_INCLUDED__Remove_Duplicates_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CRemove_Duplicates : public CSG_Module { public: CRemove_Duplicates(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_Field, m_Method, m_Numeric; CSG_Shapes *m_pPoints; void Set_Attributes (CSG_Shape *pPoint, CSG_PRQuadTree_Leaf_List *pList); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Remove_Duplicates_H saga-2.3.1/src/modules/shapes/shapes_points/AddCoordinates.cpp0000744000175000017500000000601212737416203025561 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* AddCoordinates.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "AddCoordinates.h" //--------------------------------------------------------- CAddCoordinates::CAddCoordinates(void) { Set_Name (_TL("Add Coordinates to points")); Set_Author (SG_T("Victor Olaya (c) 2004")); Set_Description (_TW( "The module attaches the x- and y-coordinates of each point to the attribute table. " "For 3D shapefiles, also the z/m-coordinates are reported.\n" )); Parameters.Add_Shapes( NULL, "INPUT" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL, "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } //--------------------------------------------------------- bool CAddCoordinates::On_Execute(void) { CSG_Shapes *pShapes = Parameters("OUTPUT")->asShapes(); if( pShapes ) { pShapes->Assign(Parameters("INPUT")->asShapes()); } else { pShapes = Parameters("INPUT")->asShapes(); } //----------------------------------------------------- int xField = pShapes->Get_Field_Count(); pShapes->Add_Field("X", SG_DATATYPE_Double); int yField = pShapes->Get_Field_Count(); pShapes->Add_Field("Y", SG_DATATYPE_Double); int zField = 0, mField = 0; if( pShapes->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { zField = pShapes->Get_Field_Count(); pShapes->Add_Field("Z", SG_DATATYPE_Double); if( pShapes->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { mField = pShapes->Get_Field_Count(); pShapes->Add_Field("M", SG_DATATYPE_Double); } } //----------------------------------------------------- for(int i=0; iGet_Count(); i++) { CSG_Shape *pShape = pShapes->Get_Shape(i); pShape->Set_Value(xField, pShape->Get_Point(0).x); pShape->Set_Value(yField, pShape->Get_Point(0).y); if( pShapes->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pShape->Set_Value(zField, pShape->Get_Z(0)); if( pShapes->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShape->Set_Value(mField, pShape->Get_M(0)); } } } DataObject_Update(pShapes); return( true ); } saga-2.3.1/src/modules/shapes/shapes_points/points_thinning.cpp0000744000175000017500000002261512737416203026117 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_thinning.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // points_thinning.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "points_thinning.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_Thinning::CPoints_Thinning(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Points Thinning")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("") ); Parameters.Add_Shapes( NULL , "THINNED" , _TL("Thinned Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "RESOLUTION" , _TL("Resolution"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_Thinning::On_Execute(void) { int Field; CSG_Shapes *pPoints; //----------------------------------------------------- pPoints = Parameters("POINTS") ->asShapes(); Field = Parameters("FIELD") ->asInt(); m_pPoints = Parameters("THINNED") ->asShapes(); m_Resolution = Parameters("RESOLUTION") ->asDouble(); //----------------------------------------------------- if( m_Resolution <= 0.0 ) { Error_Set(_TL("resolution has to be greater than zero")); return( false ); } if( !pPoints->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( pPoints->Get_Count() < 2 ) { Error_Set(_TL("not more than one point in layer")); return( false ); } if( !Set_Search_Engine(pPoints, Field) ) { Error_Set(_TL("failed to initialise search engine")); return( false ); } //----------------------------------------------------- m_pPoints->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), pPoints->Get_Field_Name(Field))); m_pPoints->Add_Field(_TL("Count") , SG_DATATYPE_Int); m_pPoints->Add_Field(_TL("Mean") , SG_DATATYPE_Double); m_pPoints->Add_Field(_TL("Minimun") , SG_DATATYPE_Double); m_pPoints->Add_Field(_TL("Maximun") , SG_DATATYPE_Double); m_pPoints->Add_Field(_TL("StdDev") , SG_DATATYPE_Double); pPoints->Select(); //----------------------------------------------------- Get_Points(m_Search.Get_Root_Pointer()); //----------------------------------------------------- if( m_pPoints->Get_Count() == pPoints->Get_Count() ) { Message_Add(_TL("no points removed")); } else { Message_Add(CSG_String::Format(SG_T("%d %s"), pPoints->Get_Count() - m_pPoints->Get_Count(), _TL("no points removed"))); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_Thinning::Set_Search_Engine(CSG_Shapes *pPoints, int Field) { CSG_Rect r(pPoints->Get_Extent()); r.Assign( r.Get_XCenter() - 0.5 * m_Resolution, r.Get_YCenter() - 0.5 * m_Resolution, r.Get_XCenter() + 0.5 * m_Resolution, r.Get_YCenter() + 0.5 * m_Resolution ); while( r.Intersects(pPoints->Get_Extent()) != INTERSECTION_Contains ) { r.Inflate(200.0); } if( !m_Search.Create(r, true) ) { return( false ); } for(int i=0; iGet_Count() && Set_Progress(i, pPoints->Get_Count()); i++) { CSG_Shape *pPoint = pPoints->Get_Shape(i); m_Search.Add_Point( pPoint->Get_Point(0).x, pPoint->Get_Point(0).y, pPoint->asDouble(Field) ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_Thinning::Get_Points(CSG_PRQuadTree_Item *pItem) { if( pItem ) { if( pItem->is_Leaf() ) { Add_Point(pItem->asLeaf()); } else if( pItem->Get_Size() <= m_Resolution ) { Add_Point((CSG_PRQuadTree_Node_Statistics *)pItem); } else { for(int i=0; i<4; i++) { Get_Points(pItem->asNode()->Get_Child(i)); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_Thinning::Add_Point(CSG_PRQuadTree_Leaf *pLeaf) { CSG_Shape *pPoint = m_pPoints->Add_Shape(); pPoint->Add_Point(pLeaf->Get_X(), pLeaf->Get_Y()); if( pLeaf->has_Statistics() ) { CSG_PRQuadTree_Leaf_List *pList = (CSG_PRQuadTree_Leaf_List *)pLeaf; pPoint->Set_Value(0, pList->Get_Count()); // Count pPoint->Set_Value(1, pList->Get_Mean()); // Mean pPoint->Set_Value(2, pList->Get_Minimum()); // Minimun pPoint->Set_Value(3, pList->Get_Maximum()); // Maximun pPoint->Set_Value(4, pList->Get_StdDev()); // StdDev } else { pPoint->Set_Value(0, 1); // Count pPoint->Set_Value(1, pLeaf->Get_Z()); // Mean pPoint->Set_Value(2, pLeaf->Get_Z()); // Minimun pPoint->Set_Value(3, pLeaf->Get_Z()); // Maximun pPoint->Set_Value(4, 0.0); // StdDev } } //--------------------------------------------------------- void CPoints_Thinning::Add_Point(CSG_PRQuadTree_Node_Statistics *pNode) { CSG_Shape *pPoint = m_pPoints->Add_Shape(); pPoint->Add_Point(pNode->Get_X()->Get_Mean(), pNode->Get_Y()->Get_Mean()); pPoint->Set_Value(0, pNode->Get_Z()->Get_Count()); // Count pPoint->Set_Value(1, pNode->Get_Z()->Get_Mean()); // Mean pPoint->Set_Value(2, pNode->Get_Z()->Get_Minimum()); // Minimun pPoint->Set_Value(3, pNode->Get_Z()->Get_Maximum()); // Maximun pPoint->Set_Value(4, pNode->Get_Z()->Get_StdDev()); // StdDev } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/Points_From_Lines.cpp0000744000175000017500000004460112737416203026275 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* Points_From_Lines.cpp Copyright (C) Victor Olaya, Volker Wichmann This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Points_From_Lines.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_From_Lines::CPoints_From_Lines(void) { Set_Name (_TL("Convert Lines to Points")); Set_Author (_TL("V. Olaya, V. Wichmann (c) 2004-2015")); Set_Description (_TW( "Converts lines to points. " "Optionally inserts additional points in user-defined distances. " )); Parameters.Add_Shapes( NULL, "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL, "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL, "ADD" , _TL("Insert Additional Points"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL, "METHOD_INSERT" , _TL("Insertion"), _TL("Choose the method how to insert additional points."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("per line segment"), _TL("per line"), _TL("from line center") ), 0 ); Parameters.Add_Value( NULL, "DIST" , _TL("Insertion Distance"), _TL("Point insertion distance [map units]."), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL, "ADD_POINT_ORDER" , _TL("Add Point Order"), _TL("Add point order as additional attribute."), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPoints_From_Lines::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "ADD") ) { pParameters->Get_Parameter("METHOD_INSERT") ->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("DIST") ->Set_Enabled(pParameter->asBool()); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_From_Lines::On_Execute(void) { CSG_Shapes *pLines, *pPoints; bool bAddPoints, bAddPtOrder; int iMethod; double dDist; //----------------------------------------------------- pLines = Parameters("LINES") ->asShapes(); pPoints = Parameters("POINTS") ->asShapes(); bAddPoints = Parameters("ADD") ->asBool(); iMethod = Parameters("METHOD_INSERT") ->asInt(); dDist = Parameters("DIST") ->asDouble(); bAddPtOrder = Parameters("ADD_POINT_ORDER") ->asBool(); pPoints->Create(SHAPE_TYPE_Point, pLines->Get_Name(), pLines, pLines->Get_Vertex_Type()); if( bAddPtOrder ) pPoints->Add_Field(_TL("PT_ID"), SG_DATATYPE_Int); if( bAddPoints ) { switch (iMethod) { case 0: default: Convert_Add_Points_Segment(pLines, pPoints, dDist, bAddPtOrder); break; case 1: Convert_Add_Points_Line(pLines, pPoints, dDist, bAddPtOrder); break; case 2: Convert_Add_Points_Center(pLines, pPoints, dDist, bAddPtOrder); break; } } else { Convert(pLines, pPoints, bAddPtOrder); } return( true ); } //--------------------------------------------------------- void CPoints_From_Lines::Convert_Add_Points_Segment(CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder) { CSG_Shape *pLine, *pPoint; TSG_Point Pt_A, Pt_B; double dx, dy, dz, dm, dLine, A_z, B_z, A_m, B_m; for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); int iPoints = 0; for(int iPart=0; iPartGet_Part_Count(); iPart++) { Pt_B = pLine->Get_Point(0, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { B_z = pLine->Get_Z(0, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { B_m = pLine->Get_M(0, iPart); } } for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { Pt_A = Pt_B; Pt_B = pLine->Get_Point(iPoint, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z = B_z; B_z = pLine->Get_Z(iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m = B_m; B_m = pLine->Get_M(iPoint, iPart); } } dx = Pt_B.x - Pt_A.x; dy = Pt_B.y - Pt_A.y; dLine = sqrt(dx*dx + dy*dy); dx /= dLine; dy /= dLine; if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { dz = (B_z - A_z) / dLine; if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { dm = (B_m - A_m) / dLine; } } pPoint = pPoints->Add_Shape(pLine, SHAPE_COPY_ATTR); pPoint ->Add_Point(Pt_A); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pPoint->Set_Z(A_z, 0); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pPoint->Set_M(A_m, 0); } } if( bAddPtOrder ) { pPoint->Set_Value(pPoints->Get_Field_Count()-1, iPoints); iPoints++; } double dLength = 0.0; while( dLength + dDist < dLine ) { Pt_A.x += dDist * dx; Pt_A.y += dDist * dy; pPoint = pPoints->Add_Shape(pLine, SHAPE_COPY_ATTR); pPoint ->Add_Point(Pt_A); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z += dDist * dz; pPoint->Set_Z(A_z, 0); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m += dDist * dm; pPoint->Set_M(A_m, 0); } } if( bAddPtOrder ) { pPoint->Set_Value(pPoints->Get_Field_Count()-1, iPoints); iPoints++; } dLength += dDist; } } } } return; } //--------------------------------------------------------- void CPoints_From_Lines::Convert_Add_Points_Line(CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder) { CSG_Shape *pLine, *pPoint; TSG_Point Pt_A, Pt_B; double dx, dy, dz, dm, dLine, A_z, B_z, A_m, B_m; for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); int iPoints = 0; double dOffset = 0.0; for(int iPart=0; iPartGet_Part_Count(); iPart++) { Pt_B = pLine->Get_Point(0, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { B_z = pLine->Get_Z(0, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { B_m = pLine->Get_M(0, iPart); } } for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { Pt_A = Pt_B; Pt_B = pLine->Get_Point(iPoint, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z = B_z; B_z = pLine->Get_Z(iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m = B_m; B_m = pLine->Get_M(iPoint, iPart); } } dx = Pt_B.x - Pt_A.x; dy = Pt_B.y - Pt_A.y; dLine = sqrt(dx*dx + dy*dy); if ( dOffset > dLine ) { dOffset = dOffset - dLine; continue; } dx /= dLine; dy /= dLine; Pt_A.x += dOffset * dx; Pt_A.y += dOffset * dy; if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { dz = (B_z - A_z) / dLine; A_z += dOffset * dz; if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { dm = (B_m - A_m) / dLine; A_m += dOffset * dm; } } pPoint = pPoints->Add_Shape(pLine, SHAPE_COPY_ATTR); pPoint ->Add_Point(Pt_A); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pPoint->Set_Z(A_z, 0); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pPoint->Set_M(A_m, 0); } } if( bAddPtOrder ) { pPoint->Set_Value(pPoints->Get_Field_Count()-1, iPoints); iPoints++; } double dLength = 0.0; dLine -= dOffset; while( dLength + dDist < dLine ) { Pt_A.x += dDist * dx; Pt_A.y += dDist * dy; pPoint = pPoints->Add_Shape(pLine, SHAPE_COPY_ATTR); pPoint ->Add_Point(Pt_A); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z += dDist * dz; pPoint->Set_Z(A_z, 0); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m += dDist * dm; pPoint->Set_M(A_m, 0); } } if( bAddPtOrder ) { pPoint->Set_Value(pPoints->Get_Field_Count()-1, iPoints); iPoints++; } dLength += dDist; } dOffset = (dLength + dDist) - dLine; } } } return; } //--------------------------------------------------------- void CPoints_From_Lines::Convert_Add_Points_Center(CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder) { CSG_Shape *pLine; TSG_Point Pt_A, Pt_B, Pt_C; double dx, dy, dz, dm, dLine, A_z, B_z, C_z, A_m, B_m, C_m; int iSplitPart, iSplitPoint; for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); double dCenter = ((CSG_Shape_Line *)pLine)->Get_Length() / 2.0; double dLength = 0.0; //--------------------------------------------------------- // search for the part we need to split for(int iPart=0; iPartGet_Part_Count(); iPart++) { dLine = ((CSG_Shape_Line *)pLine)->Get_Length(iPart); if( dLength + dLine < dCenter ) { dLength += dLine; } else { iSplitPart = iPart; break; } } double dOffset = dCenter - dLength; Pt_B = pLine->Get_Point(0, iSplitPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { B_z = pLine->Get_Z(0, iSplitPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { B_m = pLine->Get_M(0, iSplitPart); } } dLength = 0.0; //--------------------------------------------------------- // search for the point after which we need to split for(int iPoint=1; iPointGet_Point_Count(iSplitPart); iPoint++) { Pt_A = Pt_B; Pt_B = pLine->Get_Point(iPoint, iSplitPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z = B_z; B_z = pLine->Get_Z(iPoint, iSplitPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m = B_m; B_m = pLine->Get_M(iPoint, iSplitPart); } } dx = Pt_B.x - Pt_A.x; dy = Pt_B.y - Pt_A.y; dLine = sqrt(dx*dx + dy*dy); if (dLength + dLine < dOffset) { dLength += dLine; } else { iSplitPoint = iPoint - 1; dOffset = dOffset - dLength; break; } } //--------------------------------------------------------- // create center point dx /= dLine; dy /= dLine; Pt_A.x += dOffset * dx; Pt_A.y += dOffset * dy; Pt_C = Pt_A; if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { dz = (B_z - A_z) / dLine; A_z += dOffset * dz; C_z = A_z; if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { dm = (B_m - A_m) / dLine; A_m += dOffset * dm; C_m = A_m; } } //--------------------------------------------------------- // create line part from center to end of line CSG_Shapes SplitLines; CSG_Shape *pSplitLine; SplitLines.Create(pLines->Get_Type(), pLines->Get_Name(), pLines, pLines->Get_Vertex_Type()); int iPartOffset = 0; int iPointOffset; pSplitLine = SplitLines.Add_Shape(pLine, SHAPE_COPY_ATTR); pSplitLine ->Add_Point(Pt_C, iPartOffset); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSplitLine->Set_Z(C_z, iPartOffset); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSplitLine->Set_M(C_m, iPartOffset); } } for(int iPart=iSplitPart; iPartGet_Part_Count(); iPart++) { if( iPart == iSplitPart ) { iPointOffset = iSplitPoint + 1; } else { iPointOffset = 0; } for(int iPoint=iPointOffset; iPointGet_Point_Count(iPart); iPoint++) { Pt_A = pLine->Get_Point(iPoint, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z = pLine->Get_Z(iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m = pLine->Get_M(iPoint, iPart); } } pSplitLine ->Add_Point(Pt_A, iPartOffset); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSplitLine->Set_Z(A_z, iPartOffset); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSplitLine->Set_M(A_m, iPartOffset); } } } // for iPoint iPartOffset++; } // for iPart; Convert_Add_Points_Line(&SplitLines, pPoints, dDist, bAddPtOrder); //--------------------------------------------------------- // create line part from center to start of line SplitLines.Create(pLines->Get_Type(), pLines->Get_Name(), pLines, pLines->Get_Vertex_Type()); iPartOffset = 0; pSplitLine = SplitLines.Add_Shape(pLine, SHAPE_COPY_ATTR); pSplitLine ->Add_Point(Pt_C, iPartOffset); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSplitLine->Set_Z(C_z, iPartOffset); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSplitLine->Set_M(C_m, iPartOffset); } } for(int iPart=iSplitPart; iPart>=0; iPart--) { if( iPart == iSplitPart ) { iPointOffset = iSplitPoint; } else { iPointOffset = pLine->Get_Point_Count(iPart); } for(int iPoint=iPointOffset; iPoint>=0; iPoint--) { Pt_A = pLine->Get_Point(iPoint, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { A_z = pLine->Get_Z(iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { A_m = pLine->Get_M(iPoint, iPart); } } pSplitLine ->Add_Point(Pt_A, iPartOffset); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSplitLine->Set_Z(A_z, iPartOffset); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSplitLine->Set_M(A_m, iPartOffset); } } } // for iPoint iPartOffset++; } // for iPart; Convert_Add_Points_Line(&SplitLines, pPoints, dDist, bAddPtOrder); } // for iLine return; } //--------------------------------------------------------- void CPoints_From_Lines::Convert(CSG_Shapes *pLines, CSG_Shapes *pPoints, bool bAddPtOrder) { CSG_Shape *pLine, *pPoint; for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); int iPoints = 0; for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pPoint = pPoints->Add_Shape(pLine, SHAPE_COPY_ATTR); pPoint ->Add_Point(pLine->Get_Point(iPoint, iPart)); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pPoint->Set_Z(pLine->Get_Z(iPoint, iPart), 0); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pPoint->Set_M(pLine->Get_M(iPoint, iPart), 0); } } if( bAddPtOrder ) { pPoint->Set_Value(pPoints->Get_Field_Count()-1, iPoints); iPoints++; } } } } return; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_From_MultiPoints::CPoints_From_MultiPoints(void) { Set_Name (_TL("Convert Multipoints to Points")); Set_Author (_TL("O.Conrad (c) 2011")); Set_Description (_TW( "Converts multipoints to points. " )); Parameters.Add_Shapes( NULL , "MULTIPOINTS" , _TL("Multipoints"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Points ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_From_MultiPoints::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pMultipoints = Parameters("MULTIPOINTS") ->asShapes(); CSG_Shapes *pPoints = Parameters("POINTS") ->asShapes(); pPoints->Create(SHAPE_TYPE_Point, pMultipoints->Get_Name(), pMultipoints, pMultipoints->Get_Vertex_Type()); //----------------------------------------------------- for(int iMultipoint=0; iMultipointGet_Count() && Set_Progress(iMultipoint, pMultipoints->Get_Count()); iMultipoint++) { CSG_Shape *pMultipoint = pMultipoints->Get_Shape(iMultipoint); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { CSG_Shape *pPoint = pPoints->Add_Shape(pMultipoint, SHAPE_COPY_ATTR); pPoint->Add_Point(pMultipoint->Get_Point(iPoint, iPart)); if( pMultipoints->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pPoint->Set_Z(pMultipoint->Get_Z(iPoint, iPart), 0); if( pMultipoints->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pPoint->Set_M(pMultipoint->Get_M(iPoint, iPart), 0); } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/Points_From_Table.cpp0000744000175000017500000000731612737416203026254 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* Points_From_Table.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Points_From_Table.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_From_Table::CPoints_From_Table(void) { CSG_Parameter *pNode; Set_Name (_TL("Convert Table to Points")); Set_Author (_TL("Victor Olaya (c) 2004")); Set_Description (_TW( "Create Point Theme From Table" )); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "X" , _TL("X"), _TL("") ); Parameters.Add_Table_Field( pNode , "Y" , _TL("Y"), _TL("") ); Parameters.Add_Table_Field( pNode , "Z" , _TL("Z"), _TL(""), true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_From_Table::On_Execute(void) { int xField, yField, zField; CSG_Table *pTable; CSG_Shapes *pShapes; pTable = Parameters("TABLE") ->asTable(); pShapes = Parameters("POINTS") ->asShapes(); xField = Parameters("X") ->asInt(); yField = Parameters("Y") ->asInt(); zField = Parameters("Z") ->asInt(); if( pTable->Get_Field_Count() < 1 || pTable->Get_Record_Count() <= 0 ) { return( false ); } pShapes->Create(SHAPE_TYPE_Point, pTable->Get_Name(), pTable, zField < 0 ? SG_VERTEX_TYPE_XY : SG_VERTEX_TYPE_XYZ); for(int iRecord=0; iRecordGet_Record_Count() && Set_Progress(iRecord, pTable->Get_Record_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); if( !pRecord->is_NoData(xField) && !pRecord->is_NoData(yField) ) { CSG_Shape *pShape = pShapes->Add_Shape(pRecord, SHAPE_COPY_ATTR); pShape->Add_Point(pRecord->asDouble(xField), pRecord->asDouble(yField)); if( zField >= 0 ) { pShape->Set_Z(pRecord->asDouble(zField), 0); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/FitNPointsToShape.cpp0000744000175000017500000000735412737416203026231 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* FitNPointsToShape.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "FitNPointsToShape.h" #define MAX_REP 30 #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif CFitNPointsToShape::CFitNPointsToShape(void){ Parameters.Set_Name(_TL("Fit N Points to shape")); Parameters.Set_Description(_TW( "(c) 2004 by Victor Olaya. Fit N Points to shape")); Parameters.Add_Shapes(NULL, "POINTS", _TL("Points"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Shapes(NULL, "SHAPES", _TL("Shapes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Value(NULL, "NUMPOINTS", _TL("Number of points"), _TL("Number of points"), PARAMETER_TYPE_Int, 100, 1, true); }//constructor CFitNPointsToShape::~CFitNPointsToShape(void) {} bool CFitNPointsToShape::On_Execute(void){ CSG_Shapes *pShapes, *pPoints; CSG_Shape *pShape, *pShape2; bool bCopy; int iPoints; int iPointsIn = 0; int iRep = 0; int i,j; double x,y; double dArea; double dDist; double dDistInf, dDistSup; bool bFirstTime; TSG_Rect Extent; pShapes = Parameters("SHAPES")->asShapes(); pPoints = Parameters("POINTS")->asShapes(); iPoints = Parameters("NUMPOINTS")->asInt(); if(pShapes == pPoints){ bCopy = true; pPoints = SG_Create_Shapes(); }//if else{ bCopy = false; }//else pPoints->Create(SHAPE_TYPE_Point, _TL("Point Grid")); pPoints->Add_Field("X", SG_DATATYPE_Double); pPoints->Add_Field("Y", SG_DATATYPE_Double); for (i = 0; i < pShapes->Get_Selection_Count(); i++){ iRep = 0; pShape = pShapes->Get_Selection(i); dArea = ((CSG_Shape_Polygon*)pShape)->Get_Area(); dDist = sqrt(dArea / (double) iPoints); dDistInf = sqrt(dArea / (double) (iPoints + 2)); dDistSup = sqrt(dArea / (double) (iPoints - min(2, iPoints-1))); Extent = ((CSG_Shape_Polygon*)pShape)->Get_Extent(); bFirstTime = true; do{ if (!bFirstTime){ for (j = 0; j < iPointsIn; j++){ pPoints->Del_Shape(pPoints->Get_Count()-1); }//for }//if iPointsIn = 0; iRep++; for (x=Extent.xMin; xContains(x,y)){ pShape2 = pPoints->Add_Shape(); pShape2->Add_Point(x,y); pShape2->Set_Value(0, x); pShape2->Set_Value(1, y); iPointsIn++; }//if }//for }//for if (iPointsIn > iPoints){ dDistInf = dDist; dDist = (dDistInf + dDistSup) / 2.; }//if else if (iPointsIn < iPoints){ dDistSup = dDist; dDist = (dDistInf + dDistSup) / 2.; }//if bFirstTime = false; }while(iPointsIn != iPoints && iRep < MAX_REP); }//for if(bCopy){ pShapes->Assign(pPoints); delete(pPoints); }//if return true; }//method saga-2.3.1/src/modules/shapes/shapes_points/points_thinning.h0000744000175000017500000001046212737416203025561 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_thinning.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // points_thinning.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_thinning_H #define HEADER_INCLUDED__points_thinning_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_Thinning : public CSG_Module { public: CPoints_Thinning(void); protected: virtual bool On_Execute (void); private: double m_Resolution; CSG_PRQuadTree m_Search; CSG_Shapes *m_pPoints; bool Set_Search_Engine (CSG_Shapes *pPoints, int Field); void Get_Points (CSG_PRQuadTree_Item *pItem); void Add_Point (CSG_PRQuadTree_Leaf *pLeaf); void Add_Point (CSG_PRQuadTree_Node_Statistics *pNode); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_thinning_H saga-2.3.1/src/modules/shapes/shapes_points/separate_by_direction.cpp0000744000175000017500000001644312737416204027246 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // separate_by_direction.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "separate_by_direction.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSeparate_by_Direction::CSeparate_by_Direction(void) { Set_Name (_TL("Separate points by direction")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "Separates points by direction. Direction is determined as average direction of three consecutive points A, B, C. " "If the angle between the directions of A-B and B-C is higher than given tolerance angle the point is dropped. " "This module has been designed to separate GPS tracks recorded by tractors while preparing a field. " )); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL , "OUTPUT" , _TL("Ouput"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "DIRECTIONS" , _TL("Number of Directions"), _TL(""), PARAMETER_TYPE_Double , 4.0, 2.0, true ); Parameters.Add_Value( NULL , "TOLERANCE" , _TL("Tolerance (Degree)"), _TL(""), PARAMETER_TYPE_Double , 5.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSeparate_by_Direction::On_Execute(void) { int iSector, dir_Field; CSG_Shapes *pPoints; CSG_Parameter_Shapes_List *pOutput; //----------------------------------------------------- pOutput = Parameters("OUTPUT") ->asShapesList(); pPoints = Parameters("POINTS") ->asShapes(); m_Tolerance = Parameters("TOLERANCE") ->asDouble() * M_DEG_TO_RAD; m_nSectors = Parameters("DIRECTIONS") ->asInt(); m_dSector = M_PI_360 / m_nSectors; if( !pPoints || !pPoints->is_Valid() || pPoints->Get_Count() < 3 ) { return( false ); } //----------------------------------------------------- pOutput->Del_Items(); dir_Field = pPoints->Get_Field_Count(); for(iSector=0; iSectorAdd_Item(SG_Create_Shapes(SHAPE_TYPE_Point, CSG_String::Format(SG_T("Direction %.2f"), iSector * m_dSector * M_RAD_TO_DEG), pPoints)); pOutput->asShapes(iSector)->Add_Field(_TL("Direction"), SG_DATATYPE_Double); } //----------------------------------------------------- int iPoint; double dir_A, dir_B, dir, dif; CSG_Shape *pt_A, *pt_B; pt_B = pPoints->Get_Shape(pPoints->Get_Count() - 2); pt_A = pPoints->Get_Shape(pPoints->Get_Count() - 1); dir_A = SG_Get_Angle_Of_Direction(pt_B->Get_Point(0), pt_A->Get_Point(0)); for(iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { pt_B = pt_A; pt_A = pPoints->Get_Shape(iPoint); dir_B = dir_A; dir_A = SG_Get_Angle_Of_Direction(pt_B->Get_Point(0), pt_A->Get_Point(0)); dif = fmod(dir_A - dir_B, M_PI_360); if( dif > M_PI_180 ) { dif -= M_PI_360; } else if( dif < -M_PI_180 ) { dif += M_PI_360; } if( fabs(dif) <= m_Tolerance ) { dir = dir_B + 0.5 * dif; iSector = (int)(fmod(M_PI_360 + 0.5 * m_dSector + dir, M_PI_360) / m_dSector); if( iSector >= 0 && iSector < m_nSectors ) { pOutput->asShapes(iSector)->Add_Shape(pt_B)->Set_Value(dir_Field, dir * M_RAD_TO_DEG); } } } //----------------------------------------------------- for(iSector=pOutput->Get_Count()-1; iSector>=0; iSector--) { if( pOutput->asShapes(iSector)->Get_Count() == 0 ) { delete(pOutput->asShapes(iSector)); pOutput->Del_Item(iSector); } } //----------------------------------------------------- return( pOutput->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/separate_by_direction.h0000744000175000017500000001025412737416204026705 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Table_Tools // // // //-------------------------------------------------------// // // // separate_by_direction.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__separate_by_direction_H #define HEADER_INCLUDED__separate_by_direction_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSeparate_by_Direction : public CSG_Module { public: CSeparate_by_Direction(void); protected: virtual bool On_Execute (void); private: int m_nSectors; double m_Tolerance, m_dSector; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__separate_by_direction_H saga-2.3.1/src/modules/shapes/shapes_points/convex_hull.h0000744000175000017500000001067212737416203024700 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_filter.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // convex_hull.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__convex_hull_H #define HEADER_INCLUDED__convex_hull_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CConvex_Hull : public CSG_Module { public: CConvex_Hull(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Tools") ); } protected: virtual bool On_Execute (void); private: static CSG_Shapes *m_pPoints; static int Compare (const int iElement_1, const int iElement_2); double is_Left (const TSG_Point &Line_A, const TSG_Point &Line_B, const TSG_Point &Point); bool Get_Chain_Hull (CSG_Shapes *pPoints, CSG_Shapes *pHulls, CSG_Shape *pAttributes = NULL); int Get_Chain_Hull (CSG_Points &P, CSG_Points &H); bool Get_Bounding_Box (CSG_Shape *pHull, CSG_Shape *pBox); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__convex_hull_H saga-2.3.1/src/modules/shapes/shapes_points/DistanceMatrix.cpp0000744000175000017500000001511312737416203025617 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* DistanceMatrix.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "DistanceMatrix.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDistanceMatrix::CDistanceMatrix(void) { CSG_Parameter *pNode; Set_Name (_TL("Point Distances")); Set_Author ("V.Olaya (c) 2004, O.Conrad (c) 2014"); Set_Description (_TW( "Computes distances between pairs of points." )); pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "ID_POINTS" , _TL("Identifier"), _TL(""), true ); pNode = Parameters.Add_Shapes( NULL , "NEAR" , _TL("Near Points"), _TL(""), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "ID_NEAR" , _TL("Identifier"), _TL(""), true ); Parameters.Add_Table( NULL , "DISTANCES" , _TL("Distances"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "FORMAT" , _TL("Output Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("complete input times near points matrix"), _TL("each pair with a single record") ), 1 ); Parameters.Add_Value( NULL , "MAX_DIST" , _TL("Maximum Distance"), _TL("ignored if set to zero (consider all pairs)"), PARAMETER_TYPE_Double, 0.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CDistanceMatrix::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "FORMAT") ) { pParameters->Get_Parameter("MAX_DIST")->Set_Enabled(pParameter->asInt() == 1); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "NEAR") ) { pParameters->Get_Parameter("ID_NEAR")->Set_Enabled(pParameter->asShapes() != NULL); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_ID(p, id, i) (id < 0 ? CSG_String::Format(SG_T("%d"), i + 1) : CSG_String(p->Get_Shape(i)->asString(id))) //--------------------------------------------------------- bool CDistanceMatrix::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS" )->asShapes(); int id_Points = Parameters("ID_POINTS")->asInt (); CSG_Shapes *pNear = Parameters("NEAR" )->asShapes(); int id_Near = Parameters("ID_NEAR" )->asInt (); CSG_Table *pDistances = Parameters("DISTANCES")->asTable (); double max_Dist = Parameters("MAX_DIST" )->asDouble(); //----------------------------------------------------- if( pNear == NULL ) { pNear = pPoints; id_Near = id_Points; } pDistances->Destroy(); if( pPoints != pNear ) { pDistances->Set_Name(CSG_String::Format(SG_T("%s [%s / %s]"), _TL("Distances"), pPoints->Get_Name(), pNear->Get_Name())); } else { pDistances->Set_Name(CSG_String::Format(SG_T("%s [%s]"), _TL("Distances"), pPoints->Get_Name())); } //----------------------------------------------------- if( Parameters("FORMAT")->asInt() == 1 ) { pDistances->Add_Field("ID_POINT", SG_DATATYPE_String); pDistances->Add_Field("ID_NEAR" , SG_DATATYPE_String); pDistances->Add_Field("DISTANCE", SG_DATATYPE_Double); for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { TSG_Point Point = pPoints->Get_Shape(iPoint)->Get_Point(0); for(int iNear=0; iNearGet_Count(); iNear++) { if( pPoints != pNear || iPoint != iNear ) { double Distance = SG_Get_Distance(Point, pNear->Get_Shape(iNear)->Get_Point(0)); if( Distance <= max_Dist || max_Dist <= 0.0 ) { CSG_Table_Record *pRecord = pDistances->Add_Record(); pRecord->Set_Value(0, GET_ID(pPoints, id_Points, iPoint)); pRecord->Set_Value(1, GET_ID(pNear , id_Near , iNear )); pRecord->Set_Value(2, Distance); } } } } } //----------------------------------------------------- else // Matrix { int iNear; pDistances->Add_Field("ID_POINT", SG_DATATYPE_String); for(iNear=0; iNearGet_Count(); iNear++) { pDistances->Add_Field(GET_ID(pNear, id_Near, iNear), SG_DATATYPE_Double); } for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { TSG_Point Point = pPoints->Get_Shape(iPoint)->Get_Point(0); CSG_Table_Record *pRecord = pDistances->Add_Record(); pRecord->Set_Value(0, GET_ID(pPoints, id_Points, iPoint)); for(iNear=0; iNearGet_Count(); iNear++) { pRecord->Set_Value(1 + iNear, SG_Get_Distance(Point, pNear->Get_Shape(iNear)->Get_Point(0))); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/Clip_Points.h0000744000175000017500000001004112737416203024563 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Clip_Points.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Clip_Points_H #define HEADER_INCLUDED__Clip_Points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CClip_Points : public CSG_Module { public: CClip_Points(void); virtual ~CClip_Points(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Clip_Points_H saga-2.3.1/src/modules/shapes/shapes_points/Points_From_Lines.h0000744000175000017500000000651412737416203025743 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* Points_From_Lines.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Points_From_Lines_H #define HEADER_INCLUDED__Points_From_Lines_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_From_Lines : public CSG_Module { public: CPoints_From_Lines(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); void Convert_Add_Points_Segment (CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder); void Convert_Add_Points_Line (CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder); void Convert_Add_Points_Center (CSG_Shapes *pLines, CSG_Shapes *pPoints, double dDist, bool bAddPtOrder); void Convert (CSG_Shapes *pLines, CSG_Shapes *pPoints, bool bAddPtOrder); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_From_MultiPoints : public CSG_Module { public: CPoints_From_MultiPoints(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Points_From_Lines_H saga-2.3.1/src/modules/shapes/shapes_points/CountPoints.cpp0000744000175000017500000000625012737416203025167 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* CountPoints.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "CountPoints.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCountPoints::CCountPoints(void) { Set_Name (_TL("Count Points in Polygons")); Set_Author (SG_T("Victor Olaya (c) 2004")); Set_Description (_TW( "Count Points in Polygons." )); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCountPoints::On_Execute(void) { CSG_Shapes *pPoints = Parameters("POINTS") ->asShapes(); CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); int Field = pPolygons->Get_Field_Count(); pPolygons->Add_Field(_TL("Points"), SG_DATATYPE_Int); for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); int nPoints = 0; for(int iPoint=0; iPointGet_Count(); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); if( pPolygon->Contains(pPoint->Get_Point(iPoint)) ) { nPoints++; } } pPolygon->Set_Value(Field, nPoints); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/snap_points_to_grid.cpp0000744000175000017500000001762012737416204026752 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snap_points_to_grid.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // snap_points_to_grid.cpp // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "snap_points_to_grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSnap_Points_to_Grid::CSnap_Points_to_Grid(void) { //----------------------------------------------------- Set_Name (_TL("Snap Points to Grid")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Moves all points to grid cell positions that have the highest or" "lowest value respectively within the given search distance around " "each point." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "MOVES" , _TL("Moves"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "DISTANCE" , _TL("Search Distance (Map Units)"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Choice( NULL , "SHAPE" , _TL("Search Shape"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("circle"), _TL("square") ), 0 ); Parameters.Add_Choice( NULL , "EXTREME" , _TL("Extreme"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("minimum"), _TL("maximum") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSnap_Points_to_Grid::On_Execute(void) { double Distance, Sign; CSG_Shapes *pInput, *pPoints, *pMoves; CSG_Grid *pGrid; //----------------------------------------------------- pInput = Parameters("INPUT" )->asShapes(); pPoints = Parameters("OUTPUT" )->asShapes(); pGrid = Parameters("GRID" )->asGrid(); pMoves = Parameters("MOVES" )->asShapes(); Distance = Parameters("DISTANCE")->asDouble() / Get_Cellsize(); Sign = Parameters("EXTREME" )->asInt() == 1 ? 1 : -1; //----------------------------------------------------- if( !pInput->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( pInput->Get_Extent().Intersects(pGrid->Get_Extent()) == INTERSECTION_None ) { Error_Set(_TL("points layer and grid do not intersect at all")); return( false ); } if( Distance < 0.5 ) { if( !Error_Set(_TL("search distance is less than half of grid cell size")) ) // ignore { return( false ); } } //----------------------------------------------------- if( pPoints && pPoints != pInput ) { pPoints->Create(*pInput); } else { Parameters("RESULT")->Set_Value(pPoints = pInput); } pPoints->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pInput->Get_Name(), _TL("snapped"), pGrid->Get_Name())); if( pMoves ) { pMoves->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pInput->Get_Name(), _TL("snap move"), pGrid->Get_Name()), pPoints); } //----------------------------------------------------- CSG_Grid_Cell_Addressor Search; Search.Set_Radius(Distance, Parameters("SHAPE")->asInt() == 1); //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); TSG_Point Point = pPoint->Get_Point(0); int x = Get_System()->Get_xWorld_to_Grid(Point.x); int y = Get_System()->Get_yWorld_to_Grid(Point.y); int iMax = -1; double dMax; for(int i=0; iis_InGrid(ix, iy) ) { if( iMax < 0 || dMax < Sign * pGrid->asDouble(ix, iy) ) { iMax = i; dMax = Sign * pGrid->asDouble(ix, iy); } } } //------------------------------------------------- if( iMax >= 0 ) { TSG_Point snap_Point = pGrid->Get_System().Get_Grid_to_World(Search.Get_X(iMax, x), Search.Get_Y(iMax, y)); if( SG_Get_Distance(Point, snap_Point) > 0.0 ) { pPoint->Set_Point(snap_Point, 0); if( pMoves ) { CSG_Shape *pMove = pMoves->Add_Shape(pPoint, SHAPE_COPY_ATTR); pMove->Add_Point(Point); pMove->Add_Point(snap_Point); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/DistanceMatrix.h0000744000175000017500000000402312737416203025262 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* DistanceMatrix.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDistanceMatrix : public CSG_Module { public: CDistanceMatrix(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/add_polygon_attributes.cpp0000744000175000017500000001565512737416203027460 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // add_polygon_attributes.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "add_polygon_attributes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CAdd_Polygon_Attributes::CAdd_Polygon_Attributes(void) { Set_Name (_TL("Add Polygon Attributes to Points")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "Spatial join for points. Retrieves for each point the selected " "attributes from those polygon, which contain the point. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("Attributes to add. Select none to add all") ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CAdd_Polygon_Attributes::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pInput = Parameters("INPUT")->asShapes(); if( !pInput->is_Valid() ) { Error_Set(_TL("Invalid points layer.")); return( false ); } //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( !pPolygons->is_Valid() ) { Error_Set(_TL("Invalid polygon layer.")); return( false ); } //----------------------------------------------------- CSG_Parameter_Table_Fields *pFields = Parameters("FIELDS")->asTableFields(); if( pFields->Get_Count() == 0 ) { CSG_String sFields; for(int iField=0; iFieldGet_Field_Count(); iField++) { sFields += CSG_String::Format(SG_T("%d,"), iField); } pFields->Set_Value(sFields); } //----------------------------------------------------- CSG_Shapes *pOutput = Parameters("OUTPUT")->asShapes(); if( pOutput && pOutput != pInput ) { pOutput->Create(*pInput); } else { Parameters("OUTPUT")->Set_Value(pOutput = pInput); } pOutput->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), pPolygons->Get_Name())); //----------------------------------------------------- int outField = pOutput->Get_Field_Count(); { for(int iField=0; iFieldGet_Count(); iField++) { int jField = pFields->Get_Index(iField); pOutput->Add_Field(pPolygons->Get_Field_Name(jField), pPolygons->Get_Field_Type(jField)); } } //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pOutput->Get_Count()); iPoint++) { CSG_Shape *pPoint = pOutput ->Get_Shape(iPoint); CSG_Shape *pPolygon = pPolygons ->Get_Shape(pPoint->Get_Point(0)); if( pPolygon ) { for(int iField=0; iFieldGet_Count(); iField++) { int jField = pFields->Get_Index(iField); switch( pPolygons->Get_Field_Type(jField) ) { case SG_DATATYPE_String: case SG_DATATYPE_Date: pPoint->Set_Value(outField + iField, pPolygon->asString(jField)); break; default: pPoint->Set_Value(outField + iField, pPolygon->asDouble(jField)); break; } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/CreatePointGrid.cpp0000744000175000017500000000540712737416203025730 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* CreatePointGrid.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "CreatePointGrid.h" CCreatePointGrid::CCreatePointGrid(void){ Parameters.Set_Name(_TL("Create Point Grid")); Parameters.Set_Description(_TW( "(c) 2004 by Victor Olaya. Creates a regular grid of points.")); Parameters.Add_Shapes(NULL, "POINTS", _TL("Point Grid"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Range(NULL, "X_EXTENT", _TL("X-Extent"), _TL("")); Parameters.Add_Range(NULL, "Y_EXTENT", _TL("Y-Extent"), _TL("")); Parameters.Add_Value(NULL, "DIST", _TL("Distance"), _TL("Distance between points (grid units)."), PARAMETER_TYPE_Double, 100); }//constructor CCreatePointGrid::~CCreatePointGrid(void) {} bool CCreatePointGrid::On_Execute(void){ CSG_Shape *pShape; double dXMin = ((CSG_Parameter_Range *) Parameters("X_EXTENT")->Get_Data())->Get_LoVal(); double dYMin = ((CSG_Parameter_Range *) Parameters("Y_EXTENT")->Get_Data())->Get_LoVal(); double dXMax = ((CSG_Parameter_Range *) Parameters("X_EXTENT")->Get_Data())->Get_HiVal(); double dYMax = ((CSG_Parameter_Range *) Parameters("Y_EXTENT")->Get_Data())->Get_HiVal(); double dDistance = Parameters("DIST")->asDouble(); if (dDistance<=0){ return false; }//if CSG_Shapes *pShapes = Parameters("POINTS")->asShapes(); pShapes->Create(SHAPE_TYPE_Point, _TL("Point Grid")); pShapes->Add_Field("X", SG_DATATYPE_Double); pShapes->Add_Field("Y", SG_DATATYPE_Double); for (double x=dXMin; xAdd_Shape(); pShape->Add_Point(x,y); pShape->Set_Value(0, x); pShape->Set_Value(1, y); }//for }//for return true; }//method saga-2.3.1/src/modules/shapes/shapes_points/points_filter.h0000744000175000017500000001022112737416203025221 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_filter.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // points_filter.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_filter_H #define HEADER_INCLUDED__points_filter_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_Filter : public CSG_Module { public: CPoints_Filter(void); protected: virtual bool On_Execute (void); private: int m_Method, m_nMinPoints, m_nMaxPoints; double m_Radius, m_Tolerance, m_Percentile; CSG_PRQuadTree m_Search; bool Do_Filter (TSG_Point Point, double zPoint, int Quadrant = -1); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_filter_H saga-2.3.1/src/modules/shapes/shapes_points/CountPoints.h0000744000175000017500000000364212737416203024636 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* CountPoints.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCountPoints : public CSG_Module { public: CCountPoints(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/select_points.cpp0000744000175000017500000001616312737416204025562 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // select_points.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "select_points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelect_Points::CSelect_Points(void) { Set_Name (_TL("Select Points")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "SELECTION" , _TL("Selection"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Radius"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL , "MAXNUM" , _TL("Maximum Number of Points"), _TL(""), PARAMETER_TYPE_Int, 0.0, 0.0, true ); Parameters.Add_Choice( NULL , "QUADRANT" , _TL("Quadrant"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("all quadrants"), _TL("1. quadrant (upper right)"), _TL("2. quadrant (lower right)"), _TL("3. quadrant (lower left)"), _TL("4. quadrant (upper left)") ), 0 ); Parameters.Add_Value( NULL , "ADDCENTER" , _TL("Add Center"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_Points::On_Execute(void) { //----------------------------------------------------- m_pPoints = Parameters("POINTS") ->asShapes(); m_pSelection = Parameters("SELECTION") ->asShapes(); m_Radius = Parameters("RADIUS") ->asDouble(); m_MaxPoints = Parameters("MAXNUM") ->asInt(); m_Quadrant = Parameters("QUADRANT") ->asInt() - 1; m_bAddCenter = Parameters("ADDCENTER") ->asBool(); //----------------------------------------------------- if( !m_pPoints->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( m_pPoints->Get_Count() <= 0 ) { Error_Set(_TL("no points in layer")); return( false ); } if( !m_Search.Create(m_pPoints, -1) ) { Error_Set(_TL("failed to initialise search engine")); return( false ); } //----------------------------------------------------- m_pSelection->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), m_pPoints->Get_Name(), _TL("Selection")), m_pPoints); m_pSelection->Add_Field(_TL("Order") , SG_DATATYPE_Int); m_pSelection->Add_Field(_TL("Distance") , SG_DATATYPE_Double); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_Points::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { switch( Mode ) { case MODULE_INTERACTIVE_LUP: m_pSelection->Del_Records(); if( m_bAddCenter ) { m_pSelection->Add_Shape()->Add_Point(ptWorld); } if( m_Search.Select_Nearest_Points(ptWorld.Get_X(), ptWorld.Get_Y(), m_MaxPoints, m_Radius, m_Quadrant) ) { for(int i=0; iAdd_Shape(m_pPoints->Get_Shape((int)m_Search.Get_Selected_Z(i))); pPoint->Set_Value(m_pSelection->Get_Field_Count() - 2, i + 1); pPoint->Set_Value(m_pSelection->Get_Field_Count() - 1, m_Search.Get_Selected_Distance(i)); } } DataObject_Update(m_pSelection); break; default: break; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/snap_points_to_features.h0000744000175000017500000001035612737416204027307 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snap_points_to_features.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // snap_points_to_features.h // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__snap_points_to_features_H #define HEADER_INCLUDED__snap_points_to_features_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSnap_Points_to_Features : public CSG_Module { public: CSnap_Points_to_Features(TSG_Shape_Type Type); protected: virtual bool On_Execute (void); private: void Snap_To_Point (const TSG_Point &Point, CSG_Shape *pPoint, TSG_Point &snap_Point, double &snap_Dist); void Snap_To_Line (const TSG_Point &Point, CSG_Shape *pLine , TSG_Point &snap_Point, double &snap_Dist); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__snap_points_to_features_H saga-2.3.1/src/modules/shapes/shapes_points/thiessen_polygons.cpp0000744000175000017500000001500412737416204026454 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: thiessen_polygons.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // thiessen_polygons.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "thiessen_polygons.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CThiessen_Polygons::CThiessen_Polygons(void) { //----------------------------------------------------- Set_Name (_TL("Thiessen Polygons")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description(_TW( "Creates Thiessen or Voronoi polygons for given point data set." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "FRAME" , _TL("Frame Size"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CThiessen_Polygons::On_Execute(void) { //----------------------------------------------------- CSG_TIN TIN; if( !TIN.Create(Parameters("POINTS")->asShapes()) ) { Error_Set(_TL("TIN creation failed")); return( false ); } //----------------------------------------------------- int nNodes = TIN.Get_Node_Count(); CSG_Rect r(TIN.Get_Extent()); r.Inflate(Parameters("FRAME")->asDouble(), false); //----------------------------------------------------- CSG_Shapes Frame(SHAPE_TYPE_Polygon); CSG_Shape *pFrame = Frame.Add_Shape(); pFrame->Add_Point(r.Get_XMin(), r.Get_YMin()); pFrame->Add_Point(r.Get_XMin(), r.Get_YMax()); pFrame->Add_Point(r.Get_XMax(), r.Get_YMax()); pFrame->Add_Point(r.Get_XMax(), r.Get_YMin()); //----------------------------------------------------- r.Inflate(3 * r.Get_XRange(), 3 * r.Get_YRange(), false); TIN.Add_Node(CSG_Point(r.Get_XCenter(), r.Get_YMin ()), NULL, false); TIN.Add_Node(CSG_Point(r.Get_XMax (), r.Get_YCenter()), NULL, false); TIN.Add_Node(CSG_Point(r.Get_XCenter(), r.Get_YMax ()), NULL, false); TIN.Add_Node(CSG_Point(r.Get_XMin (), r.Get_YCenter()), NULL, false); TIN.Update(); //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); pPolygons->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), TIN.Get_Name(), _TL("Thiessen Polygons")), &TIN); //----------------------------------------------------- for(int iNode=0; iNodeGet_Polygon(Points) ) { CSG_Shape *pPolygon = pPolygons->Add_Shape(TIN.Get_Record(iNode), SHAPE_COPY_ATTR); for(int iPoint=0; iPointAdd_Point(Points[iPoint]); } SG_Polygon_Intersection(pPolygon, pFrame); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/snap_points_to_grid.h0000744000175000017500000001013412737416204026410 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snap_points_to_grid.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // snap_points_to_grid.h // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__snap_points_to_grid_H #define HEADER_INCLUDED__snap_points_to_grid_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSnap_Points_to_Grid : public CSG_Module_Grid { public: CSnap_Points_to_Grid(void); protected: virtual bool On_Execute (void); private: void Snap_To_Grid (const TSG_Point &Point, CSG_Shape *pPoint, TSG_Point &snap_Point, double &snap_Dist); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__snap_points_to_grid_H saga-2.3.1/src/modules/shapes/shapes_points/Clip_Points.cpp0000744000175000017500000001663412737416203025134 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // Clip_Points.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Clip_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CClip_Points::CClip_Points(void) { Set_Name (_TL("Clip Points with Polygons")); Set_Author (SG_T("(c) 2008 by O.Conrad")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Add Attribute to Clipped Points"), _TL(""), true ); Parameters.Add_Shapes_List( NULL , "CLIPS" , _TL("Clipped Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Clipping Options"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("one layer for all points"), _TL("separate layer for each polygon") ), 0 ); } //--------------------------------------------------------- CClip_Points::~CClip_Points(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CClip_Points::On_Execute(void) { int Method, iField; CSG_Shapes *pPoints, *pPolygons, *pClip; CSG_Parameter_Shapes_List *pClips; //----------------------------------------------------- pPoints = Parameters("POINTS") ->asShapes(); pPolygons = Parameters("POLYGONS") ->asShapes(); pClips = Parameters("CLIPS") ->asShapesList(); Method = Parameters("METHOD") ->asInt(); iField = Parameters("FIELD") ->asInt(); //----------------------------------------------------- if( !pPoints->is_Valid() ) { Message_Add(_TL("Invalid points layer.")); return( false ); } else if( !pPolygons->is_Valid() ) { Message_Add(_TL("Invalid polygon layer.")); return( false ); } //----------------------------------------------------- if( iField >= pPolygons->Get_Field_Count() ) { iField = -1; } pClips->Del_Items(); if( Method == 0 ) { pClip = SG_Create_Shapes(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), pPolygons->Get_Name()), pPoints); if( iField >= 0 ) { pClip->Add_Field(pPolygons->Get_Field_Name(iField), pPolygons->Get_Field_Type(iField)); } } //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); if( Method == 1 ) { CSG_String Name(pPoints->Get_Name()); Name += iField >= 0 ? CSG_String::Format(SG_T(" [%s]"), pPolygon->asString(iField)) : CSG_String::Format(SG_T(" [%00d]"), 1 + pClips->Get_Count()); pClip = SG_Create_Shapes(SHAPE_TYPE_Point, Name, pPoints); if( iField >= 0 ) { pClip->Add_Field(pPolygons->Get_Field_Name(iField), pPolygons->Get_Field_Type(iField)); } } for(int iPoint=0; iPointGet_Count() && Process_Get_Okay(false); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); if( pPolygon->Contains(pPoint->Get_Point(0)) ) { pPoint = pClip->Add_Shape(pPoint, SHAPE_COPY); if( iField >= 0 ) { pPoint->Set_Value(pPoints->Get_Field_Count(), pPolygon->asString(iField)); } } } if( Method == 1 ) { if( pClip->Get_Count() > 0 ) { pClips->Add_Item(pClip); } else { delete(pClip); } } } //----------------------------------------------------- if( Method == 0 ) { if( pClip->Get_Count() > 0 ) { pClips->Add_Item(pClip); } else { delete(pClip); } } return( pClips->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/select_points.h0000744000175000017500000001033212737416204025217 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // select_points.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__select_points_H #define HEADER_INCLUDED__select_points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelect_Points : public CSG_Module_Interactive { public: CSelect_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: bool m_bAddCenter; int m_MaxPoints, m_Quadrant; double m_Radius; CSG_Shapes *m_pPoints, *m_pSelection; CSG_PRQuadTree m_Search; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__select_points_H saga-2.3.1/src/modules/shapes/shapes_points/FitNPointsToShape.h0000744000175000017500000000256612737416203025676 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* FitNPointsToShape.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CFitNPointsToShape : public CSG_Module { public: CFitNPointsToShape(void); virtual ~CFitNPointsToShape(void); virtual bool is_ProjectDependent(void) {return( false );} protected: virtual bool On_Execute(void); }; saga-2.3.1/src/modules/shapes/shapes_points/Makefile.in0000664000175000017500000006224612737447617024270 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/shapes/shapes_points ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_points_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_points_la_OBJECTS = add_polygon_attributes.lo \ AddCoordinates.lo Clip_Points.lo convex_hull.lo CountPoints.lo \ CreatePointGrid.lo DistanceMatrix.lo FitNPointsToShape.lo \ gps_track_aggregation.lo MLB_Interface.lo points_filter.lo \ Points_From_Lines.lo Points_From_Table.lo points_thinning.lo \ remove_duplicates.lo select_points.lo separate_by_direction.lo \ snap_points_to_features.lo snap_points_to_grid.lo \ thiessen_polygons.lo libshapes_points_la_OBJECTS = $(am_libshapes_points_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_points_la_SOURCES) DIST_SOURCES = $(libshapes_points_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id$ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_points.la libshapes_points_la_SOURCES = \ add_polygon_attributes.cpp\ AddCoordinates.cpp\ Clip_Points.cpp\ convex_hull.cpp\ CountPoints.cpp\ CreatePointGrid.cpp\ DistanceMatrix.cpp\ FitNPointsToShape.cpp\ gps_track_aggregation.cpp\ MLB_Interface.cpp\ points_filter.cpp\ Points_From_Lines.cpp\ Points_From_Table.cpp\ points_thinning.cpp\ remove_duplicates.cpp\ select_points.cpp\ separate_by_direction.cpp\ snap_points_to_features.cpp\ snap_points_to_grid.cpp\ thiessen_polygons.cpp\ add_polygon_attributes.h\ AddCoordinates.h\ convex_hull.h\ CountPoints.h\ Clip_Points.h\ CreatePointGrid.h\ DistanceMatrix.h\ FitNPointsToShape.h\ gps_track_aggregation.h\ MLB_Interface.h\ points_filter.h\ Points_From_Lines.h\ Points_From_Table.h\ points_thinning.h\ remove_duplicates.h\ select_points.h\ separate_by_direction.h\ snap_points_to_features.h\ snap_points_to_grid.h\ thiessen_polygons.h libshapes_points_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/shapes/shapes_points/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_points/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_points.la: $(libshapes_points_la_OBJECTS) $(libshapes_points_la_DEPENDENCIES) $(EXTRA_libshapes_points_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_points_la_OBJECTS) $(libshapes_points_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AddCoordinates.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Clip_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CountPoints.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CreatePointGrid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DistanceMatrix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FitNPointsToShape.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Points_From_Lines.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Points_From_Table.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_polygon_attributes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convex_hull.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gps_track_aggregation.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_filter.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_thinning.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/remove_duplicates.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/select_points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/separate_by_direction.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snap_points_to_features.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snap_points_to_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/thiessen_polygons.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/shapes/shapes_points/add_polygon_attributes.h0000744000175000017500000000766612737416203027130 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // add_polygon_attributes.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__add_polygon_attributes_H #define HEADER_INCLUDED__add_polygon_attributes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CAdd_Polygon_Attributes : public CSG_Module { public: CAdd_Polygon_Attributes(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__add_polygon_attributes_H saga-2.3.1/src/modules/shapes/shapes_points/convex_hull.cpp0000744000175000017500000004135212737416203025232 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: remove_duplicates.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // convex_hull.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "convex_hull.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CConvex_Hull::CConvex_Hull(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Convex Hull")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Implementation of 'Andrew's Monotone Chain Algorithm' for convex hull construction. " "\nReferences:\n" "Algorithmist (2011): Monotone Chain Convex Hull. algorithmist.com.\n" "Andrew, A.M. (1979): Another Efficient Algorithm for Convex Hulls in Two Dimensions. Info. Proc. Letters 9, pp.216-219.\n" "Sunday, D. (2001-2006): The Convex Hull of a 2D Point Set or Polygon. Softsurfer.com.\n" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "HULLS" , _TL("Convex Hull"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "BOXES" , _TL("Minimum Bounding Box"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "POLYPOINTS" , _TL("Hull Construction"), _TL("This option does not apply to simple point layers."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("one hull for all shapes"), _TL("one hull per shape"), _TL("one hull per shape part") ), 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CConvex_Hull::On_Execute(void) { CSG_Shapes *pShapes, *pHulls, *pBoxes; //----------------------------------------------------- pShapes = Parameters("SHAPES")->asShapes(); pHulls = Parameters("HULLS" )->asShapes(); pBoxes = Parameters("BOXES" )->asShapes(); //----------------------------------------------------- pHulls->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Convex Hull"))); pHulls->Add_Field(_TL("ID" ), SG_DATATYPE_Int); pHulls->Add_Field(_TL("AREA" ), SG_DATATYPE_Double); pHulls->Add_Field(_TL("PERIMETER"), SG_DATATYPE_Double); //----------------------------------------------------- int nOkay = 0; //----------------------------------------------------- if( pShapes->Get_Type() == SHAPE_TYPE_Point ) { nOkay = Get_Chain_Hull(pShapes, pHulls) ? 1 : 0; } //----------------------------------------------------- else { CSG_Shapes Points(SHAPE_TYPE_Point); int Construction = Parameters("POLYPOINTS")->asInt(); if( Construction != 0 ) { for(int iField=0; iFieldGet_Field_Count(); iField++) { pHulls->Add_Field(pShapes->Get_Field_Name(iField), pShapes->Get_Field_Type(iField)); } } for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Points.Add_Shape()->Add_Point(pShape->Get_Point(iPoint, iPart)); } if( Construction == 2 ) // one hull per shape part { if( Get_Chain_Hull(&Points, pHulls, pShape) ) nOkay++; Points.Del_Records(); } } if( Construction == 1 ) // one hull per shape { if( Get_Chain_Hull(&Points, pHulls, pShape) ) nOkay++; Points.Del_Records(); } } if( Construction == 0 ) // one hull for all shapes { if( Get_Chain_Hull(&Points, pHulls) ) nOkay++; Points.Del_Records(); } } if( nOkay <= 0 ) { return( false ); } //----------------------------------------------------- if( pBoxes ) { pBoxes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Bounding Box"))); pBoxes->Add_Field(_TL("ID") , SG_DATATYPE_Int); pBoxes->Add_Field(_TL("AREA") , SG_DATATYPE_Double); pBoxes->Add_Field(_TL("PERIMETER") , SG_DATATYPE_Double); for(int iHull=0; iHullGet_Count() && Set_Progress(iHull, pHulls->Get_Count()); iHull++) { Get_Bounding_Box(pHulls->Get_Shape(iHull), pBoxes->Add_Shape()); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CConvex_Hull::Get_Bounding_Box(CSG_Shape *pHull, CSG_Shape *pBox) { int i, iBox; double a, aBox, d, dBox, dSin, dCos; TSG_Rect r, rBox; TSG_Point A, B; B = pHull->Get_Point(pHull->Get_Point_Count() - 1); for(i=0; iGet_Point_Count(); i++) { A = B; B = pHull->Get_Point(i); d = SG_Get_Angle_Of_Direction(A, B); dSin = sin(-d); dCos = cos(-d); for(int j=0; jGet_Point_Count(); j++) { TSG_Point q, p = pHull->Get_Point(j); q.x = p.x * dCos - p.y * dSin; q.y = p.x * dSin + p.y * dCos; if( j == 0 ) { r.xMin = r.xMax = q.x; r.yMin = r.yMax = q.y; } else { if( r.xMin > q.x ) r.xMin = q.x; else if( r.xMax < q.x ) r.xMax = q.x; if( r.yMin > q.y ) r.yMin = q.y; else if( r.yMax < q.y ) r.yMax = q.y; } } a = (r.xMax - r.xMin) * (r.yMax - r.yMin); if( i == 0 || a < aBox ) { iBox = i; aBox = a; dBox = d; rBox = r; } } //----------------------------------------------------- dSin = sin(dBox); dCos = cos(dBox); pBox->Add_Point(rBox.xMin * dCos - rBox.yMin * dSin, rBox.xMin * dSin + rBox.yMin * dCos); pBox->Add_Point(rBox.xMin * dCos - rBox.yMax * dSin, rBox.xMin * dSin + rBox.yMax * dCos); pBox->Add_Point(rBox.xMax * dCos - rBox.yMax * dSin, rBox.xMax * dSin + rBox.yMax * dCos); pBox->Add_Point(rBox.xMax * dCos - rBox.yMin * dSin, rBox.xMax * dSin + rBox.yMin * dCos); pBox->Add_Point(pBox->Get_Point(0)); pBox->Set_Value(0, pBox->Get_Index()); pBox->Set_Value(1, aBox); pBox->Set_Value(2, 2.0 * ((rBox.xMax - rBox.xMin) + (rBox.yMax - rBox.yMin))); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CConvex_Hull::Get_Chain_Hull(CSG_Shapes *pPoints, CSG_Shapes *pHulls, CSG_Shape *pAttributes) { int i, n; CSG_Points Points, Hull; //----------------------------------------------------- if( pPoints->Get_Count() < 3 ) { return( false ); } //----------------------------------------------------- m_pPoints = pPoints; CSG_Index Index(m_pPoints->Get_Count(), (TSG_PFNC_Compare)CConvex_Hull::Compare); m_pPoints = NULL; if( !Index.is_Okay() ) { return( false ); } for(i=0; iGet_Count(); i++) { Points.Add(pPoints->Get_Shape(Index[i])->Get_Point(0)); } //----------------------------------------------------- if( (n = Get_Chain_Hull(Points, Hull)) < 3 ) { return( false ); } //----------------------------------------------------- CSG_Shape *pHull = pHulls->Add_Shape(); for(i=0; iAdd_Point(Hull[i]); } pHull->Set_Value(0, pHull->Get_Index()); pHull->Set_Value(1, ((CSG_Shape_Polygon *)pHull)->Get_Area()); pHull->Set_Value(2, ((CSG_Shape_Polygon *)pHull)->Get_Perimeter()); if( pAttributes ) { for(i=3, n=0; iGet_Field_Count(); i++, n++) { *pHull->Get_Value(i) = *pAttributes->Get_Value(n); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shapes * CConvex_Hull::m_pPoints = NULL; //--------------------------------------------------------- int CConvex_Hull::Compare(const int iElement_1, const int iElement_2) { TSG_Point a = m_pPoints->Get_Shape(iElement_1)->Get_Point(0); TSG_Point b = m_pPoints->Get_Shape(iElement_2)->Get_Point(0); if( a.x < b.x ) { return( -1 ); } if( a.x > b.x ) { return( 1 ); } if( a.y < b.y ) { return( -1 ); } if( a.y > b.y ) { return( 1 ); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // Copyright 2001, softSurfer (www.softsurfer.com) // This code may be freely used and modified for any purpose // providing that this copyright notice is included with it. // SoftSurfer makes no warranty for this code, and cannot be held // liable for any real or imagined damage resulting from its use. // Users of this code must verify correctness for their application. //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // is_Left(): tests if a point is Left|On|Right of an infinite line. // Input: three points Line_A, Line_B, and Point // Return: >0 for Point left of the line through P0 and P1 // =0 for Point on the line // <0 for Point right of the line // See: the January 2001 Algorithm on Area of Triangles //--------------------------------------------------------- inline double CConvex_Hull::is_Left(const TSG_Point &Line_A, const TSG_Point &Line_B, const TSG_Point &Point) { return( (Line_B.x - Line_A.x) * (Point.y - Line_A.y) - (Point.x - Line_A.x) * (Line_B.y - Line_A.y) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // chainHull_2D(): Andrew's monotone chain 2D convex hull algorithm // Input: P[] = an array of 2D points // presorted by increasing x- and y-coordinates // n = the number of points in P[] // Output: H[] = an array of the convex hull vertices (max is n) // Return: the number of points in H[] //--------------------------------------------------------- int CConvex_Hull::Get_Chain_Hull(CSG_Points &P, CSG_Points &H) { int i, n, bot, top, minmin, minmax, maxmin, maxmax; double xmin, xmax; //----------------------------------------------------- // the output array H[] will be used as the stack n = P.Get_Count(); H.Set_Count(2 * n); bot = 0; // index for bottom of the stack top = -1; // index for top of the stack //----------------------------------------------------- // Get the indices of points with min x-coord and min|max y-coord minmin = 0; xmin = P[0].x; for(i=1; i=0; i--) { if( P[i].x != xmax ) { break; } } maxmin = i + 1; //----------------------------------------------------- // Compute the lower hull on the stack H H[++top] = P[minmin]; // push minmin point onto stack i = minmax; while( ++i <= maxmin && Process_Get_Okay() ) { // the lower line joins P[minmin] with P[maxmin] if( is_Left(P[minmin], P[maxmin], P[i]) >= 0 && i < maxmin ) continue; // ignore P[i] above or on the lower line while( top > 0 ) // there are at least 2 points on the stack { // test if P[i] is left of the line at the stack top if( is_Left(H[top-1], H[top], P[i]) > 0 ) break; // P[i] is a new hull vertex else top--; // pop top point off stack } H[++top] = P[i]; // push P[i] onto stack } //----------------------------------------------------- // Next, compute the upper hull on the stack H above the bottom hull if( maxmax != maxmin ) // if distinct xmax points { H[++top] = P[maxmax]; // push maxmax point onto stack } bot = top; // the bottom point of the upper hull stack i = maxmin; while( --i >= minmax && Process_Get_Okay() ) { // the upper line joins P[maxmax] with P[minmax] if( is_Left(P[maxmax], P[minmax], P[i]) >= 0 && i > minmax ) continue; // ignore P[i] below or on the upper line while( top > bot ) // at least 2 points on the upper stack { // test if P[i] is left of the line at the stack top if( is_Left(H[top-1], H[top], P[i]) > 0 ) break; // P[i] is a new hull vertex else top--; // pop top point off stack } H[++top] = P[i]; // push P[i] onto stack } if( minmax != minmin ) { H[++top] = P[minmin]; // push joining endpoint onto stack } return( top + 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/thiessen_polygons.h0000744000175000017500000001002212737416204026114 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: thiessen_polygons.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // thiessen_polygons.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__thiessen_polygons_H #define HEADER_INCLUDED__thiessen_polygons_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CThiessen_Polygons : public CSG_Module { public: CThiessen_Polygons(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__thiessen_polygons_H saga-2.3.1/src/modules/shapes/shapes_points/snap_points_to_features.cpp0000744000175000017500000002201512737416204027635 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snap_points_to_features.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // snap_points_to_features.cpp // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "snap_points_to_features.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSnap_Points_to_Features::CSnap_Points_to_Features(TSG_Shape_Type Type) { //----------------------------------------------------- Set_Name (Type == SHAPE_TYPE_Point ? _TL("Snap Points to Points") : _TL("Snap Points to Lines") ); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "SNAP" , _TL("Snap Features"), _TL(""), PARAMETER_INPUT, Type ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "MOVES" , _TL("Moves"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "DISTANCE" , _TL("Search Distance"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSnap_Points_to_Features::On_Execute(void) { double Distance; CSG_Shapes *pInput, *pPoints, *pSnap, *pMoves; //----------------------------------------------------- pInput = Parameters("INPUT" )->asShapes(); pPoints = Parameters("OUTPUT" )->asShapes(); pSnap = Parameters("SNAP" )->asShapes(); pMoves = Parameters("MOVES" )->asShapes(); Distance = Parameters("DISTANCE")->asDouble(); //----------------------------------------------------- if( !pInput->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( !pSnap->is_Valid() || pSnap->Get_Count() <= 0 ) { Error_Set(_TL("invalid snap features")); return( false ); } //----------------------------------------------------- if( pPoints && pPoints != pInput ) { pPoints->Create(*pInput); } else { Parameters("RESULT")->Set_Value(pPoints = pInput); } pPoints->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pInput->Get_Name(), _TL("snapped"), pSnap->Get_Name())); if( pMoves ) { pMoves->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pInput->Get_Name(), _TL("snap move"), pSnap->Get_Name()), pPoints); } //----------------------------------------------------- bool bDistance = Distance > 0.0; if( !bDistance ) { CSG_Rect r(pPoints->Get_Extent()); r.Union(pSnap->Get_Extent()); Distance = SG_Get_Distance(r.Get_BottomRight(), r.Get_TopLeft()); } //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); TSG_Point Point = pPoint->Get_Point(0), snap_Point; double snap_Dist = Distance; if( bDistance ) { if( pSnap->Select(CSG_Rect(Point.x - Distance, Point.y - Distance, Point.x + Distance, Point.y + Distance)) ) { for(int i=0; iGet_Selection_Count() && snap_Dist>0.0; i++) { if( pSnap->Get_Type() == SHAPE_TYPE_Point ) { Snap_To_Point(Point, pSnap->Get_Selection(i), snap_Point, snap_Dist); } else { Snap_To_Line (Point, pSnap->Get_Selection(i), snap_Point, snap_Dist); } } } } else { for(int i=0; iGet_Count() && snap_Dist>0.0; i++) { if( pSnap->Get_Type() == SHAPE_TYPE_Point ) { Snap_To_Point(Point, pSnap->Get_Shape(i), snap_Point, snap_Dist); } else { Snap_To_Line (Point, pSnap->Get_Shape(i), snap_Point, snap_Dist); } } } //------------------------------------------------- if( snap_Dist < Distance ) { pPoint->Set_Point(snap_Point, 0); if( pMoves ) { CSG_Shape *pMove = pMoves->Add_Shape(pPoint, SHAPE_COPY_ATTR); pMove->Add_Point(Point); pMove->Add_Point(snap_Point); } } } //----------------------------------------------------- if( bDistance ) { pSnap->Select(); // reset selection } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSnap_Points_to_Features::Snap_To_Point(const TSG_Point &Point, CSG_Shape *pPoint, TSG_Point &snap_Point, double &snap_Dist) { double d = SG_Get_Distance(Point, pPoint->Get_Point(0)); if( d < snap_Dist ) { snap_Dist = d; snap_Point = pPoint->Get_Point(0); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSnap_Points_to_Features::Snap_To_Line(const TSG_Point &Point, CSG_Shape *pLine, TSG_Point &snap_Point, double &snap_Dist) { CSG_Rect r(pLine->Get_Extent()); r.Inflate(snap_Dist, false); if( r.Contains(Point) ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point C, B, A = pLine->Get_Point(0, iPart); for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { B = A; A = pLine->Get_Point(iPoint, iPart); r.Assign(A, B); r.Inflate(snap_Dist, false); if( r.Contains(Point) ) { double d = SG_Get_Nearest_Point_On_Line(Point, A, B, C, true); if( d >= 0.0 && d < snap_Dist ) { snap_Dist = d; snap_Point = C; } } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/Makefile.am0000744000175000017500000000243112737416203024227 0ustar00oconradoconrad00000000000000# # $Id$ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_points.la libshapes_points_la_SOURCES =\ add_polygon_attributes.cpp\ AddCoordinates.cpp\ Clip_Points.cpp\ convex_hull.cpp\ CountPoints.cpp\ CreatePointGrid.cpp\ DistanceMatrix.cpp\ FitNPointsToShape.cpp\ gps_track_aggregation.cpp\ MLB_Interface.cpp\ points_filter.cpp\ Points_From_Lines.cpp\ Points_From_Table.cpp\ points_thinning.cpp\ remove_duplicates.cpp\ select_points.cpp\ separate_by_direction.cpp\ snap_points_to_features.cpp\ snap_points_to_grid.cpp\ thiessen_polygons.cpp\ add_polygon_attributes.h\ AddCoordinates.h\ convex_hull.h\ CountPoints.h\ Clip_Points.h\ CreatePointGrid.h\ DistanceMatrix.h\ FitNPointsToShape.h\ gps_track_aggregation.h\ MLB_Interface.h\ points_filter.h\ Points_From_Lines.h\ Points_From_Table.h\ points_thinning.h\ remove_duplicates.h\ select_points.h\ separate_by_direction.h\ snap_points_to_features.h\ snap_points_to_grid.h\ thiessen_polygons.h libshapes_points_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/shapes/shapes_points/gps_track_aggregation.cpp0000744000175000017500000003557512737416203027242 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gps_track_aggregation.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // gps_track_aggregation.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gps_track_aggregation.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { AGG_ID = 0, AGG_TRACK, AGG_DATE, AGG_TIME, AGG_PARM, AGG_MIN, AGG_MAX, AGG_RANGE, AGG_STDDEV, AGG_COUNT, AGG_DROPPED, AGG_DTIME, AGG_X, AGG_Y }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGPS_Track_Aggregation::CGPS_Track_Aggregation(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Aggregate Point Observations")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- // 2. Parameters... pNode = Parameters.Add_Shapes( NULL , "REFERENCE" , _TL("Reference Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "REFERENCE_ID" , _TL("ID"), _TL("") ); pNode = Parameters.Add_Table( NULL , "OBSERVATIONS" , _TL("Observations"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "X" , _TL("X"), _TL("") ); Parameters.Add_Table_Field( pNode , "Y" , _TL("Y"), _TL("") ); Parameters.Add_Table_Field( pNode , "TRACK" , _TL("Track"), _TL("") ); Parameters.Add_Table_Field( pNode , "DATE" , _TL("Date"), _TL("") ); Parameters.Add_Table_Field( pNode , "TIME" , _TL("Time"), _TL("expected to be the second of day") ); Parameters.Add_Table_Field( pNode , "PARAMETER" , _TL("Parameter"), _TL("") ); Parameters.Add_Table( NULL , "AGGREGATED" , _TL("Aggregated"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "TIME_SPAN" , _TL("Time Span Aggregation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("ignore"), _TL("floating"), _TL("fixed") ), 1 ); Parameters.Add_Value( NULL , "FIX_TIME" , _TL("Fixed Time Span (minutes)"), _TL("ignored if set to zero"), PARAMETER_TYPE_Double, 20.0, 0.0, true ); Parameters.Add_Value( NULL , "OFF_TIME" , _TL("Fixed Time Span Offset (minutes)"), _TL("offset in minutes relative to 00:00 (midnight)"), PARAMETER_TYPE_Double, -10.0 ); Parameters.Add_Value( NULL , "EPS_TIME" , _TL("Maximum Time Span (Seconds)"), _TL("ignored if set to zero"), PARAMETER_TYPE_Double, 60.0, 0.0, true ); Parameters.Add_Value( NULL , "EPS_SPACE" , _TL("Maximum Distance"), _TL("given as map units or meters if polar coordinates switch is on; ignored if set to zero"), PARAMETER_TYPE_Double, 100.0, 0.0, true ); Parameters.Add_Value( NULL , "VERBOSE" , _TL("Verbose"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "POLAR" , _TL("Polar Coordinates"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGPS_Track_Aggregation::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("TIME_SPAN")) ) { pParameters->Get_Parameter("FIX_TIME")->Set_Enabled(pParameter->asInt() == 2); pParameters->Get_Parameter("OFF_TIME")->Set_Enabled(pParameter->asInt() == 2); pParameters->Get_Parameter("EPS_TIME")->Set_Enabled(pParameter->asInt() == 1); } return( -1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGPS_Track_Aggregation::On_Execute(void) { bool bVerbose, bPolar; int Time_Span, fRefID, fX, fY, fTrack, fDate, fTime, fParameter, Observation, iDropped, nDropped; double eps_Space, eps_Time, off_Time, iTime; TSG_Point Position; CSG_String iTrack, iDate; CSG_Table_Record *pAggregate, *pObservation; CSG_Shape *pReference, *pNearest; CSG_Simple_Statistics Statistic, Time; CSG_Table *pObservations, *pAggregated, Observations; CSG_Shapes_Search Reference; //----------------------------------------------------- pObservations = Parameters("OBSERVATIONS") ->asTable (); pAggregated = Parameters("AGGREGATED") ->asTable (); fRefID = Parameters("REFERENCE_ID") ->asInt (); fX = Parameters("X") ->asInt (); fY = Parameters("Y") ->asInt (); fTrack = Parameters("TRACK") ->asInt (); fDate = Parameters("DATE") ->asInt (); fTime = Parameters("TIME") ->asInt (); fParameter = Parameters("PARAMETER") ->asInt (); Time_Span = Parameters("TIME_SPAN") ->asInt (); eps_Space = Parameters("EPS_SPACE") ->asDouble(); off_Time = Parameters("OFF_TIME") ->asDouble() * 60.0; bVerbose = Parameters("VERBOSE") ->asBool (); bPolar = Parameters("POLAR") ->asBool (); switch( Time_Span ) { default: eps_Time = 0.0; break; case 1: eps_Time = Parameters("EPS_TIME")->asDouble(); break; case 2: eps_Time = Parameters("FIX_TIME")->asDouble() * 60.0; break; } if( eps_Time <= 0.0 ) { Time_Span = 0; } //----------------------------------------------------- if( !Reference.Create(Parameters("REFERENCE")->asShapes()) ) { Error_Set(_TL("could not initialize reference point search engine")); return( false ); } //----------------------------------------------------- if( Time_Span == 2 ) // pre-processing for 'fix' time span { Observations.Create(*pObservations); Observations.Add_Field(SG_T("REF_ID"), SG_DATATYPE_String); fTrack = pObservations->Get_Field_Count(); pObservations = &Observations; for(Observation=0; ObservationGet_Count() && Set_Progress(Observation, pObservations->Get_Count()); Observation++) { pObservation = pObservations->Get_Record(Observation); pNearest = Reference.Get_Point_Nearest(pObservation->asDouble(fX), pObservation->asDouble(fY)); pObservation ->Set_Value(fTrack, pNearest->asString(fRefID)); } } //----------------------------------------------------- if( !pObservations->Set_Index(fTrack, TABLE_INDEX_Ascending, fDate, TABLE_INDEX_Ascending, fTime, TABLE_INDEX_Ascending) ) { Error_Set(_TL("could not create index on observations")); return( false ); } //----------------------------------------------------- pAggregated->Destroy(); pAggregated->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pObservations->Get_Name(), _TL("aggregated"))); pAggregated->Add_Field(SG_T("REFID") , SG_DATATYPE_String); // AGG_ID pAggregated->Add_Field(SG_T("TRACK") , SG_DATATYPE_String); // AGG_TRACK pAggregated->Add_Field(SG_T("DATE") , SG_DATATYPE_String); // AGG_DATE pAggregated->Add_Field(SG_T("TIME") , SG_DATATYPE_String); // AGG_TIME pAggregated->Add_Field(pObservations->Get_Field_Name(fParameter), SG_DATATYPE_Double); // AGG_PARM if( bVerbose ) { pAggregated->Add_Field(SG_T("MIN") , SG_DATATYPE_Double); // AGG_MIN, pAggregated->Add_Field(SG_T("MAX") , SG_DATATYPE_Double); // AGG_MAX pAggregated->Add_Field(SG_T("RANGE") , SG_DATATYPE_Double); // AGG_RANGE pAggregated->Add_Field(SG_T("STDDEV") , SG_DATATYPE_Double); // AGG_STDDEV, pAggregated->Add_Field(SG_T("COUNT") , SG_DATATYPE_Int ); // AGG_COUNT, pAggregated->Add_Field(SG_T("DROPPED") , SG_DATATYPE_Int ); // AGG_DROPPED, pAggregated->Add_Field(SG_T("DTIME") , SG_DATATYPE_Double); // AGG_DTIME, pAggregated->Add_Field(SG_T("X") , SG_DATATYPE_Double); // AGG_X pAggregated->Add_Field(SG_T("Y") , SG_DATATYPE_Double); // AGG_Y } //----------------------------------------------------- pAggregate = NULL; nDropped = 0; iDropped = 0; //----------------------------------------------------- for(Observation=0; ObservationGet_Count() && Set_Progress(Observation, pObservations->Get_Count()); Observation++) { pObservation = pObservations->Get_Record_byIndex(Observation); if( !pAggregate || iTrack.Cmp(pObservation->asString(fTrack)) || iDate .Cmp(pObservation->asString(fDate )) || (eps_Time > 0.0 && eps_Time <= pObservation->asDouble(fTime) - iTime) ) { pReference = NULL; } Position.x = pObservation->asDouble(fX); Position.y = pObservation->asDouble(fY); pNearest = Reference.Get_Point_Nearest(Position.x, Position.y); if( eps_Space > 0.0 && eps_Space <= (bPolar ? SG_Get_Distance_Polar(Position, pNearest->Get_Point(0)) : SG_Get_Distance(Position, pNearest->Get_Point(0))) ) { nDropped++; iDropped++; } else { if( pReference != pNearest ) { Set_Statistic(pAggregate, Statistic, Time, iDropped, bVerbose); Statistic .Invalidate(); Time .Invalidate(); iDropped = 0; iTrack = pObservation->asString(fTrack); iDate = pObservation->asString(fDate ); switch( Time_Span ) { default: iTime = 0.0; break; case 1: iTime = pObservation->asDouble(fTime); break; case 2: iTime = (int)(pObservation->asDouble(fTime) / eps_Time) * eps_Time - off_Time; break; } pReference = pNearest; pAggregate = pAggregated->Add_Record(); pAggregate ->Set_Value(AGG_ID , pReference->asString(fRefID)); pAggregate ->Set_Value(AGG_TRACK, iTrack); pAggregate ->Set_Value(AGG_DATE , iDate ); if( bVerbose ) { pAggregate ->Set_Value(AGG_X, pReference->Get_Point(0).x); pAggregate ->Set_Value(AGG_Y, pReference->Get_Point(0).y); } } Statistic += pObservation->asDouble(fParameter); Time += pObservation->asDouble(fTime ); } } Set_Statistic(pAggregate, Statistic, Time, iDropped, bVerbose); //----------------------------------------------------- if( nDropped > 0 ) { Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("number of dropped observations"), nDropped)); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGPS_Track_Aggregation::Set_Statistic(CSG_Table_Record *pAggregate, CSG_Simple_Statistics &Statistic, CSG_Simple_Statistics &Time, int nDropped, bool bVerbose) { if( pAggregate ) { pAggregate ->Set_Value(AGG_PARM , Statistic.Get_Mean()); pAggregate ->Set_Value(AGG_TIME , Time .Get_Mean()); if( bVerbose ) { pAggregate ->Set_Value(AGG_MIN , Statistic.Get_Minimum()); pAggregate ->Set_Value(AGG_MAX , Statistic.Get_Maximum()); pAggregate ->Set_Value(AGG_RANGE , Statistic.Get_Range ()); pAggregate ->Set_Value(AGG_STDDEV , Statistic.Get_StdDev ()); pAggregate ->Set_Value(AGG_COUNT , Statistic.Get_Count ()); pAggregate ->Set_Value(AGG_DTIME , Time .Get_Range ()); pAggregate ->Set_Value(AGG_DROPPED, nDropped); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/AddCoordinates.h0000744000175000017500000000231712737416203025232 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* AddCoordinates.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "MLB_Interface.h" class CAddCoordinates : public CSG_Module { public: CAddCoordinates(void); protected: virtual bool On_Execute(void); }; saga-2.3.1/src/modules/shapes/shapes_points/remove_duplicates.cpp0000744000175000017500000002347112737416203026420 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // Remove_Duplicates.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "remove_duplicates.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CRemove_Duplicates::CRemove_Duplicates(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Remove Duplicate Points")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("") ); Parameters.Add_Shapes( NULL , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Point to Keep"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("first point"), _TL("last point"), _TL("point with minimum attribute value"), _TL("point with maximum attribute value") ), 0 ); Parameters.Add_Choice( NULL , "NUMERIC" , _TL("Numeric Attribute Values"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("take value from the point to be kept"), _TL("minimum value of all duplicates"), _TL("maximum value of all duplicates"), _TL("mean value of all duplicates") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CRemove_Duplicates::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("METHOD")) ) { pParameters->Get_Parameter("FIELD")->Set_Enabled(pParameter->asInt() >= 2); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CRemove_Duplicates::On_Execute(void) { CSG_PRQuadTree Search; //----------------------------------------------------- m_pPoints = Parameters("RESULT") ->asShapes(); m_Field = Parameters("FIELD") ->asInt(); m_Method = Parameters("METHOD") ->asInt(); m_Numeric = Parameters("NUMERIC") ->asInt(); //----------------------------------------------------- if( m_pPoints == NULL ) { m_pPoints = Parameters("POINTS")->asShapes(); } else if( m_pPoints != Parameters("POINTS")->asShapes() ) { m_pPoints ->Assign(Parameters("POINTS")->asShapes()); } //----------------------------------------------------- if( !m_pPoints->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( m_pPoints->Get_Count() <= 0 ) { Error_Set(_TL("no points in layer")); return( false ); } if( !Search.Create(m_pPoints, -1) ) { Error_Set(_TL("failed to initialise search engine")); return( false ); } //----------------------------------------------------- m_pPoints->Add_Field(_TL("Duplicates"), SG_DATATYPE_Int); m_pPoints->Select(); for(int i=0; iGet_Count() && Set_Progress(i, m_pPoints->Get_Count()); i++) { CSG_Shape *pPoint = m_pPoints->Get_Shape(i); if( !pPoint->is_Selected() ) { double Distance; CSG_PRQuadTree_Leaf *pLeaf = Search.Get_Nearest_Leaf(pPoint->Get_Point(0), Distance); if( Distance == 0.0 && pLeaf && pLeaf->has_Statistics() ) { Set_Attributes(pPoint, (CSG_PRQuadTree_Leaf_List *)pLeaf); } } } //----------------------------------------------------- if( m_pPoints->Get_Selection_Count() == 0 ) { Message_Add(_TL("No duplicates found.")); } else { Message_Add(CSG_String::Format(SG_T("%d %s"), m_pPoints->Get_Selection_Count(), _TL("duplicates have been identified."))); m_pPoints->Del_Selection(); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CRemove_Duplicates::Set_Attributes(CSG_Shape *pPoint, CSG_PRQuadTree_Leaf_List *pList) { int iDuplicate; double dKeep; CSG_Shape *pKeep; //----------------------------------------------------- for(iDuplicate=0, pKeep=NULL; iDuplicateGet_Count(); iDuplicate++) { CSG_Shape *pDuplicate = m_pPoints->Get_Shape((int)pList->Get_Value(iDuplicate)); if( pDuplicate != pPoint ) { m_pPoints->Select(pDuplicate->Get_Index(), true); } switch( m_Method ) { case 2: // point with minimum attribute value if( !pKeep || (!pDuplicate->is_NoData(m_Field) && pDuplicate->asDouble(m_Field) < dKeep) ) { dKeep = pDuplicate->asDouble(m_Field); pKeep = pDuplicate; } break; case 3: // point with maximum attribute value") if( !pKeep || (!pDuplicate->is_NoData(m_Field) && pDuplicate->asDouble(m_Field) > dKeep) ) { dKeep = pDuplicate->asDouble(m_Field); pKeep = pDuplicate; } break; } } //----------------------------------------------------- if( m_Method == 1 ) // last point { pKeep = m_pPoints->Get_Shape((int)pList->Get_Value((int)(pList->Get_Count() - 1))); } if( pKeep ) { ((CSG_Table_Record *)pPoint)->Assign(pKeep); } pPoint->Set_Value(m_pPoints->Get_Field_Count() - 1, (double)pList->Get_Count()); //----------------------------------------------------- if( m_Numeric > 0 ) { for(int iField=0; iFieldGet_Field_Count()-1; iField++) { if( SG_Data_Type_is_Numeric(m_pPoints->Get_Field_Type(iField)) ) { CSG_Simple_Statistics s; for(iDuplicate=0; iDuplicateGet_Count(); iDuplicate++) { CSG_Shape *pDuplicate = m_pPoints->Get_Shape((int)pList->Get_Value(iDuplicate)); if( !pDuplicate->is_NoData(iField) ) { s += m_pPoints->Get_Shape((int)pList->Get_Value(iDuplicate))->asDouble(iField); } } switch( m_Numeric ) { case 1: pPoint->Set_Value(iField, s.Get_Minimum()); break; // minimun value case 2: pPoint->Set_Value(iField, s.Get_Maximum()); break; // maximum value case 3: pPoint->Set_Value(iField, s.Get_Mean()); break; // mean value } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/MLB_Interface.h0000744000175000017500000000736112737416203024745 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2004 by // // Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: volaya@ya.com // // // // contact: Victor Olaya Ferrero // // Madrid // // Spain // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__shapes_points_H #define HEADER_INCLUDED__shapes_points_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef shapes_points_EXPORTS #define shapes_points_EXPORT _SAGA_DLL_EXPORT #else #define shapes_points_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_points_H saga-2.3.1/src/modules/shapes/shapes_points/gps_track_aggregation.h0000744000175000017500000001131412737416203026670 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gps_track_aggregation.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // gps_track_aggregation.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gps_track_aggregation_H #define HEADER_INCLUDED__gps_track_aggregation_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGPS_Track_Aggregation : public CSG_Module { public: CGPS_Track_Aggregation(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool Set_Statistic (CSG_Table_Record *pAggregate, CSG_Simple_Statistics &Statistic, CSG_Simple_Statistics &Time, int nDropped, bool bVerbose); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gps_track_aggregation_H saga-2.3.1/src/modules/shapes/shapes_points/Points_From_Table.h0000744000175000017500000000462112737416203025715 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* Points_From_Table.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Points_From_Table_H #define HEADER_INCLUDED__Points_From_Table_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_From_Table : public CSG_Module { public: CPoints_From_Table(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Points_From_Table_H saga-2.3.1/src/modules/shapes/shapes_points/MLB_Interface.cpp0000744000175000017500000001342612737416203025277 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: volaya@ya.com // // // // contact: Victor Olaya Ferrero // // Madrid // // Spain // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Points") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( _TL("Various Authors") ); case MLB_INFO_Description: return( _TL("Tools for the manipulation of point vector data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Points") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Points_From_Table.h" #include "Points_From_Lines.h" #include "CountPoints.h" #include "CreatePointGrid.h" #include "DistanceMatrix.h" #include "FitNPointsToShape.h" #include "AddCoordinates.h" #include "remove_duplicates.h" #include "Clip_Points.h" #include "separate_by_direction.h" #include "add_polygon_attributes.h" #include "points_filter.h" #include "convex_hull.h" #include "select_points.h" #include "points_thinning.h" #include "thiessen_polygons.h" #include "gps_track_aggregation.h" #include "snap_points_to_features.h" #include "snap_points_to_grid.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CPoints_From_Table ); case 1: return( new CCountPoints ); case 2: return( new CCreatePointGrid ); case 3: return( new CDistanceMatrix ); case 4: return( new CFitNPointsToShape ); case 5: return( new CPoints_From_Lines ); case 6: return( new CAddCoordinates ); case 7: return( new CRemove_Duplicates ); case 8: return( new CClip_Points ); case 9: return( new CSeparate_by_Direction ); case 10: return( new CAdd_Polygon_Attributes ); case 11: return( new CPoints_Filter ); case 12: return( new CConvex_Hull ); case 13: return( new CSelect_Points ); case 14: return( new CPoints_Thinning ); case 15: return( new CPoints_From_MultiPoints ); case 16: return( new CThiessen_Polygons ); case 17: return( new CGPS_Track_Aggregation ); case 18: return( new CSnap_Points_to_Features(SHAPE_TYPE_Point) ); case 19: return( new CSnap_Points_to_Features(SHAPE_TYPE_Line) ); case 20: return( new CSnap_Points_to_Grid() ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/shapes/shapes_points/points_filter.cpp0000744000175000017500000002511512737416203025564 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: remove_duplicates.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_points // // // //-------------------------------------------------------// // // // points_filter.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "points_filter.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_Filter::CPoints_Filter(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Points Filter")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("") ); Parameters.Add_Shapes( NULL , "FILTER" , _TL("Filtered Points"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Radius"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL , "MINNUM" , _TL("Minimum Number of Points"), _TL("only points with given minimum number of points in search radius will be processed"), PARAMETER_TYPE_Int, 0, 0.0, true ); Parameters.Add_Value( NULL , "MAXNUM" , _TL("Maximum Number of Points"), _TL("Number of nearest points, which will be evaluated for filtering. Set to zero to investigate all points in search radius."), PARAMETER_TYPE_Int, 0, 0.0, true ); Parameters.Add_Value( NULL , "QUADRANTS" , _TL("Quadrants"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Filter Criterion"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("keep maxima (with tolerance)"), _TL("keep minima (with tolerance)"), _TL("remove maxima (with tolerance)"), _TL("remove minima (with tolerance)"), _TL("remove below percentile"), _TL("remove above percentile") ), 0 ); Parameters.Add_Value( NULL , "TOLERANCE" , _TL("Tolerance"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Value( NULL , "PERCENT" , _TL("Percentile"), _TL(""), PARAMETER_TYPE_Double, 50.0, 0.0, true, 100.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_Filter::On_Execute(void) { bool bQuadrants; int zField; CSG_Shapes *pPoints, *pFilter; //----------------------------------------------------- pPoints = Parameters("POINTS") ->asShapes(); pFilter = Parameters("FILTER") ->asShapes(); zField = Parameters("FIELD") ->asInt(); bQuadrants = Parameters("QUADRANTS") ->asBool(); m_Method = Parameters("METHOD") ->asInt(); m_nMinPoints = Parameters("MINNUM") ->asInt(); m_nMaxPoints = Parameters("MAXNUM") ->asInt(); m_Radius = Parameters("RADIUS") ->asDouble(); m_Tolerance = Parameters("TOLERANCE") ->asDouble(); m_Percentile = Parameters("PERCENT") ->asDouble(); //----------------------------------------------------- if( !pPoints->is_Valid() ) { Error_Set(_TL("invalid points layer")); return( false ); } if( pPoints->Get_Count() <= 0 ) { Error_Set(_TL("no points in layer")); return( false ); } if( !m_Search.Create(pPoints, zField) ) { Error_Set(_TL("failed to initialise search engine")); return( false ); } //----------------------------------------------------- if( pFilter ) { pFilter->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Filtered")), pPoints); } else { pPoints->Select(); } //----------------------------------------------------- int nFiltered = 0; for(int i=0; iGet_Count() && Set_Progress(i, pPoints->Get_Count()); i++) { CSG_Shape *pPoint = pPoints->Get_Shape(i); if( pPoint ) { bool bFilter = bQuadrants ? Do_Filter(pPoint->Get_Point(0), pPoint->asDouble(zField), 0) || Do_Filter(pPoint->Get_Point(0), pPoint->asDouble(zField), 1) || Do_Filter(pPoint->Get_Point(0), pPoint->asDouble(zField), 2) || Do_Filter(pPoint->Get_Point(0), pPoint->asDouble(zField), 3) : Do_Filter(pPoint->Get_Point(0), pPoint->asDouble(zField)); if( bFilter ) { nFiltered++; if( !pFilter ) { pPoints->Select(i, true); } } else if( pFilter ) { pFilter->Add_Shape(pPoint); } } } //----------------------------------------------------- if( !pFilter ) { pPoints->Del_Selection(); DataObject_Update(pPoints); } Message_Add(CSG_String::Format(SG_T("%d %s"), nFiltered, _TL("points have been filtered"))); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_Filter::Do_Filter(TSG_Point Point, double zPoint, int Quadrant) { if( !m_Search.Select_Nearest_Points(Point.x, Point.y, m_nMaxPoints, m_Radius, Quadrant) ) { return( false ); } if( m_Search.Get_Selected_Count() <= m_nMinPoints ) { return( true ); } switch( m_Method ) { //----------------------------------------------------- case 0: // keep maxima case 1: // keep minima case 2: // remove maxima case 3: // remove minima { for(int i=0; ihas_Statistics() ) { switch( m_Method ) { case 0: z = ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Maximum(); break; // keep maxima case 1: z = ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Minimum(); break; // keep minima case 2: z = ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Maximum(); break; // remove maxima case 3: z = ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Minimum(); break; // remove minima } } else { z = pLeaf->Get_Z(); } switch( m_Method ) { case 0: if( zPoint < (z - m_Tolerance) ) return( true ); break; // keep maxima case 1: if( zPoint > (z + m_Tolerance) ) return( true ); break; // keep minima case 2: if( zPoint < (z - m_Tolerance) ) return( false ); break; // remove maxima case 3: if( zPoint > (z + m_Tolerance) ) return( false ); break; // remove minima } } } return( m_Method <= 1 ? false : true ); } //----------------------------------------------------- case 4: // remove below percentile case 5: // remove above percentile { double n = 0.0; for(int i=0; ihas_Statistics() ) { for(int j=0; j<((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Count(); j++) { if( zPoint > ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Value(j) ) { n++; } } } else if( zPoint > pLeaf->Get_Z() ) { n++; } } } n *= 100.0 / m_Search.Get_Selected_Count(); return( m_Method == 4 ? n < m_Percentile : n > m_Percentile ); } } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_points/CreatePointGrid.h0000744000175000017500000000256112737416203025373 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* CreatePointGrid.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CCreatePointGrid : public CSG_Module { public: CCreatePointGrid(void); virtual ~CCreatePointGrid(void); virtual bool is_ProjectDependent(void) {return( false );} protected: virtual bool On_Execute(void); }; saga-2.3.1/src/modules/shapes/shapes_tools/0000775000175000017500000000000012737740006022021 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/shapes/shapes_tools/shapes_extents.h0000744000175000017500000001015612737416205025232 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Extents.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Extents_H #define HEADER_INCLUDED__Shapes_Extents_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Extents : public CSG_Module { public: CShapes_Extents(void); virtual ~CShapes_Extents(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Extents_H saga-2.3.1/src/modules/shapes/shapes_tools/Shapes_Create_Empty.h0000744000175000017500000001063212737416205026060 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Create_Empty.h // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Create_Empty_H #define HEADER_INCLUDED__Shapes_Create_Empty_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Create_Empty : public CSG_Module { public: CShapes_Create_Empty(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: void _Set_Field_Count (CSG_Parameters *pAttributes, int nAttributes); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Create_Empty_H saga-2.3.1/src/modules/shapes/shapes_tools/shapes_convert_vertex_type.h0000744000175000017500000001075212737416205027660 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_convert_vertex_type.h // // // // Copyright (C) 2013 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Convert_Vertex_Type_H #define HEADER_INCLUDED__Shapes_Convert_Vertex_Type_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Convert_Vertex_Type : public CSG_Module { public: CShapes_Convert_Vertex_Type(void); virtual ~CShapes_Convert_Vertex_Type(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Convert_Vertex_Type_H saga-2.3.1/src/modules/shapes/shapes_tools/SearchInTable.cpp0000744000175000017500000001402312737416205025171 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* SearchInTable.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SearchInTable.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelect_String::CSelect_String(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Select by Attributes... (String Expression)")); Set_Author (SG_T("V.Olaya (c) 2004, O.Conrad (c) 2011")); Set_Description (_TW( "Searches for an character string expression in the attributes table and selects records where the expression is found." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("attribute to be searched; if not set all attributes will be searched"), true ); Parameters.Add_String( NULL , "EXPRESSION" , _TL("Expression"), _TL(""), SG_T("") ); Parameters.Add_Value( NULL , "CASE" , _TL("Case Sensitive"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( NULL , "COMPARE" , _TL("Select if..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("attribute is identical with search expression"), _TL("attribute contains search expression"), _TL("attribute is contained in search expression") ), 1 ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("new selection"), _TL("add to current selection"), _TL("select from current selection"), _TL("remove from current selection") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_String::On_Execute(void) { int Method; CSG_Shapes *pShapes; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); m_Field = Parameters("FIELD") ->asInt(); m_Expression = Parameters("EXPRESSION") ->asString(); m_Case = Parameters("CASE") ->asBool(); m_Compare = Parameters("COMPARE") ->asInt(); Method = Parameters("METHOD") ->asInt(); //----------------------------------------------------- if( m_Case == false ) { m_Expression.Make_Upper(); } //----------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { CSG_Shape *pShape = pShapes->Get_Shape(i); switch( Method ) { case 0: // New selection if( ( pShape->is_Selected() && !Do_Select(pShape)) || (!pShape->is_Selected() && Do_Select(pShape)) ) { pShapes->Select(i, true); } break; case 1: // Add to current selection if( !pShape->is_Selected() && Do_Select(pShape) ) { pShapes->Select(i, true); } break; case 2: // Select from current selection if( pShape->is_Selected() && !Do_Select(pShape) ) { pShapes->Select(i, true); } break; case 3: // Remove from current selection if( pShape->is_Selected() && Do_Select(pShape) ) { pShapes->Select(i, true); } break; } } //----------------------------------------------------- Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("selected shapes"), pShapes->Get_Selection_Count())); DataObject_Update(pShapes); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CSelect_String::Do_Compare(const SG_Char *Value) { CSG_String s(Value); if( m_Case == false ) { s.Make_Upper(); } switch( m_Compare ) { case 0: // identical return( m_Expression.Cmp(s) == 0 ); case 1: // contains return( s.Find(m_Expression) >= 0 ); case 2: // contained return( m_Expression.Find(s) >= 0 ); } return( false ); } //--------------------------------------------------------- inline bool CSelect_String::Do_Select(CSG_Shape *pShape) { if( m_Field >= 0 && m_Field < pShape->Get_Table()->Get_Field_Count() ) { return( Do_Compare(pShape->asString(m_Field)) ); } for(int i=0; iGet_Table()->Get_Field_Count(); i++) { if( Do_Compare(pShape->asString(i)) ) { return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/LandUse_Scenario.h0000744000175000017500000001100512737416205025345 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: LandUse_Scenario.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics // // // //-------------------------------------------------------// // // // LandUse_Scenario.h // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__LandUse_Scenario_H #define HEADER_INCLUDED__LandUse_Scenario_H #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLandUse_Scenario : public CSG_Module { public: CLandUse_Scenario(void); protected: virtual bool On_Execute(void); private: bool Get_Known_LandUse (int nYears, CSG_Table &Scenario, const CSG_Table &Types); bool Get_Scenario (int nYears, CSG_Table &Scenario, const CSG_Matrix &Crops); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__LandUse_Scenario_H saga-2.3.1/src/modules/shapes/shapes_tools/shapes_generate.h0000744000175000017500000001123012737416205025324 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_generate.h // // // // Copyright (C) 2012 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Generate_H #define HEADER_INCLUDED__Shapes_Generate_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Generate : public CSG_Module { public: CShapes_Generate(void); virtual ~CShapes_Generate(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual bool On_Execute (void); private: bool Generate_Point_Shapes (CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY); bool Generate_Line_Shapes (CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY); bool Generate_Polygon_Shapes (CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Generate_H saga-2.3.1/src/modules/shapes/shapes_tools/shapes_split.cpp0000744000175000017500000001426612737416205025234 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Split.cpp // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_split.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Split::CShapes_Split(void) { Set_Name (_TL("Split Shapes Layer")); Set_Author (SG_T("(c) 2006 by O.Conrad")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes_List( NULL , "CUTS" , _TL("Tiles"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "NX" , _TL("Number of horizontal tiles"), _TL(""), PARAMETER_TYPE_Int, 2, 1, true ); Parameters.Add_Value( NULL , "NY" , _TL("Number of vertical tiles"), _TL(""), PARAMETER_TYPE_Int, 2, 1, true ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), Cut_Methods_Str(), 0 ); } //--------------------------------------------------------- CShapes_Split::~CShapes_Split(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Split::On_Execute(void) { int x, y, nx, ny, Method; CSG_Shapes *pShapes, *pCut, *pExtent; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); pExtent = Parameters("EXTENT") ->asShapes(); nx = Parameters("NX") ->asInt(); ny = Parameters("NY") ->asInt(); Method = Parameters("METHOD") ->asInt(); Parameters("CUTS")->asShapesList()->Del_Items(); //----------------------------------------------------- if( pShapes->is_Valid() ) { double dx, dy; TSG_Rect r; dx = pShapes->Get_Extent().Get_XRange() / nx; dy = pShapes->Get_Extent().Get_YRange() / ny; for(y=0; yGet_Extent().Get_YMin() + y * dy; r.yMax = r.yMin + dy; for(x=0; xGet_Extent().Get_XMin() + x * dx; r.xMax = r.xMin + dx; Cut_Set_Extent(r, pExtent, y == 0 && x == 0); Process_Set_Text(CSG_String::Format(SG_T("%d/%d"), y * nx + (x + 1), nx * ny)); if( (pCut = Cut_Shapes(r, Method, pShapes)) != NULL ) { pCut->Set_Name(CSG_String::Format(SG_T("%s [%d][%d]"), pShapes->Get_Name(), 1 + x, 1 + y)); Parameters("CUTS")->asShapesList()->Add_Item(pCut); } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/QueryBuilder.cpp0000744000175000017500000001213412737416205025142 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* QueryBuilder.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "QueryBuilder.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelect_Numeric::CSelect_Numeric(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Select by Attributes... (Numerical Expression)")); Set_Author (SG_T("V.Olaya (c) 2004, O.Conrad (c) 2011")); Set_Description (_TW( "Selects records for which the expression is true." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("attribute to be searched; if not set all attributes will be searched"), true ); Parameters.Add_String( NULL , "EXPRESSION" , _TL("Expression"), _TL(""), SG_T("a > 0") ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("new selection"), _TL("add to current selection"), _TL("select from current selection"), _TL("remove from current selection") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_Numeric::On_Execute(void) { int Method, Field; CSG_String Expression; CSG_Shapes *pShapes; CSG_Formula Formula; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); Field = Parameters("FIELD") ->asInt(); Expression = Parameters("EXPRESSION") ->asString(); Method = Parameters("METHOD") ->asInt(); //----------------------------------------------------- if( !Formula.Set_Formula(Expression) ) { CSG_String Message; if( Formula.Get_Error(Message) ) { Error_Set(Message); } return( false ); } //----------------------------------------------------- double *Values = new double[pShapes->Get_Field_Count()]; for(int i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { CSG_Shape *pShape = pShapes->Get_Shape(i); if( Field >= pShapes->Get_Field_Count() ) { for(int j=0; jGet_Field_Count(); j++) { Values[j] = pShape->asDouble(j); } } else { Values[0] = pShape->asDouble(Field); } switch( Method ) { case 0: // New selection if( ( pShape->is_Selected() && !Formula.Get_Value(Values, pShapes->Get_Field_Count())) || (!pShape->is_Selected() && Formula.Get_Value(Values, pShapes->Get_Field_Count())) ) { pShapes->Select(i, true); } break; case 1: // Add to current selection if( !pShape->is_Selected() && Formula.Get_Value(Values, pShapes->Get_Field_Count()) ) { pShapes->Select(i, true); } break; case 2: // Select from current selection if( pShape->is_Selected() && !Formula.Get_Value(Values, pShapes->Get_Field_Count()) ) { pShapes->Select(i, true); } break; case 3: // Remove from current selection if( pShape->is_Selected() && Formula.Get_Value(Values, pShapes->Get_Field_Count()) ) { pShapes->Select(i, true); } break; } } delete[](Values); //----------------------------------------------------- Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("selected shapes"), pShapes->Get_Selection_Count())); DataObject_Update(pShapes); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/SeparateShapes.cpp0000744000175000017500000000707612737416205025447 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* SeparateShapes.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SeparateShapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSeparateShapes::CSeparateShapes(void) { CSG_Parameter *pNode; Set_Name (_TL("Split Shapes Layer Completely")); Set_Author (SG_T("Victor Olaya (c) 2005")); Set_Description (_TW( "Copies each shape of given layer to a separate target layer." )); pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("") ); Parameters.Add_Shapes_List( NULL , "LIST" , _TL("Output"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "NAMING" , _TL("Name by..."), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("number of order"), _TL("attribute") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSeparateShapes::On_Execute(void) { int Naming, Field; CSG_Shapes *pShapes; CSG_Parameter_Shapes_List *pList; pShapes = Parameters("SHAPES") ->asShapes(); pList = Parameters("LIST") ->asShapesList(); Naming = Parameters("NAMING") ->asInt(); Field = Parameters("FIELD") ->asInt(); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_String Name; switch( Naming ) { case 0: default: Name.Printf(SG_T("%s [%04d]"), pShapes->Get_Name(), iShape + 1); break; case 1: Name.Printf(SG_T("%s [%s]") , pShapes->Get_Name(), pShapes->Get_Record(iShape)->asString(Field)); break; } CSG_Shapes *pShape = SG_Create_Shapes(pShapes->Get_Type(), Name, pShapes); pList ->Add_Item(pShape); pShape ->Add_Shape(pShapes->Get_Shape(iShape)); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/Shapes_Merge.cpp0000744000175000017500000002034712737416205025075 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* Shapes_Merge.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Shapes_Merge.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Merge::CShapes_Merge(void) : CTables_Merge() { Parameters.Del_Parameters(); Set_Name (_TL("Merge Layers")); Set_Author ("V.Olaya (c) 2004"); Set_Description (_TW( "Merge vector layers." )); Parameters.Add_Shapes_List( NULL , "INPUT" , _TL("Layers"), _TL("Output will inherit shape type and table structure from the first layer in this list."), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "MERGED" , _TL("Merged Layer"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "SRCINFO" , _TL("Add Source Information"), _TL("Adds a field with the name of the original input data set."), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "MATCH" , _TL("Match Fields by Name"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTables_Merge::CTables_Merge(void) { Set_Name (_TL("Merge Tables")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "Merge tables." )); Parameters.Add_Table_List( NULL , "INPUT" , _TL("Tables"), _TL("The resulting table inherits its field structure from the first table in this list."), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "MERGED" , _TL("Merged Table"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "SRCINFO" , _TL("Add Source Information"), _TL("Adds a field with the name of the original input data set."), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "MATCH" , _TL("Match Fields by Name"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTables_Merge::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_List *pList = Parameters("INPUT")->asList(); if( pList->Get_Type() == PARAMETER_TYPE_Shapes_List ) { int n = pList->Get_Count(); for(int i=n-1; i>0; i--) { if( ((CSG_Shapes *)pList->asDataObject(0))->Get_Type() != ((CSG_Shapes *)pList->asDataObject(i))->Get_Type() ) { pList->Del_Item(i); } } if( n > pList->Get_Count() ) { Message_Add(CSG_String::Format(SG_T("%s [%d]"), _TL("incompatible items have been removed from input list"), n - pList->Get_Count())); } } if( pList->Get_Count() < 2 ) { Error_Set(_TL("Nothing to do! Merging needs more than one input data set.")); return( false ); } //----------------------------------------------------- CSG_Table *pMerged = Parameters("MERGED")->asTable(); if( pList->Get_Type() == PARAMETER_TYPE_Shapes_List ) { CSG_Shapes *pShapesIn = ((CSG_Shapes *)pList->asDataObject(0)); ((CSG_Shapes *)pMerged)->Create(pShapesIn->Get_Type(), pShapesIn->Get_Name(), pShapesIn, pShapesIn->Get_Vertex_Type()); CSG_Shapes *pShapesOut = ((CSG_Shapes *)pMerged); for(int i=0; iGet_Count(); i++) { CSG_Shape *pShape = pShapesIn->Get_Shape(i); pShapesOut->Add_Shape(pShape); if( pShapesIn->Get_Vertex_Type() > SG_VERTEX_TYPE_XY ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pShapesOut->Get_Shape(i)->Set_Z(pShape->Get_Z(iPoint, iPart), iPoint, iPart); if( pShapesIn->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShapesOut->Get_Shape(i)->Set_M(pShape->Get_M(iPoint, iPart), iPoint, iPart); } } } } } } else // if( pList->Get_Type() == PARAMETER_TYPE_Table_List ) { pMerged->Create(*((CSG_Table *)pList->asDataObject(0))); } pMerged->Set_Name(_TL("Merged Layers")); //----------------------------------------------------- bool bInfo = Parameters("SRCINFO")->asBool(); if( bInfo ) { pMerged->Add_Field(_TL("Source"), SG_DATATYPE_String, 0); for(int i=0; iGet_Count(); i++) { pMerged->Set_Value(i, 0, pList->asDataObject(0)->Get_Name()); } } int *Index = NULL; //----------------------------------------------------- for(int iTable=1; iTableGet_Count() && Process_Get_Okay(); iTable++) { CSG_Table *pTable = (CSG_Table *)pList->asDataObject(iTable); //------------------------------------------------- if( Parameters("MATCH")->asBool() ) // see which fields are in both attributes tables { Index = (int *)SG_Realloc(Index, pTable->Get_Field_Count() * sizeof(int)); for(int i=0; iGet_Field_Count(); i++) { CSG_String Name(pTable->Get_Field_Name(i)); Index[i] = -1; for(int j=bInfo?1:0; Index[i]<0 && jGet_Field_Count(); j++) { if( !Name.CmpNoCase(pMerged->Get_Field_Name(j)) ) { Index[i] = j; } } } } //------------------------------------------------- for(int iRecord=0; iRecordGet_Count(); iRecord++) { CSG_Table_Record *pOutput, *pInput = pTable->Get_Record(iRecord); if( pMerged->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ) { CSG_Shape *pShapeOut; pOutput = pShapeOut = ((CSG_Shapes *)pMerged)->Add_Shape(pInput, SHAPE_COPY_GEOM); if( pMerged->asShapes()->Get_Vertex_Type() > SG_VERTEX_TYPE_XY ) { CSG_Shape *pShapeIn = pTable->asShapes()->Get_Shape(iRecord); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pShapeOut->Set_Z(pShapeIn->Get_Z(iPoint, iPart), iPoint, iPart); if( pMerged->asShapes()->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShapeOut->Set_M(pShapeIn->Get_M(iPoint, iPart), iPoint, iPart); } } } } } else // if( pMerged->Get_ObjectType() == DATAOBJECT_TYPE_Table ) { pOutput = pMerged->Add_Record(); } if( bInfo ) { pOutput->Set_Value(0, pTable->Get_Name()); } if( Index ) { for(int i=0; iGet_Field_Count(); i++) { if( Index[i] >= 0 ) { *pOutput->Get_Value(Index[i]) = *pInput->Get_Value(i); } } } else // if( !Index ) { for(int i=0, j=bInfo?1:0; iGet_Field_Count() && jGet_Field_Count(); i++, j++) { *pOutput->Get_Value(j) = *pInput->Get_Value(i); } } } } //----------------------------------------------------- SG_FREE_SAFE(Index); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/shapes_cut.h0000744000175000017500000001175312737416205024337 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Cut.h // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Cut_H #define HEADER_INCLUDED__Shapes_Cut_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shapes * Cut_Shapes (CSG_Shapes *pPolygons, int Method, CSG_Shapes *pShapes , double Overlap = 0.0); bool Cut_Shapes (CSG_Shapes *pPolygons, int Method, CSG_Shapes *pShapes, CSG_Shapes *pCut, double Overlap = 0.0); CSG_Shapes * Cut_Shapes (CSG_Rect Extent , int Method, CSG_Shapes *pShapes); bool Cut_Shapes (CSG_Rect Extent , int Method, CSG_Shapes *pShapes, CSG_Shapes *pCut); CSG_String Cut_Methods_Str (void); bool Cut_Set_Extent (CSG_Rect Extent, CSG_Shapes *pExtent, bool bClear); /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Cut : public CSG_Module { public: CShapes_Cut(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Cut_H saga-2.3.1/src/modules/shapes/shapes_tools/shapes_polar_to_cartes.cpp0000744000175000017500000001613112737416205027252 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_polar_to_cartes.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_polar_to_cartes.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_polar_to_cartes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Polar_to_Cartes::CShapes_Polar_to_Cartes(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Polar to Cartesian Coordinates")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- // 2. Parameters... pNode = Parameters.Add_Shapes( NULL , "POLAR" , _TL("Polar Coordinates"), _TL(""), PARAMETER_INPUT ); pNode = Parameters.Add_Table_Field( pNode , "F_EXAGG" , _TL("Exaggeration"), _TL(""), true ); Parameters.Add_Value( pNode , "D_EXAGG" , _TL("Exaggeration Factor"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Shapes( NULL , "CARTES" , _TL("Cartesion Coordinates"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "RADIUS" , _TL("Radius"), _TL(""), PARAMETER_TYPE_Double, 6371000.0, 0.0, true ); Parameters.Add_Value( NULL , "DEGREE" , _TL("Degree"), _TL("polar coordinates given in degree"), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Polar_to_Cartes::On_Execute(void) { bool bDegree; int fExagg; double Radius, dExagg, Exagg = 0.0; CSG_Shapes *pPolar, *pCartes; //----------------------------------------------------- pPolar = Parameters("POLAR") ->asShapes(); pCartes = Parameters("CARTES") ->asShapes(); Radius = Parameters("RADIUS") ->asDouble(); bDegree = Parameters("DEGREE") ->asBool(); fExagg = Parameters("F_EXAGG") ->asInt(); dExagg = Parameters("D_EXAGG") ->asDouble(); //----------------------------------------------------- if( !pPolar->is_Valid() ) { Error_Set(_TL("invalid input")); return( false ); } //----------------------------------------------------- pCartes->Create(pPolar->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pPolar->Get_Name(), _TL("cartesian")), pPolar, SG_VERTEX_TYPE_XYZ); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pPolar->Get_Count()); iShape++) { CSG_Shape *pShape = pPolar->Get_Shape(iShape); CSG_Shape *pTarget = pCartes->Add_Shape(pShape, SHAPE_COPY_ATTR); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point_Z Point = Get_Cartes(pShape->Get_Point(iPoint, iPart), fExagg < 0 ? Radius : Radius + dExagg * pShape->asDouble(fExagg), bDegree); pTarget->Add_Point(Point.x, Point.y, iPart); pTarget->Set_Z (Point.z, iPoint , iPart); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline TSG_Point_Z CShapes_Polar_to_Cartes::Get_Cartes(TSG_Point Point, double Radius, bool bDegree) { if( bDegree ) { Point.x *= M_DEG_TO_RAD; Point.y *= M_DEG_TO_RAD; } TSG_Point_Z p; p.z = Radius * sin(Point.y); Radius = Radius * cos(Point.y); p.x = Radius * cos(Point.x); p.y = Radius * sin(Point.x); return( p ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/GraticuleBuilder.cpp0000744000175000017500000002124112737416205025753 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* GraticuleBuilder.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "GraticuleBuilder.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGraticuleBuilder::CGraticuleBuilder(void) { Set_Name (_TL("Create Graticule")); Set_Author ("V.Olaya (c) 2004"); Set_Description (_TW( "(c) 2004 by Victor Olaya. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "GRATICULE_LINE" , _TL("Graticule"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "GRATICULE_RECT" , _TL("Graticule"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Type"), _TL(""), CSG_String::Format("%s|%s|", _TL("Lines"), _TL("Rectangles") ), 0 ); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Range( NULL , "EXTENT_X" , _TL("Width"), _TL(""), -180.0, 180.0 ); Parameters.Add_Range( NULL , "EXTENT_Y" , _TL("Height"), _TL(""), -90.0, 90.0 ); Parameters.Add_Value( NULL , "DIVISION_X" , _TL("Division Width"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Value( NULL , "DIVISION_Y" , _TL("Division Height"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Choice( NULL , "ALIGNMENT" , _TL("Alignment"), _TL("Determines how the graticule is aligned to the extent, if division sizes do not fit."), CSG_String::Format("%s|%s|%s|%s|%s|", _TL("bottom-left"), _TL("top-left"), _TL("bottom-right"), _TL("top-right"), _TL("centered") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGraticuleBuilder::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( CSG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CGraticuleBuilder::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TYPE") ) { pParameters->Set_Enabled("GRATICULE_LINE", pParameter->asInt() == 0); pParameters->Set_Enabled("GRATICULE_RECT", pParameter->asInt() != 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "EXTENT") ) { pParameters->Set_Enabled("EXTENT_X", pParameter->asShapes() == NULL); pParameters->Set_Enabled("EXTENT_Y", pParameter->asShapes() == NULL); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGraticuleBuilder::On_Execute(void) { //----------------------------------------------------- TSG_Rect Extent; if( Parameters("EXTENT")->asShapes() ) { Extent = Parameters("EXTENT")->asShapes()->Get_Extent(); } else { Extent.xMin = Parameters("EXTENT_X")->asRange()->Get_LoVal(); Extent.yMin = Parameters("EXTENT_Y")->asRange()->Get_LoVal(); Extent.xMax = Parameters("EXTENT_X")->asRange()->Get_HiVal(); Extent.yMax = Parameters("EXTENT_Y")->asRange()->Get_HiVal(); } if( Extent.xMin >= Extent.xMax || Extent.yMin >= Extent.yMax ) { Error_Set(_TL("invalid extent")); return( false ); } //----------------------------------------------------- double dx = Parameters("DIVISION_X")->asDouble(); double dy = Parameters("DIVISION_Y")->asDouble(); if( dx <= 0.0 || dy <= 0.0 ) { Error_Set(_TL("invalid division size")); return( false ); } //----------------------------------------------------- int nx = (int)ceil((Extent.xMax - Extent.xMin) / dx); int ny = (int)ceil((Extent.yMax - Extent.yMin) / dy); switch( Parameters("ALIGNMENT")->asInt() ) { default: // bottom-left // Extent.xMax = Extent.xMin + nx * dx; // Extent.yMax = Extent.yMin + ny * dy; break; case 1: // top-left // Extent.xMax = Extent.xMin + nx * dx; Extent.yMin = Extent.yMax - ny * dy; break; case 2: // bottom-right Extent.xMin = Extent.xMax - nx * dx; // Extent.yMax = Extent.yMin + ny * dy; break; case 3: // top-right Extent.xMin = Extent.xMax - nx * dx; Extent.yMin = Extent.yMax - ny * dy; break; case 4: // centered { double cx = Extent.xMin + (Extent.xMax - Extent.xMin) / 2.0; double cy = Extent.yMin + (Extent.yMax - Extent.yMin) / 2.0; Extent.xMin = cx - nx * dx / 2.0; Extent.yMin = cy - ny * dy / 2.0; // Extent.xMax = cx + nx * dx / 2.0; // Extent.yMax = cy + ny * dy / 2.0; } break; } //----------------------------------------------------- CSG_Shapes *pGraticule = Parameters("TYPE")->asInt() == 0 ? Parameters("GRATICULE_LINE")->asShapes() : Parameters("GRATICULE_RECT")->asShapes(); int x, y; TSG_Point p; switch( Parameters("TYPE")->asInt() ) { //----------------------------------------------------- case 0: // Lines { pGraticule->Create(SHAPE_TYPE_Line, _TL("Graticule")); pGraticule->Add_Field("ID", SG_DATATYPE_Int); for(x=0, p.x=Extent.xMin; x<=nx; x++, p.x+=dx) { CSG_Shape *pLine = pGraticule->Add_Shape(); pLine->Set_Value(0, pGraticule->Get_Count()); for(y=0, p.y=Extent.yMin; y<=ny; y++, p.y+=dy) { pLine->Add_Point(p.x, p.y); } } for(y=0, p.y=Extent.yMin; y<=ny; y++, p.y+=dy) { CSG_Shape *pLine = pGraticule->Add_Shape(); pLine->Set_Value(0, pGraticule->Get_Count()); for(x=0, p.x=Extent.xMin; x<=nx; x++, p.x+=dx) { pLine->Add_Point(p.x, p.y); } } } break; //----------------------------------------------------- case 1: // Rectangles { pGraticule->Create(SHAPE_TYPE_Polygon, _TL("Graticule")); pGraticule->Add_Field("ID" , SG_DATATYPE_Int); pGraticule->Add_Field("ROW", SG_DATATYPE_Int); pGraticule->Add_Field("COL", SG_DATATYPE_Int); for(y=0, p.y=Extent.yMin; yAdd_Shape(); pRect->Set_Value(0, pGraticule->Get_Count()); pRect->Set_Value(1, 1 + y); pRect->Set_Value(2, 1 + x); pRect->Add_Point(p.x , p.y ); pRect->Add_Point(p.x , p.y + dy); pRect->Add_Point(p.x + dx, p.y + dy); pRect->Add_Point(p.x + dx, p.y ); pRect->Add_Point(p.x , p.y ); } } } break; //----------------------------------------------------- } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/SelectByTheme.cpp0000744000175000017500000001532312737416205025226 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* SelectByTheme.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "SelectByTheme.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelect_Location::CSelect_Location(void) { //----------------------------------------------------- Set_Name (_TL("Select by Location...")); Set_Author (SG_T("V.Olaya (c) 2004, O.Conrad (c) 2011")); Set_Description (_TW( "Select by location." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes to Select From"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "LOCATIONS" , _TL("Locations"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Choice( NULL , "CONDITION" , _TL("Condition"), _TL("Select shapes that fulfil this condition"), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("intersect"), _TL("are completely within"), _TL("completely contain"), _TL("have their centroid in"), _TL("contain the centeroid of") ), 0 ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("new selection"), _TL("add to current selection"), _TL("select from current selection"), _TL("remove from current selection") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_Location::On_Execute(void) { int Method, Condition; m_pShapes = Parameters("SHAPES") ->asShapes(); m_pLocations = Parameters("LOCATIONS") ->asShapes(); Condition = Parameters("CONDITION") ->asInt(); Method = Parameters("METHOD") ->asInt(); //----------------------------------------------------- switch( Condition ) { case 0: // intersect if( ((m_pShapes ->Get_Type() == SHAPE_TYPE_Point || m_pShapes ->Get_Type() == SHAPE_TYPE_Points) && m_pLocations->Get_Type() != SHAPE_TYPE_Polygon) || ((m_pLocations->Get_Type() == SHAPE_TYPE_Point || m_pLocations->Get_Type() == SHAPE_TYPE_Points) && m_pShapes ->Get_Type() != SHAPE_TYPE_Polygon) ) { Error_Set(_TL("points can only intersect with polygons")); return( false ); } break; case 1: // are completely within case 3: // have their centroid in if( m_pLocations->Get_Type() != SHAPE_TYPE_Polygon ) { Error_Set(_TL("this operation requires locations to be of type polygon")); return( false ); } break; case 2: // completely contain case 4: // contain the centroid of if( m_pShapes->Get_Type() != SHAPE_TYPE_Polygon ) { Error_Set(_TL("this operation requires selectable shapes to be of type polygon")); return( false ); } break; } //----------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, m_pShapes->Get_Count()); i++) { CSG_Shape *pShape = m_pShapes->Get_Shape(i); switch( Method ) { case 0: // New selection if( ( pShape->is_Selected() && !Do_Select(pShape, Condition)) || (!pShape->is_Selected() && Do_Select(pShape, Condition)) ) { m_pShapes->Select(i, true); } break; case 1: // Add to current selection if( !pShape->is_Selected() && Do_Select(pShape, Condition) ) { m_pShapes->Select(i, true); } break; case 2: // Select from current selection if( pShape->is_Selected() && !Do_Select(pShape, Condition) ) { m_pShapes->Select(i, true); } break; case 3: // Remove from current selection if( pShape->is_Selected() && Do_Select(pShape, Condition) ) { m_pShapes->Select(i, true); } break; } } //----------------------------------------------------- Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("selected shapes"), m_pShapes->Get_Selection_Count())); DataObject_Update(m_pShapes); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSelect_Location::Do_Select(CSG_Shape *pShape, int Condition) { for(int i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Shape *pLocation = m_pLocations->Get_Shape(i); if( pShape->Intersects(pLocation->Get_Extent()) ) { switch( Condition ) { case 0: // intersect if( pLocation->Intersects(pShape) ) { return( true ); } break; case 1: // are completely within if( pLocation->Intersects(pShape) == INTERSECTION_Contains ) { return( true ); } break; case 2: // completely contain if( pShape->Intersects(pLocation) == INTERSECTION_Contains ) { return( true ); } break; case 3: // have their centroid in if( ((CSG_Shape_Polygon *)pLocation)->Contains(pShape->Get_Centroid()) ) { return( true ); } break; case 4: // contain the centroid of if( ((CSG_Shape_Polygon *)pShape)->Contains(pLocation->Get_Centroid()) ) { return( true ); } break; } } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/shapes_split_by_attribute.h0000744000175000017500000001022312737416205027443 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_split_by_attribute.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__shapes_split_by_attribute_H #define HEADER_INCLUDED__shapes_split_by_attribute_H //--------------------------------------------------------- #include "shapes_cut.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Split_by_Attribute : public CSG_Module { public: CShapes_Split_by_Attribute(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_split_by_attribute_H saga-2.3.1/src/modules/shapes/shapes_tools/shapes_split_by_attribute.cpp0000744000175000017500000001341012737416205027777 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_split_by_attribute.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_split_by_attribute.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Split_by_Attribute::CShapes_Split_by_Attribute(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Split Table/Shapes by Attribute")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table / Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL(""), false ); Parameters.Add_Table_List( NULL , "CUTS" , _TL("Cuts"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Split_by_Attribute::On_Execute(void) { int iField; CSG_Table *pTable; //----------------------------------------------------- pTable = Parameters("TABLE") ->asTable(); iField = Parameters("FIELD") ->asInt(); Parameters("CUTS")->asTableList()->Del_Items(); //----------------------------------------------------- if( pTable->is_Valid() && pTable->Set_Index(iField, TABLE_INDEX_Ascending) ) { CSG_String sValue; CSG_Table *pCut = NULL; for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record_byIndex(iRecord); if( !pCut || sValue.Cmp(pRecord->asString(iField)) ) { pCut = pTable->Get_ObjectType() == DATAOBJECT_TYPE_Shapes ? SG_Create_Shapes(((CSG_Shapes *)pTable)->Get_Type(), SG_T(""), pTable) : SG_Create_Table(pTable); pCut->Set_Name(CSG_String::Format(SG_T("%s [%s = %s]"), pTable->Get_Name(), pTable->Get_Field_Name(iField), pRecord->asString(iField) )); Parameters("CUTS")->asTableList()->Add_Item(pCut); sValue = pRecord->asString(iField); } pCut->Add_Record(pRecord); } return( pCut != NULL ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/TransformShapes.h0000744000175000017500000000262512737416205025316 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* TransformShapes.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CTransformShapes : public CSG_Module{ public: CTransformShapes(void); virtual ~CTransformShapes(void); protected: virtual bool On_Execute(void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: }; saga-2.3.1/src/modules/shapes/shapes_tools/quadtree_structure.h0000744000175000017500000001073412737416205026131 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // quadtree_structure.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. // // // // This library is free software; you can redistribute // // it and/or modify it under the terms of the GNU Lesser // // General Public License as published by the Free // // Software Foundation, version 2.1 of the License. // // // // This library is distributed in the hope that it will // // be useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU Lesser General Public // // License for more details. // // // // You should have received a copy of the GNU Lesser // // General Public License along with this program; if // // not, write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__quadtree_structure_H #define HEADER_INCLUDED__quadtree_structure_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CQuadTree_Structure : public CSG_Module { public: CQuadTree_Structure(void); protected: virtual bool On_Execute (void); private: bool Get_Shapes (CSG_Shapes *pShapes, CSG_PRQuadTree_Item *pItem); void Get_Shapes (CSG_Shapes *pShapes, CSG_PRQuadTree_Item *pItem, int Level); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__quadtree_structure_H saga-2.3.1/src/modules/shapes/shapes_tools/shapes_cut_interactive.h0000744000175000017500000001130112737416205026721 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Cut_Interactive.h // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Cut_Interactive_H #define HEADER_INCLUDED__Shapes_Cut_Interactive_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_cut.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Cut_Interactive : public CSG_Module_Interactive { public: CShapes_Cut_Interactive(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: bool m_bDown, m_bConfirm; int m_Method; CSG_Point m_pDown; CSG_Shapes *m_pShapes, *m_pCut, *m_pExtent; bool Get_Extent (CSG_Rect &Extent); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Cut_Interactive_H saga-2.3.1/src/modules/shapes/shapes_tools/SelectByTheme.h0000744000175000017500000000416112737416205024671 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* SelectByTheme.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelect_Location : public CSG_Module { public: CSelect_Location(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); private: CSG_Shapes *m_pShapes, *m_pLocations; bool Do_Select (CSG_Shape *pShape, int Condition); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/Makefile.in0000664000175000017500000006333712737447617024116 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/shapes/shapes_tools ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_tools_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_tools_la_OBJECTS = CreateChartLayer.lo \ GraticuleBuilder.lo LandUse_Scenario.lo MLB_Interface.lo \ NewLayerFromSelectedShapes.lo quadtree_structure.lo \ QueryBuilder.lo SearchInTable.lo SelectByTheme.lo \ SeparateShapes.lo Shapes_Create_Empty.lo Shapes_Merge.lo \ TransformShapes.lo shapes_buffer.lo \ shapes_convert_vertex_type.lo shapes_cut.lo \ shapes_cut_interactive.lo shapes_extents.lo shapes_generate.lo \ shapes_polar_to_cartes.lo shapes_split.lo \ shapes_split_by_attribute.lo shapes_split_randomly.lo libshapes_tools_la_OBJECTS = $(am_libshapes_tools_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_tools_la_SOURCES) DIST_SOURCES = $(libshapes_tools_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id$ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_tools.la libshapes_tools_la_SOURCES = \ CreateChartLayer.cpp\ GraticuleBuilder.cpp\ LandUse_Scenario.cpp\ MLB_Interface.cpp\ NewLayerFromSelectedShapes.cpp\ quadtree_structure.cpp\ QueryBuilder.cpp\ SearchInTable.cpp\ SelectByTheme.cpp\ SeparateShapes.cpp\ Shapes_Create_Empty.cpp\ Shapes_Merge.cpp\ TransformShapes.cpp\ shapes_buffer.cpp\ shapes_convert_vertex_type.cpp\ shapes_cut.cpp\ shapes_cut_interactive.cpp\ shapes_extents.cpp\ shapes_generate.cpp\ shapes_polar_to_cartes.cpp\ shapes_split.cpp\ shapes_split_by_attribute.cpp\ shapes_split_randomly.cpp\ CreateChartLayer.h\ GraticuleBuilder.h\ LandUse_Scenario.h\ MLB_Interface.h\ NewLayerFromSelectedShapes.h\ quadtree_structure.h\ QueryBuilder.h\ SearchInTable.h\ SelectByTheme.h\ SeparateShapes.h\ Shapes_Create_Empty.h\ Shapes_Merge.h\ TransformShapes.h\ shapes_buffer.h\ shapes_convert_vertex_type.h\ shapes_cut.h\ shapes_cut_interactive.h\ shapes_extents.h\ shapes_generate.h\ shapes_polar_to_cartes.h\ shapes_split.h\ shapes_split_by_attribute.h\ shapes_split_randomly.h libshapes_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/shapes/shapes_tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_tools/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_tools.la: $(libshapes_tools_la_OBJECTS) $(libshapes_tools_la_DEPENDENCIES) $(EXTRA_libshapes_tools_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_tools_la_OBJECTS) $(libshapes_tools_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CreateChartLayer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GraticuleBuilder.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LandUse_Scenario.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NewLayerFromSelectedShapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/QueryBuilder.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SearchInTable.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SelectByTheme.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SeparateShapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Shapes_Create_Empty.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Shapes_Merge.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TransformShapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/quadtree_structure.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_buffer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_convert_vertex_type.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_cut.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_cut_interactive.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_extents.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_generate.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_polar_to_cartes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_split.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_split_by_attribute.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shapes_split_randomly.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile #install-exec-hook: # pushd .; cd $(pkglibdir); ln -s libshapes_tools.so shapes_tools.so; popd # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/shapes/shapes_tools/shapes_polar_to_cartes.h0000744000175000017500000001074212737416205026721 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: shapes_polar_to_cartes.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_polar_to_cartes.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__shapes_polar_to_cartes__H #define HEADER_INCLUDED__shapes_polar_to_cartes__H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Polar_to_Cartes : public CSG_Module { public: CShapes_Polar_to_Cartes(void); protected: virtual bool On_Execute (void); private: TSG_Point_Z Get_Cartes (TSG_Point Point, double Radius, bool bDegree); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_polar_to_cartes__H saga-2.3.1/src/modules/shapes/shapes_tools/shapes_extents.cpp0000744000175000017500000001565312737416205025574 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Extents.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_extents.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Extents::CShapes_Extents(void) { //----------------------------------------------------- Set_Name (_TL("Get Shapes Extents")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "EXTENTS" , _TL("Extents"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Get Extent for ..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("all shapes"), _TL("each shape"), _TL("each shape's part") ), 1 ); } //--------------------------------------------------------- CShapes_Extents::~CShapes_Extents(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Extents::On_Execute(void) { CSG_Shapes *pShapes = Parameters("SHAPES" )->asShapes(); CSG_Shapes *pExtents = Parameters("EXTENTS")->asShapes(); //----------------------------------------------------- if( !pShapes->is_Valid() ) { Message_Add(_TL("invalid input")); return( false ); } //----------------------------------------------------- int iOutput = Parameters("OUTPUT")->asInt(); if( iOutput == 0 ) // all shapes { pExtents->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Extent"))); pExtents->Add_Field(SG_T("OID"), SG_DATATYPE_Int); TSG_Rect r = pShapes->Get_Extent(); CSG_Shape *pExtent = pExtents->Add_Shape(); pExtent->Set_Value(0, 1); pExtent->Add_Point(r.xMin, r.yMin); pExtent->Add_Point(r.xMin, r.yMax); pExtent->Add_Point(r.xMax, r.yMax); pExtent->Add_Point(r.xMax, r.yMin); return( true ); } //----------------------------------------------------- if( pShapes->Get_Type() == SHAPE_TYPE_Point ) { Message_Add(_TL("no 'get extents' support for single point layers")); return( false ); } //----------------------------------------------------- pExtents->Create(SHAPE_TYPE_Polygon, pShapes->Get_Name(), pShapes); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); if( iOutput == 1 ) // each shape { TSG_Rect r = pShape->Get_Extent(); CSG_Shape *pExtent = pExtents->Add_Shape(pShape, SHAPE_COPY_ATTR); pExtent->Add_Point(r.xMin, r.yMin); pExtent->Add_Point(r.xMin, r.yMax); pExtent->Add_Point(r.xMax, r.yMax); pExtent->Add_Point(r.xMax, r.yMin); } else // if( iOutput == 2 ) // each shape's part { for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Rect r = pShape->Get_Extent(iPart); CSG_Shape *pExtent = pExtents->Add_Shape(pShape, SHAPE_COPY_ATTR); pExtent->Add_Point(r.xMin, r.yMin); pExtent->Add_Point(r.xMin, r.yMax); pExtent->Add_Point(r.xMax, r.yMax); pExtent->Add_Point(r.xMax, r.yMin); } } } //----------------------------------------------------- return( pExtents->is_Valid() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/shapes_split_randomly.cpp0000744000175000017500000001764212737416205027142 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Split_Randomly.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_split_randomly.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Split_Randomly::CShapes_Split_Randomly(void) { Set_Name (_TL("Split Shapes Layer Randomly")); Set_Author ("O.Conrad (c) 2008"); Set_Description (_TW( "Randomly splits one layer into to two new layers. " "Useful to create a control group for model testing. " "Optionally this can be done category-wise if a category " "field is specified. " )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Categories"), _TL(""), true ); Parameters.Add_Shapes( NULL , "A" , _TL("Group A"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "B" , _TL("Group B"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "PERCENT" , _TL("Relation B / A"), _TL(""), PARAMETER_TYPE_Double, 25.0, 0.0, true, 100.0, true ); Parameters.Add_Value( NULL , "EXACT" , _TL("Exact"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Split_Randomly::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pSplit[2], *pShapes = Parameters("SHAPES")->asShapes(); if( !pShapes->is_Valid() ) { Error_Set("invalid input"); return( false ); } //----------------------------------------------------- double Percent = Parameters("PERCENT")->asDouble(); pSplit[0] = Parameters("A")->asShapes(); pSplit[1] = Parameters("B")->asShapes(); pSplit[0]->Create(pShapes->Get_Type(), CSG_String::Format("%s [%d%%]", pShapes->Get_Name(), (int)(100.5 - Percent)), pShapes); pSplit[1]->Create(pShapes->Get_Type(), CSG_String::Format("%s [%d%%]", pShapes->Get_Name(), (int)( 0.5 + Percent)), pShapes); CSG_Random::Initialize(); // initialize with current time //----------------------------------------------------- int Field = Parameters("FIELD")->asInt(); if( Field < 0 ) { Split(pShapes, pSplit, Percent); } else // stratified { CSG_String Category; CSG_Shapes Shapes(pShapes->Get_Type(), pShapes->Get_Name(), pShapes); pShapes->Set_Index(Field, TABLE_INDEX_Ascending); for(int i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { CSG_Shape *pShape = pShapes->Get_Shape_byIndex(i); if( Shapes.Get_Count() == 0 ) { Category = pShape->asString(Field); } else if( Category.Cmp(pShape->asString(Field)) ) // category changed { Category = pShape->asString(Field); Split(&Shapes, pSplit, Percent); Shapes.Del_Shapes(); } Shapes.Add_Shape(pShape); } Split(&Shapes, pSplit, Percent); // don't forget to split last category } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CShapes_Split_Randomly::Split(CSG_Shapes *pShapes, CSG_Shapes *pSplit[2], double Percent) { //----------------------------------------------------- if( !Parameters("EXACT")->asBool() ) { for(int i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { pSplit[Percent >= CSG_Random::Get_Uniform(0, 100) ? 1 : 0]->Add_Shape(pShapes->Get_Shape(i)); } } //----------------------------------------------------- else { int i, n = (int)(0.5 + pShapes->Get_Count() * Percent / 100.0); CSG_Table Random; Random.Add_Field("INDEX" , SG_DATATYPE_Int); Random.Add_Field("PERCENT", SG_DATATYPE_Double); for(i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { CSG_Table_Record *pRecord = Random.Add_Record(); pRecord->Set_Value(0, i); pRecord->Set_Value(1, CSG_Random::Get_Uniform(0, 100)); } Random.Set_Index(1, TABLE_INDEX_Ascending); //------------------------------------------------- for(i=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { pSplit[i < n ? 1 : 0]->Add_Shape(pShapes->Get_Shape(Random[i].asInt(0))); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/quadtree_structure.cpp0000744000175000017500000002163512737416205026466 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // quadtree_structure.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. // // // // This library is free software; you can redistribute // // it and/or modify it under the terms of the GNU Lesser // // General Public License as published by the Free // // Software Foundation, version 2.1 of the License. // // // // This library is distributed in the hope that it will // // be useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU Lesser General Public // // License for more details. // // // // You should have received a copy of the GNU Lesser // // General Public License along with this program; if // // not, write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "quadtree_structure.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CQuadTree_Structure::CQuadTree_Structure(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("QuadTree Structure to Shapes")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ATTRIBUTE" , _TL("Attribute"), _TL(""), true ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Duplicated Points"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); } //--------------------------------------------------------- bool CQuadTree_Structure::On_Execute(void) { CSG_PRQuadTree QT(Parameters("SHAPES")->asShapes(), Parameters("ATTRIBUTE")->asInt()); Get_Shapes(Parameters("POLYGONS")->asShapes(), (CSG_PRQuadTree_Item *)&QT.Get_Root()); Get_Shapes(Parameters("LINES") ->asShapes(), (CSG_PRQuadTree_Item *)&QT.Get_Root()); Get_Shapes(Parameters("POINTS") ->asShapes(), (CSG_PRQuadTree_Item *)&QT.Get_Root()); return( true ); } //--------------------------------------------------------- bool CQuadTree_Structure::Get_Shapes(CSG_Shapes *pShapes, CSG_PRQuadTree_Item *pItem) { CSG_Shape *pShape; if( pShapes && pItem ) { switch( pShapes->Get_Type() ) { default: return( false ); case SHAPE_TYPE_Point: pShapes->Create(SHAPE_TYPE_Point , CSG_String::Format(SG_T("%s [%s, %s]"), Parameters("SHAPES")->asShapes()->Get_Name(), _TL("QuadTree"), _TL("Duplicates"))); pShapes->Add_Field("COUNT", SG_DATATYPE_Int); pShapes->Add_Field("VALUE", SG_DATATYPE_String); break; case SHAPE_TYPE_Line: pShapes->Create(SHAPE_TYPE_Line , CSG_String::Format(SG_T("%s [%s, %s]"), Parameters("SHAPES")->asShapes()->Get_Name(), _TL("QuadTree"), _TL("Squares"))); pShapes->Add_Field("LEVEL", SG_DATATYPE_Int); pShape = pShapes->Add_Shape(); pShape->Set_Value(0, 0.0); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yMin()); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yMax()); pShape->Add_Point(pItem->Get_xMax(), pItem->Get_yMax()); pShape->Add_Point(pItem->Get_xMax(), pItem->Get_yMin()); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yMin()); break; case SHAPE_TYPE_Polygon: pShapes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s, %s]"), Parameters("SHAPES")->asShapes()->Get_Name(), _TL("QuadTree"), _TL("Leafs"))); pShapes->Add_Field("LEVEL", SG_DATATYPE_Int); pShapes->Add_Field("VALUE", SG_DATATYPE_Double); pShapes->Add_Field("COUNT", SG_DATATYPE_Int); break; } Get_Shapes(pShapes, pItem, 1); return( true ); } return( false ); } //--------------------------------------------------------- void CQuadTree_Structure::Get_Shapes(CSG_Shapes *pShapes, CSG_PRQuadTree_Item *pItem, int Level) { if( pItem ) { switch( pShapes->Get_Type() ) { //------------------------------------------------- case SHAPE_TYPE_Point: { if( pItem->is_Leaf() ) { CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Add_Point(pItem->asLeaf()->Get_Point()); if( pItem->has_Statistics() ) { CSG_PRQuadTree_Leaf_List *pList = (CSG_PRQuadTree_Leaf_List *)pItem; pShape->Set_Value(0, pList->Get_Count()); pShape->Set_Value(1, SG_Get_String(pList->Get_Value(0), -2).c_str()); for(int i=1; iGet_Count(); i++) { pShape->Set_Value(1, CSG_String::Format(SG_T("%s|%s"), pShape->asString(1), SG_Get_String(pList->Get_Value(i), -2).c_str() )); } } else { pShape->Set_Value(0, 1); pShape->Set_Value(1, SG_Get_String(pItem->asLeaf()->Get_Z(), -2).c_str()); } } } break; //------------------------------------------------- case SHAPE_TYPE_Line: { if( pItem->is_Node() ) { CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Set_Value(0, Level); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yCenter(), 0); pShape->Add_Point(pItem->Get_xMax(), pItem->Get_yCenter(), 0); pShape->Add_Point(pItem->Get_xCenter(), pItem->Get_yMin(), 1); pShape->Add_Point(pItem->Get_xCenter(), pItem->Get_yMax(), 1); } } break; //------------------------------------------------- case SHAPE_TYPE_Polygon: { if( pItem->is_Leaf() ) { CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Set_Value(0, Level + 1); pShape->Set_Value(1, pItem->asLeaf()->Get_Z()); pShape->Set_Value(2, pItem->has_Statistics() ? ((CSG_PRQuadTree_Leaf_List *)pItem)->Get_Count() : 1); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yMin()); pShape->Add_Point(pItem->Get_xMin(), pItem->Get_yMax()); pShape->Add_Point(pItem->Get_xMax(), pItem->Get_yMax()); pShape->Add_Point(pItem->Get_xMax(), pItem->Get_yMin()); } } break; } //------------------------------------------------- if( pItem->is_Node() ) { for(int i=0; i<4; i++) { Get_Shapes(pShapes, pItem->asNode()->Get_Child(i), Level + 1); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/NewLayerFromSelectedShapes.h0000744000175000017500000000552312737416205027366 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* NewLayerFromSelectedShapes.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelection_Copy : public CSG_Module { public: CSelection_Copy(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelection_Delete : public CSG_Module { public: CSelection_Delete(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelection_Invert : public CSG_Module { public: CSelection_Invert(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/TransformShapes.cpp0000744000175000017500000002030112737416205025640 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* TransformShapes.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ //--------------------------------------------------------- #include "TransformShapes.h" //--------------------------------------------------------- CTransformShapes::CTransformShapes(void) { Set_Name (_TL("Transform Shapes")); Set_Author (SG_T("(c) 2004 by Victor Olaya")); Set_Description (_TW( "(c) 2004 by Victor Olaya. Use this module to move, rotate and/or scale shapes." )); CSG_Parameter *pNode_0; //----------------------------------------------------- Parameters.Add_Shapes( NULL , "IN" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "MOVE" , _TL("Move"), _TL("") ); Parameters.Add_Value( pNode_0 , "DX" , _TL("dX"), _TL("dX (Map Units)"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0, "DY" , _TL("dY"), _TL("dY (Map Units)"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0, "DZ" , _TL("dZ"), _TL("dZ (Map Units)"), PARAMETER_TYPE_Double, 0.0 ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "ROTATE" , _TL("Rotate"), _TL("")); Parameters.Add_Value( pNode_0 , "ANGLE" , _TL("Angle"), _TL("Angle in degrees, counting clockwise from north"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0 , "ROTATEX" , _TL("Rotation X"), _TL("Angle in degrees, clockwise around x axis"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0 , "ROTATEY" , _TL("Rotation Y"), _TL("Angle in degrees, clockwise around y axis"), PARAMETER_TYPE_Double, 0.0 ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "SCALE" , _TL("Scale"), _TL("") ); Parameters.Add_Value( pNode_0 , "SCALEX" , _TL("Scale Factor X"), _TL("Scale Factor X"), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Value( pNode_0 , "SCALEY" , _TL("Scale Factor Y"), _TL("Scale Factor Y"), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Value( pNode_0 , "SCALEZ" , _TL("Scale Factor Z"), _TL("Scale Factor Z"), PARAMETER_TYPE_Double, 1.0 ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "ANCHOR" , _TL("Anchor Point"), _TL("") ); Parameters.Add_Value( pNode_0 , "ANCHORX" , _TL("X"), _TL("X"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0 , "ANCHORY" , _TL("Y"), _TL("Y"), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( pNode_0 , "ANCHORZ" , _TL("Z"), _TL("Z"), PARAMETER_TYPE_Double, 0.0 ); }//constructor //--------------------------------------------------------- CTransformShapes::~CTransformShapes(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTransformShapes::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("IN")) && pParameter->asShapes() != NULL ) { pParameters->Set_Enabled("ROTATEX", pParameter->asShapes()->Get_Vertex_Type() != SG_VERTEX_TYPE_XY); pParameters->Set_Enabled("ROTATEY", pParameter->asShapes()->Get_Vertex_Type() != SG_VERTEX_TYPE_XY); pParameters->Set_Enabled("DZ", pParameter->asShapes()->Get_Vertex_Type() != SG_VERTEX_TYPE_XY); pParameters->Set_Enabled("SCALEZ", pParameter->asShapes()->Get_Vertex_Type() != SG_VERTEX_TYPE_XY); pParameters->Set_Enabled("ANCHORZ", pParameter->asShapes()->Get_Vertex_Type() != SG_VERTEX_TYPE_XY); } return( 0 ); } //--------------------------------------------------------- bool CTransformShapes::On_Execute(void) { bool bCopy; double angleX, angleY, angleZ; TSG_Point_Z P, Q, Move, Scale, Anchor; CSG_Shapes *pIn, *pOut; double a11, a12, a13, a21, a22, a23, a31, a32, a33; //----------------------------------------------------- pIn = Parameters("IN") ->asShapes(); pOut = Parameters("OUT") ->asShapes(); Scale.x = Parameters("SCALEX") ->asDouble(); Scale.y = Parameters("SCALEY") ->asDouble(); Scale.z = Parameters("SCALEZ") ->asDouble(); Move.x = Parameters("DX") ->asDouble(); Move.y = Parameters("DY") ->asDouble(); Move.z = Parameters("DZ") ->asDouble(); Anchor.x = Parameters("ANCHORX") ->asDouble(); Anchor.y = Parameters("ANCHORY") ->asDouble(); Anchor.z = Parameters("ANCHORZ") ->asDouble(); angleX = Parameters("ROTATEX") ->asDouble() * -M_DEG_TO_RAD; angleY = Parameters("ROTATEY") ->asDouble() * -M_DEG_TO_RAD; angleZ = Parameters("ANGLE") ->asDouble() * -M_DEG_TO_RAD; if( pIn == pOut ) { bCopy = true; pOut = SG_Create_Shapes(); }//if else { bCopy = false; }//else pOut->Create(pIn->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pIn->Get_Name(), _TL("Transformed")), pIn, pIn->Get_Vertex_Type()); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count(); iShape++) { CSG_Shape *pShape = pOut->Add_Shape(pIn->Get_Shape(iShape)); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { P.x = pShape->Get_Point(iPoint, iPart).x; P.y = pShape->Get_Point(iPoint, iPart).y; if( pIn->Get_Vertex_Type() < SG_VERTEX_TYPE_XYZ ) { // move first, then rotate and scale... P.x += Move.x - Anchor.x; P.y += Move.y - Anchor.y; Q.x = Anchor.x + Scale.x * (P.x * cos(angleZ) - P.y * sin(angleZ)); Q.y = Anchor.y + Scale.y * (P.x * sin(angleZ) + P.y * cos(angleZ)); pShape->Set_Point(Q.x, Q.y, iPoint, iPart); } else { P.z = pIn->Get_Shape(iShape)->Get_Z(iPoint, iPart); //anchor shift P.x -= Anchor.x; P.y -= Anchor.y; P.z -= Anchor.z; // create rotation matrix a11 = cos(angleY) * cos(angleZ); a12 = -cos(angleX) * sin(angleZ) + sin(angleX) * sin(angleY) * cos(angleZ); a13 = sin(angleX) * sin(angleZ) + cos(angleX) * sin(angleY) * cos(angleZ); a21 = cos(angleY) * sin(angleZ); a22 = cos(angleX) * cos(angleZ) + sin(angleX) * sin(angleY) * sin(angleZ); a23 = -sin(angleX) * cos(angleZ) + cos(angleX) * sin(angleY) * sin(angleZ); a31 = -sin(angleY); a32 = sin(angleX) * cos(angleY); a33 = cos(angleX) * cos(angleY); //transform Q.x = (P.x * a11 + P.y * a12 + P.z * a13) * Scale.x; Q.y = (P.x * a21 + P.y * a22 + P.z * a23) * Scale.y; Q.z = (P.x * a31 + P.y * a32 + P.z * a33) * Scale.z; //undo anchor shift and apply move Q.x += Anchor.x + Move.x; Q.y += Anchor.y + Move.y; Q.z += Anchor.z + Move.z; pShape->Set_Point(Q.x, Q.y, iPoint, iPart); pShape->Set_Z(Q.z, iPoint, iPart); if( pIn->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShape->Set_M(pIn->Get_Shape(iShape)->Get_M(iPoint, iPart), iPoint, iPart); } } }//for iPoint }//for iPart }//for iShape //----------------------------------------------------- if( bCopy ) { pIn->Assign(pOut); delete(pOut); }//if return true; }//method saga-2.3.1/src/modules/shapes/shapes_tools/shapes_generate.cpp0000744000175000017500000002516612737416205025674 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_generate.cpp // // // // Copyright (C) 2012 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_generate.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Generate::CShapes_Generate(void) { Set_Name(_TL("Generate Shapes")); Set_Author(_TL("Volker Wichmann (c) 2012, LASERDATA GmbH")); Set_Description (_TW( "The module allows one to generate point, line or polygon shapes " "from a table with x and y coordinates and an identifier. The table " "must be sorted in vertex order.\n\n" "The identifier has different meanings:\n\n" "* Point Shapes: The identifier is arbitrary\n\n" "* Line Shapes: The identifier is unique for each line\n\n" "* Polygon Shapes: The identifier is unique for each polygon; " "the first polygon vertex may but must not be duplicated in " "order to close the polygon\n\n") ); //----------------------------------------------------- Parameters.Add_Table( NULL , "INPUT" ,_TL("Input"), _TL("Table with coordinates."), PARAMETER_INPUT ); Parameters.Add_Table_Field( Parameters("INPUT"), "FIELD_ID", _TL("ID"), _TL("Field with identifier.") ); Parameters.Add_Table_Field( Parameters("INPUT"), "FIELD_X", _TL("X"), _TL("Field with x-coordinate.") ); Parameters.Add_Table_Field( Parameters("INPUT"), "FIELD_Y", _TL("Y"), _TL("Field with y-coordinate.") ); /*Parameters.Add_Table_Field( Parameters("INPUT"), "FIELD_Z", _TL("Z"), _TL("Field with z-coordinate."), true );*/ Parameters.Add_Choice( NULL , "SHAPE_TYPE" , _TL("Shape Type"), _TL("Shape type to generate."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Point(s)"), _TL("Line(s)"), _TL("Polygon(s)") ), 0 ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL("Generated Shapefile."), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CShapes_Generate::~CShapes_Generate(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Generate::On_Execute(void) { CSG_Table *pInput; CSG_Shapes *pOutput; int iFieldId, iFieldX, iFieldY; // iFieldZ int iShapeType; CSG_String sName; pInput = Parameters("INPUT")->asTable(); iFieldId = Parameters("FIELD_ID")->asInt(); iFieldX = Parameters("FIELD_X")->asInt(); iFieldY = Parameters("FIELD_Y")->asInt(); //iFieldZ = Parameters("FIELD_Z")->asInt(); iShapeType = Parameters("SHAPE_TYPE")->asInt(); pOutput = Parameters("OUTPUT")->asShapes(); if (pInput->Get_Count() < 1) { SG_UI_Msg_Add_Error(_TL("Input table is empty!")); return (false); } //----------------------------------------------------- // Initialize ... sName = CSG_String::Format(SG_T("Shapes_%s"), pInput->Get_Name()); pOutput->Destroy(); switch (iShapeType) { default: case 0: // point pOutput->Create(SHAPE_TYPE_Point, sName, (CSG_Table*)0, SG_VERTEX_TYPE_XY); break; case 1: // line pOutput->Create(SHAPE_TYPE_Line, sName, (CSG_Table*)0, SG_VERTEX_TYPE_XY); break; case 2: // polygon pOutput->Create(SHAPE_TYPE_Polygon, sName, (CSG_Table*)0, SG_VERTEX_TYPE_XY); break; } pOutput->Add_Field(SG_T("ID"), SG_DATATYPE_Int); //----------------------------------------------------- // Generate ... switch (iShapeType) { default: case 0: // point if (!Generate_Point_Shapes(pInput, pOutput, iFieldId, iFieldX, iFieldY)) return (false); break; case 1: // line if (!Generate_Line_Shapes(pInput, pOutput, iFieldId, iFieldX, iFieldY)) return (false); break; case 2: // polygon if (!Generate_Polygon_Shapes(pInput, pOutput, iFieldId, iFieldX, iFieldY)) return (false); break; } //----------------------------------------------------- return (true); } //--------------------------------------------------------- bool CShapes_Generate::Generate_Point_Shapes(CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY) { for (int i=0; iGet_Count() && Set_Progress(i, pInput->Get_Count()); i++) { CSG_Table_Record *pRecord = pInput->Get_Record(i); CSG_Shape *pShape = pOutput->Add_Shape(); pShape->Add_Point(pRecord->asDouble(iFieldX), pRecord->asDouble(iFieldY)); pShape->Set_Value(0, pRecord->asInt(iFieldId)); } return (true); } //--------------------------------------------------------- bool CShapes_Generate::Generate_Line_Shapes(CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY) { int iVertices = 0; int iID = pInput->Get_Record(0)->asInt(iFieldId); CSG_Shape *pShape = pOutput->Add_Shape(); pShape->Set_Value(0, iID); for (int i=0; iGet_Count() && Set_Progress(i, pInput->Get_Count()); i++) { CSG_Table_Record *pRecord = pInput->Get_Record(i); if (pRecord->asInt(iFieldId) != iID) { if (iVertices < 2) { pOutput->Del_Record(pOutput->Get_Record_Count() - 1); SG_UI_Msg_Add_Error(_TL("Line with less than 2 vertices encountered!")); return (false); } pShape = pOutput->Add_Shape(); iID = pRecord->asInt(iFieldId); pShape->Set_Value(0, iID); iVertices = 0; } pShape->Add_Point(pRecord->asDouble(iFieldX), pRecord->asDouble(iFieldY)); iVertices += 1; iID = pRecord->asInt(iFieldId); } if (iVertices < 2) { pOutput->Del_Record(pOutput->Get_Record_Count() - 1); SG_UI_Msg_Add_Error(_TL("Line with less than 2 vertices encountered!")); return (false); } return (true); } //--------------------------------------------------------- bool CShapes_Generate::Generate_Polygon_Shapes(CSG_Table *pInput, CSG_Shapes *pOutput, int iFieldId, int iFieldX, int iFieldY) { int iVertices = 0; int iID = pInput->Get_Record(0)->asInt(iFieldId); CSG_Shape *pShape = pOutput->Add_Shape(); pShape->Set_Value(0, iID); TSG_Point pointA; pointA.x = pInput->Get_Record(0)->asDouble(iFieldX); pointA.y = pInput->Get_Record(0)->asDouble(iFieldY); for (int i=0; iGet_Count() && Set_Progress(i, pInput->Get_Count()); i++) { CSG_Table_Record *pRecord = pInput->Get_Record(i); if (pRecord->asInt(iFieldId) != iID) { if (iVertices < 3) { pOutput->Del_Record(pOutput->Get_Record_Count() - 1); SG_UI_Msg_Add_Error(_TL("Polygon with less than 3 vertices encountered!")); return (false); } TSG_Point pointB; pointB.x = pInput->Get_Record(i-1)->asDouble(iFieldX); pointB.y = pInput->Get_Record(i-1)->asDouble(iFieldY); if (pointA.x != pointB.x || pointA.y != pointB.y) pShape->Add_Point(pointA); pShape = pOutput->Add_Shape(); iID = pRecord->asInt(iFieldId); pShape->Set_Value(0, iID); pointA.x = pInput->Get_Record(i)->asDouble(iFieldX); pointA.y = pInput->Get_Record(i)->asDouble(iFieldY); iVertices = 0; } pShape->Add_Point(pRecord->asDouble(iFieldX), pRecord->asDouble(iFieldY)); iVertices += 1; iID = pRecord->asInt(iFieldId); } if (iVertices < 3) { pOutput->Del_Record(pOutput->Get_Record_Count() - 1); SG_UI_Msg_Add_Error(_TL("Polygon with less than 3 vertices encountered!")); return (false); } return (true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/shapes_split_randomly.h0000744000175000017500000001033312737416205026575 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Split_Randomly.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Split_Randomly_H #define HEADER_INCLUDED__Shapes_Split_Randomly_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Split_Randomly : public CSG_Module { public: CShapes_Split_Randomly(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual bool On_Execute (void); private: void Split (CSG_Shapes *pShapes, CSG_Shapes *pSplit[2], double Percent); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Split_Randomly_H saga-2.3.1/src/modules/shapes/shapes_tools/SearchInTable.h0000744000175000017500000000426412737416205024644 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* SearchInTable.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelect_String : public CSG_Module { public: CSelect_String(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); private: bool m_Case; int m_Field, m_Compare; CSG_String m_Expression; bool Do_Compare (const SG_Char *Value); bool Do_Select (CSG_Shape *pShape); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/shapes_buffer.h0000744000175000017500000001232712737416205025013 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Buffer.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Buffer_H #define HEADER_INCLUDED__Shapes_Buffer_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Buffer : public CSG_Module { public: CShapes_Buffer(void); protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool m_bPolyInner; double m_dArc; bool Get_Buffers (CSG_Shapes *pShapes, int Field, CSG_Shapes *pBuffers, double Scale, bool bDissolve); bool Get_Buffer (CSG_Shape *pShape , CSG_Shape *pBuffer, double Distance); bool Get_Buffer_Point (CSG_Shape *pPoint , CSG_Shape *pBuffer, double Distance); bool Get_Buffer_Points (CSG_Shape *pPoints , CSG_Shape *pBuffer, double Distance); bool Get_Buffer_Line (CSG_Shape *pLine , CSG_Shape *pBuffer, double Distance); bool Get_Buffer_Polygon (CSG_Shape *pPolygon, CSG_Shape *pBuffer, double Distance); double Get_Direction (const TSG_Point &From, const TSG_Point &To); bool Get_Parallel (const TSG_Point &A, const TSG_Point &B, TSG_Point AB[2], double Distance); void Add_Vertex (CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, double theta); void Add_Arc (CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, double alpha, double beta); void Add_Arc (CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, const TSG_Point &A, const TSG_Point &B); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Buffer_H saga-2.3.1/src/modules/shapes/shapes_tools/Makefile.am0000744000175000017500000000301712737416205024056 0ustar00oconradoconrad00000000000000# # $Id$ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_tools.la libshapes_tools_la_SOURCES =\ CreateChartLayer.cpp\ GraticuleBuilder.cpp\ LandUse_Scenario.cpp\ MLB_Interface.cpp\ NewLayerFromSelectedShapes.cpp\ quadtree_structure.cpp\ QueryBuilder.cpp\ SearchInTable.cpp\ SelectByTheme.cpp\ SeparateShapes.cpp\ Shapes_Create_Empty.cpp\ Shapes_Merge.cpp\ TransformShapes.cpp\ shapes_buffer.cpp\ shapes_convert_vertex_type.cpp\ shapes_cut.cpp\ shapes_cut_interactive.cpp\ shapes_extents.cpp\ shapes_generate.cpp\ shapes_polar_to_cartes.cpp\ shapes_split.cpp\ shapes_split_by_attribute.cpp\ shapes_split_randomly.cpp\ CreateChartLayer.h\ GraticuleBuilder.h\ LandUse_Scenario.h\ MLB_Interface.h\ NewLayerFromSelectedShapes.h\ quadtree_structure.h\ QueryBuilder.h\ SearchInTable.h\ SelectByTheme.h\ SeparateShapes.h\ Shapes_Create_Empty.h\ Shapes_Merge.h\ TransformShapes.h\ shapes_buffer.h\ shapes_convert_vertex_type.h\ shapes_cut.h\ shapes_cut_interactive.h\ shapes_extents.h\ shapes_generate.h\ shapes_polar_to_cartes.h\ shapes_split.h\ shapes_split_by_attribute.h\ shapes_split_randomly.h libshapes_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la #install-exec-hook: # pushd .; cd $(pkglibdir); ln -s libshapes_tools.so shapes_tools.so; popd saga-2.3.1/src/modules/shapes/shapes_tools/shapes_buffer.cpp0000744000175000017500000003506112737416205025346 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Buffer.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_buffer.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Buffer::CShapes_Buffer(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Shapes Buffer")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "A vector based buffer construction partly based on the method supposed by Dong et al. 2003. " "\n\n" "References:\n" "Dong, P, Yang, C., Rui, X., Zhang, L., Cheng, Q. (2003): " "'An effective buffer generation method in GIS'. " "Geoscience and Remote Sensing Symposium, 2003. " "IGARSS '03. Proceedings. 2003 IEEE International, Vol.6, p.3706-3708.\n" "online version\n" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "BUFFER" , _TL("Buffer"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); pNode = Parameters.Add_Table_Field_or_Const( pNode , "DIST_FIELD" , _TL("Buffer Distance"), _TL(""), 100.0, 0.0, true ); Parameters.Add_Value( pNode , "DIST_SCALE" , _TL("Scaling Factor for Attribute Value"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL , "DISSOLVE" , _TL("Dissolve Buffers"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "NZONES" , _TL("Number of Buffer Zones"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Value( NULL , "POLY_INNER" , _TL("Inner Buffer"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "DARC" , _TL("Arc Vertex Distance [Degree]"), _TL(""), PARAMETER_TYPE_Double, 5.0, 0.01, true, 45.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CShapes_Buffer::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SHAPES")) ) { pParameters->Get_Parameter("POLY_INNER")->Set_Enabled(pParameter->asShapes() && pParameter->asShapes()->Get_Type() == SHAPE_TYPE_Polygon); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("NZONES")) ) { pParameters->Get_Parameter("DISSOLVE" )->Set_Enabled(pParameter->asInt() == 1); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("DIST_FIELD")) ) { pParameters->Get_Parameter("DIST_SCALE")->Set_Enabled(pParameter->asInt() >= 0); } //----------------------------------------------------- return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Buffer::On_Execute(void) { int Field, nZones; CSG_Shapes *pShapes, *pBuffers; //----------------------------------------------------- pShapes = Parameters("SHAPES" )->asShapes(); pBuffers = Parameters("BUFFER" )->asShapes(); nZones = Parameters("NZONES" )->asInt(); Field = Parameters("DIST_FIELD")->asInt(); m_dArc = Parameters("DARC" )->asDouble() * M_DEG_TO_RAD; m_bPolyInner = Parameters("POLY_INNER")->asBool() && pShapes->Get_Type() == SHAPE_TYPE_Polygon; //----------------------------------------------------- if( !pShapes->is_Valid() ) { Message_Add(_TL("Invalid Shapes")); return( false ); } if( Field < 0 && Parameters("DIST_FIELD")->asDouble() <= 0.0 ) { Message_Add(_TL("Invalid Buffer Distance")); return( false ); } //----------------------------------------------------- if( nZones == 1 ) { Get_Buffers(pShapes, Field, pBuffers, 1.0, Parameters("DISSOLVE")->asBool()); } //----------------------------------------------------- else if( nZones > 1 ) { CSG_Shape *pBuffer; CSG_Shapes Buffers; pBuffers->Create(SHAPE_TYPE_Polygon); pBuffers->Add_Field(_TL("ID") , SG_DATATYPE_Int); pBuffers->Add_Field(_TL("ZONE") , SG_DATATYPE_Double); double dZone = 1.0 / nZones; for(int iZone=0; iZone 0 ) { SG_Polygon_Difference(pBuffer, Buffers.Get_Shape(0)); } pBuffer = pBuffers->Add_Shape(Buffers.Get_Shape(0)); pBuffer ->Set_Value(0, (nZones - iZone) + 1); pBuffer ->Set_Value(1, (nZones - iZone) * dZone * 100.0); } } //----------------------------------------------------- pBuffers->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Buffer"))); return( pBuffers->is_Valid() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffers(CSG_Shapes *pShapes, int Field, CSG_Shapes *pBuffers, double Scale, bool bDissolve) { //----------------------------------------------------- double Distance; CSG_Shapes Part(SHAPE_TYPE_Polygon); CSG_Shape *pPart = Part.Add_Shape(), *pBuffer; Distance = Parameters("DIST_FIELD")->asDouble() * Scale; Scale = Parameters("DIST_SCALE")->asDouble() * Scale; if( !bDissolve ) { pBuffers->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Buffer")), pShapes); } else { pBuffers->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("Buffer"))); pBuffers->Add_Field(_TL("ID"), SG_DATATYPE_Int); pBuffer = pBuffers->Add_Shape(); } //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); if( Field < 0 || (Distance = Scale * pShape->asDouble(Field)) > 0.0 ) { if( !bDissolve ) { pBuffer = pBuffers->Add_Shape(pShape, SHAPE_COPY_ATTR); } if( pBuffer->Get_Part_Count() == 0 ) { Get_Buffer(pShape, pBuffer, Distance); } else { Get_Buffer(pShape, pPart , Distance); SG_Polygon_Union(pBuffer, pPart); pPart->Del_Parts(); } } } //----------------------------------------------------- return( pBuffers->is_Valid() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer(CSG_Shape *pShape, CSG_Shape *pBuffer, double Distance) { switch( pShape->Get_Type() ) { case SHAPE_TYPE_Point: return( Get_Buffer_Point (pShape, pBuffer, Distance) ); case SHAPE_TYPE_Points: return( Get_Buffer_Points (pShape, pBuffer, Distance) ); case SHAPE_TYPE_Line: return( Get_Buffer_Line (pShape, pBuffer, Distance) ); case SHAPE_TYPE_Polygon: return( Get_Buffer_Polygon (pShape, pBuffer, Distance) ); default: return( false ); } } //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer_Point(CSG_Shape *pPoint, CSG_Shape *pBuffer, double Distance) { Add_Arc(pBuffer, pPoint->Get_Point(0), Distance, 0.0, M_PI_360); return( true ); } //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer_Points(CSG_Shape *pPoints, CSG_Shape *pBuffer, double Distance) { CSG_Shapes Part(SHAPE_TYPE_Polygon); CSG_Shape *pPart = Part.Add_Shape(); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { if( pBuffer->Get_Part_Count() == 0 ) { Add_Arc(pBuffer, pPoints->Get_Point(iPoint), Distance, 0.0, M_PI_360); } else { Add_Arc(pPart , pPoints->Get_Point(iPoint), Distance, 0.0, M_PI_360); SG_Polygon_Union(pBuffer, pPart); pPart->Del_Parts(); } } } return( true ); } //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer_Line(CSG_Shape *pLine, CSG_Shape *pBuffer, double Distance) { return( SG_Polygon_Offset(pLine, Distance, m_dArc, pBuffer) ); } //--------------------------------------------------------- bool CShapes_Buffer::Get_Buffer_Polygon(CSG_Shape *pPolygon, CSG_Shape *pBuffer, double Distance) { if( m_bPolyInner ) { if( SG_Polygon_Offset(pPolygon, -Distance, m_dArc, pBuffer) ) SG_Polygon_Difference(pPolygon, pBuffer, pBuffer); else pBuffer->Assign(pPolygon, false); return( true ); } return( SG_Polygon_Offset(pPolygon, Distance, m_dArc, pBuffer) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CShapes_Buffer::Get_Direction(const TSG_Point &From, const TSG_Point &To) { double dx = To.x - From.x; double dy = To.y - From.y; return( dx != 0.0 ? M_PI_180 + atan2(dy, dx) : ( dy > 0.0 ? M_PI_270 : ( dy < 0.0 ? M_PI_090 : 0.0 ) ) ); } //--------------------------------------------------------- inline bool CShapes_Buffer::Get_Parallel(const TSG_Point &A, const TSG_Point &B, TSG_Point AB[2], double Distance) { double d; TSG_Point C; if( (d = SG_Get_Distance(A, B)) > 0.0 ) { d = Distance / d; C.x = d * (A.y - B.y); C.y = d * (B.x - A.x); AB[0].x = A.x + C.x; AB[0].y = A.y + C.y; AB[1].x = B.x + C.x; AB[1].y = B.y + C.y; return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CShapes_Buffer::Add_Vertex(CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, double theta) { pBuffer->Add_Point( Center.x + Distance * cos(theta), Center.y + Distance * sin(theta) ); } //--------------------------------------------------------- inline void CShapes_Buffer::Add_Arc(CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, double alpha, double beta) { double theta; if( alpha < beta ) { for(theta=alpha; thetabeta; theta-=m_dArc) { Add_Vertex(pBuffer, Center, Distance, theta); } } Add_Vertex(pBuffer, Center, Distance, beta); } //--------------------------------------------------------- inline void CShapes_Buffer::Add_Arc(CSG_Shape *pBuffer, const TSG_Point &Center, double Distance, const TSG_Point &A, const TSG_Point &B) { double alpha, beta; alpha = Get_Direction(A, Center); beta = Get_Direction(B, Center); if( alpha - beta >= M_PI_180 ) { beta += M_PI_360; } Add_Arc(pBuffer, Center, Distance, alpha, beta); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/CreateChartLayer.h0000744000175000017500000000323512737416205025357 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* CreateChartLayer.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CCreateChartLayer : public CSG_Module { public: CCreateChartLayer(); virtual ~CCreateChartLayer(); virtual bool is_ProjectDependent(void) {return( false );} private: double m_fMaxValue, m_fMinValue; double m_fMaxSize, m_fMinSize; CSG_Parameters *m_pExtraParameters; bool *m_bIncludeParam; CSG_Shapes *m_pOutput; void AddPieChart(CSG_Shape*, int); void AddBarChart(CSG_Shape*, int); bool GetExtraParameters(); TSG_Point GetLineMidPoint(CSG_Shape_Line*); protected: virtual bool On_Execute(void); }; saga-2.3.1/src/modules/shapes/shapes_tools/shapes_split.h0000744000175000017500000001016112737416205024667 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Split.h // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Split_H #define HEADER_INCLUDED__Shapes_Split_H //--------------------------------------------------------- #include "shapes_cut.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Split : public CSG_Module { public: CShapes_Split(void); virtual ~CShapes_Split(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Split_H saga-2.3.1/src/modules/shapes/shapes_tools/shapes_cut_interactive.cpp0000744000175000017500000002332012737416205027260 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Cut_Interactive.cpp // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_cut_interactive.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Cut_Interactive::CShapes_Cut_Interactive(void) { Set_Name (_TL("Copy Selected Shapes")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "" )); Set_Drag_Mode (MODULE_INTERACTIVE_DRAG_BOX); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "CUT" , _TL("Selection"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), Cut_Methods_Str(), 1 ); Parameters.Add_Bool( NULL , "CONFIRM" , _TL("Confirm"), _TL("Show a confirmation dialog before selection is performed"), false ); //----------------------------------------------------- CSG_Parameters *pParameters = Add_Parameters("CUT", _TL("Extent"), _TL("")); pParameters->Add_Double(NULL, "AX", _TL("Left" ), _TL(""), 0.0); pParameters->Add_Double(NULL, "BX", _TL("Right" ), _TL(""), 1.0); pParameters->Add_Double(NULL, "AY", _TL("Bottom" ), _TL(""), 0.0); pParameters->Add_Double(NULL, "BY", _TL("Top" ), _TL(""), 1.0); pParameters->Add_Double(NULL, "DX", _TL("Horizontal Range"), _TL(""), 1.0, 0.0, true); pParameters->Add_Double(NULL, "DY", _TL("Vertical Range" ), _TL(""), 1.0, 0.0, true); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CShapes_Cut_Interactive::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameters->Get_Identifier(), "CUT") ) { double ax = pParameters->Get_Parameter("AX")->asDouble(); double ay = pParameters->Get_Parameter("AY")->asDouble(); double bx = pParameters->Get_Parameter("BX")->asDouble(); double by = pParameters->Get_Parameter("BY")->asDouble(); double dx = pParameters->Get_Parameter("DX")->asDouble(); double dy = pParameters->Get_Parameter("DY")->asDouble(); if( ax > bx ) { double d = ax; ax = bx; bx = d; } if( ay > by ) { double d = ay; ay = by; by = d; } if ( !SG_STR_CMP(pParameter->Get_Identifier(), "DX") ) { bx = ax + dx; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), "AX") || !SG_STR_CMP(pParameter->Get_Identifier(), "BX") ) { dx = bx - ax; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), "DY") ) { by = ay + dy; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), "AY") || !SG_STR_CMP(pParameter->Get_Identifier(), "BY") ) { dy = by - ay; } pParameters->Set_Parameter("AX", ax); pParameters->Set_Parameter("AY", ay); pParameters->Set_Parameter("BX", bx); pParameters->Set_Parameter("BY", by); pParameters->Set_Parameter("DX", dx); pParameters->Set_Parameter("DY", dy); } //----------------------------------------------------- else if( !SG_STR_CMP(pParameter->Get_Identifier(), "SHAPES") && pParameter->asShapes() ) { CSG_Shapes *pCut = pParameters->Get_Parameter("CUT")->asShapes(); if( pCut != DATAOBJECT_NOTSET && pCut != DATAOBJECT_CREATE && pCut->Get_Type() != pParameter->asShapes()->Get_Type() ) { pParameters->Get_Parameter("CUT")->Set_Value(DATAOBJECT_CREATE); } } return( CSG_Module::On_Parameter_Changed(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Cut_Interactive::On_Execute(void) { m_bDown = false; m_pShapes = Parameters("SHAPES" )->asShapes(); m_pCut = Parameters("CUT" )->asShapes(); m_pExtent = Parameters("EXTENT" )->asShapes(); m_Method = Parameters("METHOD" )->asInt (); m_bConfirm = Parameters("CONFIRM")->asBool (); m_pCut->Create(m_pShapes->Get_Type()); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Cut_Interactive::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { switch( Mode ) { //----------------------------------------------------- case MODULE_INTERACTIVE_LDOWN: if( m_bDown == false ) { m_bDown = true; m_pDown = ptWorld; } break; //----------------------------------------------------- case MODULE_INTERACTIVE_LUP: if( m_bDown == true ) { m_bDown = false; CSG_Rect Extent(m_pDown, ptWorld); if( !m_bConfirm || Get_Extent(Extent) ) { if( Cut_Set_Extent(Extent, m_pExtent, true) ) { DataObject_Update(m_pExtent); } if( Cut_Shapes(Extent, m_Method, m_pShapes, m_pCut) ) { DataObject_Update(m_pCut); } else { Message_Add(_TL("No shapes in selection")); } } } break; } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Cut_Interactive::Get_Extent(CSG_Rect &Extent) { CSG_Parameters *pParameters = Get_Parameters("CUT"); pParameters->Set_Callback(false); pParameters->Set_Parameter("AX", Extent.Get_XMin ()); pParameters->Set_Parameter("AY", Extent.Get_YMin ()); pParameters->Set_Parameter("BX", Extent.Get_XMax ()); pParameters->Set_Parameter("BY", Extent.Get_YMax ()); pParameters->Set_Parameter("DX", Extent.Get_XRange()); pParameters->Set_Parameter("DY", Extent.Get_YRange()); pParameters->Set_Callback(true); if( Dlg_Parameters("CUT") ) { Extent.Assign( pParameters->Get_Parameter("AX")->asDouble(), pParameters->Get_Parameter("AY")->asDouble(), pParameters->Get_Parameter("BX")->asDouble(), pParameters->Get_Parameter("BY")->asDouble() ); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/GraticuleBuilder.h0000744000175000017500000000502612737416205025423 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* GraticuleBuilder.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGraticuleBuilder : public CSG_Module { public: CGraticuleBuilder(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/Shapes_Create_Empty.cpp0000744000175000017500000002674412737416205026426 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Create_Empty.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Shapes_Create_Empty.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_NODE(i) CSG_String::Format(SG_T("NODE%03d"), i) #define GET_NAME(i) CSG_String::Format(SG_T("NAME%03d"), i) #define GET_TYPE(i) CSG_String::Format(SG_T("TYPE%03d"), i) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Create_Empty::CShapes_Create_Empty(void) { //----------------------------------------------------- Set_Name (_TL("Create New Shapes Layer")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (CSG_String::Format(_TW( "Creates a new empty shapes layer of given type, " "which might be either point, multipoint, line or polygon.\n\n" "Possible field types for the attributes table are:\n" "- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n- %s\n"), SG_Data_Type_Get_Name(SG_DATATYPE_String).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Date ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Color ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Byte ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Char ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Word ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Short ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_DWord ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Int ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_ULong ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Long ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Float ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Double).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Binary).c_str() )); //----------------------------------------------------- Parameters.Add_Shapes_Output( NULL , "SHAPES" , _TL("Shapes"), _TL("") ); Parameters.Add_String( NULL , "NAME" , _TL("Name"), _TL(""), _TL("New Shapes Layer") ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Shape Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Point"), _TL("Multipoint"), _TL("Lines"), _TL("Polygon") ) ); Parameters.Add_Choice( NULL , "VERTEX" , _TL("Vertex Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("x, y"), _TL("x, y, z"), _TL("x, y, z, m") ) ); Parameters.Add_Value( NULL , "NFIELDS" , _TL("Number of Attributes"), _TL(""), PARAMETER_TYPE_Int , 2, 1, true ); Parameters.Add_Parameters( NULL , "FIELDS" , _TL("Attributes"), _TL("") ); //----------------------------------------------------- CSG_Parameters *pAttributes = Parameters("FIELDS")->asParameters(); _Set_Field_Count(pAttributes, Parameters("NFIELDS")->asInt()); pAttributes->Get_Parameter(GET_NAME(0))->Set_Value(_TL("ID")); pAttributes->Get_Parameter(GET_TYPE(0))->Set_Value(3); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CShapes_Create_Empty::_Set_Field_Count(CSG_Parameters *pAttributes, int nAttributes) { //----------------------------------------------------- CSG_String Types; Types = CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|"), SG_Data_Type_Get_Name(SG_DATATYPE_String).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Date ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Color ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Byte ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Char ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Word ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Short ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_DWord ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Int ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_ULong ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Long ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Float ).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Double).c_str(), SG_Data_Type_Get_Name(SG_DATATYPE_Binary).c_str() ); //----------------------------------------------------- if( pAttributes && nAttributes > 0 ) { int nCurrent = pAttributes->Get_Count() / 3; if( nCurrent < nAttributes ) { for(int i=nCurrent; iAdd_Node( NULL , GET_NODE(i), CSG_String::Format(SG_T("%i. %s"), i + 1, _TL("Attribute")), _TL("") ); pAttributes->Add_String( pNode , GET_NAME(i), _TL("Name"), _TL(""), _TL("Name") ); pAttributes->Add_Choice( pNode , GET_TYPE(i), _TL("Type"), _TL(""), Types ); } } else if( nCurrent > nAttributes ) { CSG_Parameters Tmp; Tmp.Assign(pAttributes); pAttributes->Destroy(); pAttributes->Set_Name(Tmp.Get_Name()); for(int i=0; iAdd_Node( NULL , GET_NODE(i), CSG_String::Format(SG_T("%i. %s"), i + 1, _TL("Attribute")), _TL("") ); pAttributes->Add_String( pNode , GET_NAME(i), _TL("Name"), _TL(""), Tmp(GET_NAME(i)) ? Tmp(GET_NAME(i))->asString() : _TL("Name") ); pAttributes->Add_Choice( pNode , GET_TYPE(i), _TL("Type"), _TL(""), Types, Tmp(GET_TYPE(i)) ? Tmp(GET_TYPE(i))->asInt() : 0 ); } } } } //--------------------------------------------------------- int CShapes_Create_Empty::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("NFIELDS")) ) { _Set_Field_Count(pParameters->Get_Parameter("FIELDS")->asParameters(), pParameter->asInt()); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Create_Empty::On_Execute(void) { TSG_Vertex_Type Vertex; switch( Parameters("VERTEX")->asInt() ) { default: case 0: Vertex = SG_VERTEX_TYPE_XY; break; case 1: Vertex = SG_VERTEX_TYPE_XYZ; break; case 2: Vertex = SG_VERTEX_TYPE_XYZM; break; } //----------------------------------------------------- CSG_Shapes *pShapes; switch( Parameters("TYPE")->asInt() ) { default: return( false ); case 0: pShapes = SG_Create_Shapes(SHAPE_TYPE_Point , Parameters("NAME")->asString(), NULL, Vertex); break; case 1: pShapes = SG_Create_Shapes(SHAPE_TYPE_Points , Parameters("NAME")->asString(), NULL, Vertex); break; case 2: pShapes = SG_Create_Shapes(SHAPE_TYPE_Line , Parameters("NAME")->asString(), NULL, Vertex); break; case 3: pShapes = SG_Create_Shapes(SHAPE_TYPE_Polygon, Parameters("NAME")->asString(), NULL, Vertex); break; } //----------------------------------------------------- int i, n; TSG_Data_Type Type; CSG_Parameters *pAttributes; pAttributes = Parameters("FIELDS")->asParameters(); n = pAttributes->Get_Count() / 3; for(i=0; iGet_Parameter(GET_TYPE(i))->asInt() ) { default: case 0: Type = SG_DATATYPE_String; break; case 1: Type = SG_DATATYPE_Date; break; case 2: Type = SG_DATATYPE_Color; break; case 3: Type = SG_DATATYPE_Byte; break; case 4: Type = SG_DATATYPE_Char; break; case 5: Type = SG_DATATYPE_Word; break; case 6: Type = SG_DATATYPE_Short; break; case 7: Type = SG_DATATYPE_DWord; break; case 8: Type = SG_DATATYPE_Int; break; case 9: Type = SG_DATATYPE_ULong; break; case 10: Type = SG_DATATYPE_Long; break; case 11: Type = SG_DATATYPE_Float; break; case 12: Type = SG_DATATYPE_Double; break; case 13: Type = SG_DATATYPE_Binary; break; } pShapes->Add_Field(pAttributes->Get_Parameter(GET_NAME(i))->asString(), Type); } Parameters("SHAPES")->Set_Value(pShapes); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/MLB_Interface.h0000744000175000017500000000763712737416205024601 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__shapes_tools_H #define HEADER_INCLUDED__shapes_tools_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef shapes_tools_EXPORTS #define shapes_tools_EXPORT _SAGA_DLL_EXPORT #else #define shapes_tools_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_tools_H saga-2.3.1/src/modules/shapes/shapes_tools/LandUse_Scenario.cpp0000744000175000017500000003251712737416205025713 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: LandUse_Scenario.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // statistics // // // //-------------------------------------------------------// // // // LandUse_Scenario.cpp // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "LandUse_Scenario.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define STATISTICS_HEADCOLS 3 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLandUse_Scenario::CLandUse_Scenario(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Land Use Scenario Generator")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "This tool generates land use scenarios for fields under " "agricultural use based on statistics about the amount of " "crop types grown in the investigated area of interest. " )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "FIELDS" , _TL("Fields"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field( pNode , "FIELD_ID" , _TL("Field Identifier"), _TL("") ); pNode = Parameters.Add_Shapes( NULL , "SCENARIO" , _TL("Land Use Scenario"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( pNode , "OUTPUT" , _TL("Output of..."), _TL(""), CSG_String::Format("%s|%s|", _TL("Identifier"), _TL("Name") ), 0 ); //----------------------------------------------------- Parameters.Add_Table( NULL , "STATISTICS" , _TL("Crop Statistics"), _TW("The first column specifies a crop type id. " "The second column provides a human readible name for the crop type (e.g. 'potatoes') ." "The third column must be an integer value, though this value is not yet used by this module. " "The following columns provide the yearly amount of each crop type [%] for a sequence of years. "), PARAMETER_INPUT ); Parameters.Add_Table( NULL , "KNOWN_CROPS" , _TL("Known Crops"), _TW("The first column specifies the field id as given by the 'Fields' layer. " "The following columns specify the crop type for each field and year " "and refer to the crop type identifiers used in the crop statistics table. " "The sequence of years must be identical with that of the crop statistics table."), PARAMETER_INPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLandUse_Scenario::On_Execute(void) { //----------------------------------------------------- CSG_Table *pStatistics = Parameters("STATISTICS")->asTable(); if( pStatistics->Get_Field_Count() <= STATISTICS_HEADCOLS ) { Error_Set(_TL("statistics table is missing required fields")); return( false ); } if( pStatistics->Get_Count() <= 0 ) { Error_Set(_TL("statistics table does not contain any records")); return( false ); } //----------------------------------------------------- CSG_Shapes *pFields = Parameters("FIELDS" )->asShapes(); int Field_ID = Parameters("FIELD_ID")->asInt (); if( pFields->Get_Count() <= 0 ) { Error_Set(_TL("fields layer does not contain any records")); return( false ); } //----------------------------------------------------- int nYears, iYear, iField, iType; //----------------------------------------------------- CSG_Table Types; Types.Add_Field("ID" , SG_DATATYPE_Int); Types.Add_Field("NAME" , SG_DATATYPE_String); Types.Add_Field("RETURN", SG_DATATYPE_Int); Types.Set_Record_Count(pStatistics->Get_Count()); nYears = pStatistics->Get_Field_Count() - STATISTICS_HEADCOLS; CSG_Matrix Crops(nYears, Types.Get_Count()); for(iType=0; iTypeGet_Record(iType); Types[iType][0] = pRecord->asInt (0); Types[iType][1] = pRecord->asString(1); Types[iType][2] = pRecord->asInt (2); for(iYear=0; iYearasDouble(iYear + STATISTICS_HEADCOLS); } } //----------------------------------------------------- CSG_Table Scenario; for(iYear=0; iYearGet_Field_Name(iYear + STATISTICS_HEADCOLS), SG_DATATYPE_Int); } Scenario.Add_Field("ID" , SG_DATATYPE_Int); Scenario.Add_Field("AREA", SG_DATATYPE_Double); Scenario.Set_Record_Count(pFields->Get_Count()); for(iField=0; iFieldGet_Count(); iField++) { CSG_Shape_Polygon *pField = (CSG_Shape_Polygon *)pFields->Get_Shape(iField); Scenario[iField][nYears + 0] = pField->asInt(Field_ID); Scenario[iField][nYears + 1] = pField->Get_Area(); for(iYear=0; iYearasShapes(); bool bID = Parameters("OUTPUT")->asInt() == 0; pScenario->Create(SHAPE_TYPE_Polygon, CSG_String::Format("%s [%s]", pFields->Get_Name(), _TL("Land Use Scenario"))); pScenario->Add_Field("ID", SG_DATATYPE_Int); for(iYear=0; iYearAdd_Field(pStatistics->Get_Field_Name(iYear + STATISTICS_HEADCOLS), bID ? SG_DATATYPE_Int : SG_DATATYPE_String); } //----------------------------------------------------- for(iField=0; iFieldGet_Count(); iField++) { CSG_Shape *pField = pScenario->Add_Shape(pFields->Get_Shape(iField), SHAPE_COPY_GEOM); pField->Set_Value(0, pFields->Get_Shape(iField)->asInt(Field_ID)); for(iYear=0; iYearasTable(); if( !pLandUse_Known || pLandUse_Known->Get_Field_Count() != nYears + 1 ) { return( true ); } for(int iKnown=0; iKnownGet_Count(); iKnown++) { CSG_Table_Record *pKnown = pLandUse_Known->Get_Record(iKnown); for(int iField=0, Field_ID=pKnown->asInt(0); iFieldasInt(iYear + 1); for(int iType=0; iType= 0 ) { iType = Scenario[iField][iYear].asInt(); Area_Left -= Scenario[iField][nYears + 1]; Area_Crop[iType] -= Scenario[iField][nYears + 1]; } } //------------------------------------------------- // 3. fill remaining gaps with randomized scenario... for(iField=0; iField= 0 ) { Area_Left -= Scenario[iField][nYears + 1]; Area_Crop[Type] -= Scenario[iField][nYears + 1]; Scenario[iField][iYear] = Type; } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/shapes_convert_vertex_type.cpp0000744000175000017500000002015312737416205030207 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // shapes_convert_vertex_type.cpp // // // // Copyright (C) 2013 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_convert_vertex_type.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Convert_Vertex_Type::CShapes_Convert_Vertex_Type(void) { Set_Name(_TL("Convert Vertex Type (2D/3D)")); Set_Author(_TL("Volker Wichmann (c) 2013, LASERDATA GmbH")); Set_Description (_TW( "The module allows one to convert the vertex type of shapes from " "'XY' (2D) to 'XYZ/M' (3D) and vice versa. The conversion from " "3D to 2D is not lossless for lines and polygons, as only the " "Z/M value of one vertex can be retained (currently that of the " "last vertex).\n\n") ); //----------------------------------------------------- CSG_Parameter *pNode; pNode = Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL("The shapefile to convert."), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD_Z" , _TL("Z"), _TL("Field with z-coordinate information."), true ); Parameters.Add_Table_Field( pNode , "FIELD_M" , _TL("M"), _TL("Field with measure information."), true ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL("The converted shapefile."), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CShapes_Convert_Vertex_Type::~CShapes_Convert_Vertex_Type(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Convert_Vertex_Type::On_Execute(void) { CSG_Shapes *pInput, *pOutput; int iFieldZ, iFieldM; pInput = Parameters("INPUT")->asShapes(); iFieldZ = Parameters("FIELD_Z")->asInt(); iFieldM = Parameters("FIELD_M")->asInt(); pOutput = Parameters("OUTPUT")->asShapes(); if( pInput->Get_Count() < 1 ) { SG_UI_Msg_Add_Error(_TL("Input shape is empty!")); return (false); } //----------------------------------------------------- if( pInput->Get_Vertex_Type() == SG_VERTEX_TYPE_XY ) { if( iFieldZ < 0 ) { SG_UI_Msg_Add_Error(_TL("Please provide an attribute field with z-information!")); return( false ); } if( iFieldM < 0 ) { pOutput->Create(pInput->Get_Type(), CSG_String::Format(SG_T("%s_Z"), pInput->Get_Name()), pInput, SG_VERTEX_TYPE_XYZ); } else { pOutput->Create(pInput->Get_Type(), CSG_String::Format(SG_T("%s_ZM"), pInput->Get_Name()), pInput, SG_VERTEX_TYPE_XYZM); } } else { pOutput->Create(pInput->Get_Type(), CSG_String::Format(SG_T("%s_XY"), pInput->Get_Name()), pInput, SG_VERTEX_TYPE_XY); pOutput->Add_Field(SG_T("Z"), SG_DATATYPE_Double); if( pInput->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pOutput->Add_Field(SG_T("M"), SG_DATATYPE_Double); } } //----------------------------------------------------- for(int iShape=0; iShapeGet_Count(); iShape++) { CSG_Shape *pShapeIn = pInput ->Get_Shape(iShape); CSG_Shape *pShapeOut = pOutput ->Add_Shape(pShapeIn, SHAPE_COPY_ATTR); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pShapeOut->Add_Point(pShapeIn->Get_Point(iPoint, iPart), iPart); if( pInput->Get_Vertex_Type() == SG_VERTEX_TYPE_XY ) { pShapeOut->Set_Z(pShapeIn->asDouble(iFieldZ), iPoint, iPart); if( pOutput->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShapeOut->Set_M(pShapeIn->asDouble(iFieldM), iPoint, iPart); } } else { if( pInput->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pShapeOut->Set_Value(pOutput->Get_Field_Count() - 1, pShapeIn->Get_M(iPoint, iPart)); pShapeOut->Set_Value(pOutput->Get_Field_Count() - 2, pShapeIn->Get_Z(iPoint, iPart)); } else { pShapeOut->Set_Value(pOutput->Get_Field_Count() - 1, pShapeIn->Get_Z(iPoint, iPart)); } } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- int CShapes_Convert_Vertex_Type::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("INPUT")) && pParameter->asShapes() != NULL ) { pParameters->Get_Parameter("FIELD_Z")->Set_Enabled(pParameters->Get_Parameter("INPUT")->asShapes()->Get_Vertex_Type() == SG_VERTEX_TYPE_XY); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FIELD_Z")) ) { pParameters->Get_Parameter("FIELD_M")->Set_Enabled(pParameter->asInt() >= 0); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/QueryBuilder.h0000744000175000017500000000400712737416205024607 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* QueryBuilder.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSelect_Numeric : public CSG_Module { public: CSelect_Numeric(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Selection") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/shapes_cut.cpp0000744000175000017500000004036112737416205024667 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // Shapes_Cut.cpp // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shapes_cut.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool Cut_Shapes(CSG_Shapes *pPolygons, int Method, CSG_Shapes *pShapes, CSG_Shapes *pCut, double Overlap) { if( !pCut || !pShapes || !pShapes->is_Valid() || !pPolygons || !pPolygons->is_Valid() || !pPolygons->Get_Extent().Intersects(pShapes->Get_Extent()) || pPolygons->Get_Type() != SHAPE_TYPE_Polygon ) { return( false ); } pCut->Create(pShapes->Get_Type(), CSG_String::Format("%s [%s]", pShapes->Get_Name(), _TL("Cut")), pShapes, pShapes->Get_Vertex_Type()); //----------------------------------------------------- CSG_Shapes Intersect(SHAPE_TYPE_Polygon); CSG_Shape_Polygon *pIntersect = Overlap > 0.0 && pShapes->Get_Type() == SHAPE_TYPE_Polygon ? (CSG_Shape_Polygon *)Intersect.Add_Shape() : NULL; //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && SG_UI_Process_Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); bool bAdd = false; for(int iPolygon=0; !bAdd && iPolygonGet_Count(); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); switch( Method ) { case 2: // center bAdd = pPolygon->Contains(pShapes->Get_Type() == SHAPE_TYPE_Polygon ? ((CSG_Shape_Polygon *)pShape)->Get_Centroid() : (TSG_Point)pShape->Get_Extent().Get_Center() ); break; case 1: // intersects bAdd = pPolygon->Intersects(pShape) != INTERSECTION_None; if( bAdd && pIntersect ) { bAdd = SG_Polygon_Intersection(pPolygon, pShape, pIntersect) && Overlap <= pIntersect->Get_Area() / ((CSG_Shape_Polygon *)pShape)->Get_Area(); } break; default: // completely contained bAdd = pPolygon->Intersects(pShape) == INTERSECTION_Contains; break; } } //------------------------------------------------- if( bAdd ) { pCut->Add_Shape(pShape); } } //----------------------------------------------------- return( pCut->Get_Count() > 0 ); } //--------------------------------------------------------- CSG_Shapes * Cut_Shapes(CSG_Shapes *pPolygons, int Method, CSG_Shapes *pShapes, double Overlap) { CSG_Shapes *pCut = SG_Create_Shapes(); if( Cut_Shapes(pPolygons, Method, pShapes, pCut, Overlap) ) { return( pCut ); } delete(pCut); return( NULL ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool Cut_Shapes(CSG_Rect Extent, int Method, CSG_Shapes *pShapes, CSG_Shapes *pCut) { if( !pCut || !pShapes || !pShapes->is_Valid() || !Extent.Intersects(pShapes->Get_Extent()) ) { return( false ); } pCut->Create(pShapes->Get_Type(), CSG_String::Format("%s [%s]", pShapes->Get_Name(), _TL("Cut")), pShapes, pShapes->Get_Vertex_Type()); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && SG_UI_Process_Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); bool bAdd; switch( Method ) { case 2: // center bAdd = Extent.Contains(pShapes->Get_Type() == SHAPE_TYPE_Polygon ? ((CSG_Shape_Polygon *)pShape)->Get_Centroid() : (TSG_Point)pShape->Get_Extent().Get_Center() ); break; case 1: // intersects bAdd = pShape->Intersects(Extent) != INTERSECTION_None; break; default: // completely contained bAdd = pShape->Intersects(Extent) == INTERSECTION_Contained; break; } //------------------------------------------------- if( bAdd ) { pCut->Add_Shape(pShape); } } //----------------------------------------------------- return( pCut->Get_Count() > 0 ); } //--------------------------------------------------------- CSG_Shapes * Cut_Shapes(CSG_Rect Extent, int Method, CSG_Shapes *pShapes) { CSG_Shapes *pCut = SG_Create_Shapes(); if( Cut_Shapes(Extent, Method, pShapes, pCut) ) { return( pCut ); } delete(pCut); return( NULL ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String Cut_Methods_Str(void) { return( CSG_String::Format("%s|%s|%s|", _TL("completely contained"), _TL("intersects"), _TL("center") )); } //--------------------------------------------------------- bool Cut_Set_Extent(CSG_Rect Extent, CSG_Shapes *pExtent, bool bClear) { if( pExtent ) { if( bClear ) { pExtent->Create(SHAPE_TYPE_Polygon, _TL("Extent [Cut]")); pExtent->Add_Field("ID", SG_DATATYPE_Int); } if( pExtent->Get_Type() == SHAPE_TYPE_Polygon ) { CSG_Shape *pShape = pExtent->Add_Shape(); pShape->Set_Value("ID", pExtent->Get_Count()); pShape->Add_Point(Extent.Get_XMin(), Extent.Get_YMin()); pShape->Add_Point(Extent.Get_XMin(), Extent.Get_YMax()); pShape->Add_Point(Extent.Get_XMax(), Extent.Get_YMax()); pShape->Add_Point(Extent.Get_XMax(), Extent.Get_YMin()); pShape->Add_Point(Extent.Get_XMin(), Extent.Get_YMin()); return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Cut::CShapes_Cut(void) { Set_Name (_TL("Copy Selected Shapes")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes_List( NULL , "CUT" , _TL("Selection"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), Cut_Methods_Str(), 1 ); Parameters.Add_Choice( NULL , "EXTENT" , _TL("Extent"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("user defined"), _TL("grid project"), _TL("shapes layer extent"), _TL("polygons") ), 0 ); //----------------------------------------------------- Parameters.Add_Double(NULL, "AX", _TL("Left" ), _TL(""), 0.0); Parameters.Add_Double(NULL, "BX", _TL("Right" ), _TL(""), 1.0); Parameters.Add_Double(NULL, "AY", _TL("Bottom" ), _TL(""), 0.0); Parameters.Add_Double(NULL, "BY", _TL("Top" ), _TL(""), 1.0); Parameters.Add_Double(NULL, "DX", _TL("Horizontal Range"), _TL(""), 1.0, 0.0, true); Parameters.Add_Double(NULL, "DY", _TL("Vertical Range" ), _TL(""), 1.0, 0.0, true); Parameters.Add_Grid_System( NULL , "GRID_SYS" , _TL("Grid System"), _TL("") ); Parameters.Add_Shapes( NULL , "SHAPES_EXT" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Double( NULL , "OVERLAP" , _TL("Minimum Overlap"), _TL("minimum overlapping area as percentage of the total size of the input shape. applies to polygon layers only."), 50.0, 0.0, true, 100.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CShapes_Cut::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "SHAPES") ) { if( pParameter->asShapesList()->Get_Count() > 0 ) { CSG_Rect Extent(pParameter->asShapesList()->asShapes(0)->Get_Extent()); for(int i=1; iasShapesList()->Get_Count(); i++) { Extent.Union(pParameter->asShapesList()->asShapes(i)->Get_Extent()); } pParameters->Set_Parameter("AX", Extent.Get_XMin ()); pParameters->Set_Parameter("AY", Extent.Get_YMin ()); pParameters->Set_Parameter("BX", Extent.Get_XMax ()); pParameters->Set_Parameter("BY", Extent.Get_YMax ()); pParameters->Set_Parameter("DX", Extent.Get_XRange()); pParameters->Set_Parameter("DY", Extent.Get_YRange()); } } else if( pParameters->Get_Parameter("EXTENT")->asInt() == 0 ) { double ax = pParameters->Get_Parameter("AX")->asDouble(); double ay = pParameters->Get_Parameter("AY")->asDouble(); double bx = pParameters->Get_Parameter("BX")->asDouble(); double by = pParameters->Get_Parameter("BY")->asDouble(); double dx = pParameters->Get_Parameter("DX")->asDouble(); double dy = pParameters->Get_Parameter("DY")->asDouble(); if( ax > bx ) { double d = ax; ax = bx; bx = d; } if( ay > by ) { double d = ay; ay = by; by = d; } if ( !SG_STR_CMP(pParameter->Get_Identifier(), "DX") ) { bx = ax + dx; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), "AX") || !SG_STR_CMP(pParameter->Get_Identifier(), "BX") ) { dx = bx - ax; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), "DY") ) { by = ay + dy; } else if( !SG_STR_CMP(pParameter->Get_Identifier(), "AY") || !SG_STR_CMP(pParameter->Get_Identifier(), "BY") ) { dy = by - ay; } pParameters->Set_Parameter("AX", ax); pParameters->Set_Parameter("AY", ay); pParameters->Set_Parameter("BX", bx); pParameters->Set_Parameter("BY", by); pParameters->Set_Parameter("DX", dx); pParameters->Set_Parameter("DY", dy); } return( CSG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CShapes_Cut::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "EXTENT") ) { pParameters->Set_Enabled("AX" , pParameter->asInt() == 0); pParameters->Set_Enabled("AY" , pParameter->asInt() == 0); pParameters->Set_Enabled("BX" , pParameter->asInt() == 0); pParameters->Set_Enabled("BY" , pParameter->asInt() == 0); pParameters->Set_Enabled("DX" , pParameter->asInt() == 0); pParameters->Set_Enabled("DY" , pParameter->asInt() == 0); pParameters->Set_Enabled("GRID_SYS" , pParameter->asInt() == 1); pParameters->Set_Enabled("SHAPES_EXT", pParameter->asInt() == 2); pParameters->Set_Enabled("POLYGONS" , pParameter->asInt() == 3); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "SHAPES") || !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { bool bEnable = pParameters->Get_Parameter("METHOD")->asInt() == 1; // intersects if( bEnable ) { CSG_Parameter_Shapes_List *pShapes = pParameters->Get_Parameter("SHAPES")->asShapesList(); bEnable = false; for(int i=0; !bEnable && iGet_Count(); i++) { bEnable = pShapes->asShapes(i)->Get_Type() == SHAPE_TYPE_Polygon; } } pParameters->Set_Enabled("OVERLAP" , bEnable); } return( CSG_Module::On_Parameter_Changed(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Cut::On_Execute(void) { CSG_Parameter_Shapes_List *pShapes = Parameters("SHAPES")->asShapesList(); if( pShapes->Get_Count() < 1 ) { return( false ); } //----------------------------------------------------- CSG_Rect Extent; CSG_Shapes Polygons(SHAPE_TYPE_Polygon), *pPolygons = NULL; switch( Parameters("EXTENT")->asInt() ) { case 0: // user defined Extent.Assign( Parameters("AX")->asDouble(), Parameters("AY")->asDouble(), Parameters("BX")->asDouble(), Parameters("BY")->asDouble() ); break; case 1: // grid project Extent.Assign(Parameters("GRID_SYS")->asGrid_System()->Get_Extent()); break; case 2: // shapes extent Extent.Assign(Parameters("SHAPES_EXT")->asShapes()->Get_Extent()); break; case 3: // polygons pPolygons = Parameters("POLYGONS")->asShapes(); break; } if( !pPolygons ) { CSG_Shape *pPolygon = Polygons.Add_Shape(); pPolygon->Add_Point(Extent.Get_XMin(), Extent.Get_YMin()); pPolygon->Add_Point(Extent.Get_XMin(), Extent.Get_YMax()); pPolygon->Add_Point(Extent.Get_XMax(), Extent.Get_YMax()); pPolygon->Add_Point(Extent.Get_XMax(), Extent.Get_YMin()); pPolygons = &Polygons; } //----------------------------------------------------- CSG_Parameter_Shapes_List *pCuts = Parameters("CUT")->asShapesList(); pCuts->Del_Items(); int Method = Parameters("METHOD")->asInt(); double Overlap = Parameters("OVERLAP")->asDouble() / 100.0; for(int i=0; iGet_Count(); i++) { CSG_Shapes *pCut = Cut_Shapes(pPolygons, Method, pShapes->asShapes(i), Overlap); if( pCut ) { pCuts->Add_Item(pCut); } } //----------------------------------------------------- return( pCuts->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/SeparateShapes.h0000744000175000017500000000377612737416205025117 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* SeparateShapes.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSeparateShapes : public CSG_Module { public: CSeparateShapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/MLB_Interface.cpp0000744000175000017500000001440112737416205025117 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Tools") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Olaya, V. Wichmann (c) 2002-2013") ); case MLB_INFO_Description: return( _TL("Tools for the manipulation of vector data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Tools") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Shapes_Create_Empty.h" #include "Shapes_Merge.h" #include "QueryBuilder.h" #include "SearchInTable.h" #include "SelectByTheme.h" #include "NewLayerFromSelectedShapes.h" #include "SeparateShapes.h" #include "TransformShapes.h" #include "CreateChartLayer.h" #include "GraticuleBuilder.h" #include "shapes_cut.h" #include "shapes_cut_interactive.h" #include "shapes_split.h" #include "shapes_split_randomly.h" #include "shapes_split_by_attribute.h" #include "shapes_buffer.h" #include "shapes_extents.h" #include "quadtree_structure.h" #include "shapes_polar_to_cartes.h" #include "shapes_generate.h" #include "shapes_convert_vertex_type.h" #include "LandUse_Scenario.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CShapes_Create_Empty ); case 2: return( new CShapes_Merge ); case 24: return( new CTables_Merge ); case 3: return( new CSelect_Numeric ); case 4: return( new CSelect_String ); case 5: return( new CSelect_Location ); case 6: return( new CSelection_Copy ); case 7: return( new CSelection_Delete ); case 8: return( new CSelection_Invert ); case 9: return( new CSeparateShapes ); case 10: return( new CTransformShapes ); case 11: return( new CCreateChartLayer ); case 12: return( new CGraticuleBuilder ); case 13: return( new CShapes_Cut ); case 14: return( new CShapes_Cut_Interactive ); case 15: return( new CShapes_Split ); case 16: return( new CShapes_Split_Randomly ); case 17: return( new CShapes_Split_by_Attribute ); case 18: return( new CShapes_Buffer ); case 19: return( new CShapes_Extents ); case 20: return( new CQuadTree_Structure ); case 21: return( new CShapes_Polar_to_Cartes ); case 22: return( new CShapes_Generate ); case 23: return( new CShapes_Convert_Vertex_Type ); case 25: return( new CLandUse_Scenario ); case 30: return( NULL ); } return( MLB_INTERFACE_SKIP_MODULE ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/shapes/shapes_tools/NewLayerFromSelectedShapes.cpp0000744000175000017500000001242212737416205027715 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* NewLayerFromSelectedShapes.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "NewLayerFromSelectedShapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelection_Copy::CSelection_Copy(void) { Set_Name (_TL("Copy Selection to New Shapes Layer")); Set_Author (SG_T("Victor Olaya (c) 2004")); Set_Description (_TW( "Copies selected shapes to a new shapes layer." )); Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- bool CSelection_Copy::On_Execute(void) { CSG_Shapes *pInput, *pOutput; pInput = Parameters("INPUT") ->asShapes(); pOutput = Parameters("OUTPUT")->asShapes(); if( pInput->Get_Selection_Count() <= 0 ) { Error_Set(_TL("no shapes in selection")); return( false ); } if( pOutput->Get_Type() != SHAPE_TYPE_Undefined && pOutput->Get_Type() != pInput->Get_Type() && pOutput->Get_Vertex_Type() != pInput->Get_Vertex_Type() ) { Parameters("OUTPUT")->Set_Value(pOutput = SG_Create_Shapes()); } pOutput->Create(pInput->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), _TL("Selection")), pInput, pInput->Get_Vertex_Type()); for(int i=0; iGet_Selection_Count() && Set_Progress(i, pInput->Get_Selection_Count()); i++) { CSG_Shape *pShape = pInput->Get_Selection(i); pOutput->Add_Shape(pShape); if( pInput->Get_Vertex_Type() > SG_VERTEX_TYPE_XY ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pOutput->Get_Shape(i)->Set_Z(pShape->Get_Z(iPoint, iPart), iPoint, iPart); if( pInput->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pOutput->Get_Shape(i)->Set_M(pShape->Get_M(iPoint, iPart), iPoint, iPart); } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelection_Delete::CSelection_Delete(void) { Set_Name (_TL("Delete Selection from Shapes Layer")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Deletes selected shapes from shapes layer." )); Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); } //--------------------------------------------------------- bool CSelection_Delete::On_Execute(void) { CSG_Shapes *pInput; pInput = Parameters("INPUT") ->asShapes(); if( pInput->Get_Selection_Count() <= 0 ) { Error_Set(_TL("no shapes in selection")); return( false ); } pInput->Del_Selection(); DataObject_Update(pInput); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSelection_Invert::CSelection_Invert(void) { Set_Name (_TL("Invert Selection of Shapes Layer")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Deselects selected and selects unselected shapes of given shapes layer." )); Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); } //--------------------------------------------------------- bool CSelection_Invert::On_Execute(void) { CSG_Shapes *pInput; pInput = Parameters("INPUT") ->asShapes(); pInput->Inv_Selection(); DataObject_Update(pInput); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_tools/Shapes_Merge.h0000744000175000017500000000533012737416205024535 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* Shapes_Merge.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Merge_H #define HEADER_INCLUDED__Shapes_Merge_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTables_Merge : public CSG_Module { public: CTables_Merge(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Table|Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Merge : public CTables_Merge { public: CShapes_Merge(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Construction") ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Merge_H saga-2.3.1/src/modules/shapes/shapes_tools/CreateChartLayer.cpp0000744000175000017500000002233412737416205025713 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* CCreateChartLayer.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "CreateChartLayer.h" #include #define TYPE_PIE 0 #define TYPE_BARS 0 #define PI2 6.283185 CCreateChartLayer::CCreateChartLayer(void){ CSG_Parameter *pNode; Parameters.Set_Name(_TL("Create Chart Layer (bars/sectors)")); Parameters.Set_Description(_TW( "(c) 2004 by Victor Olaya. ")); pNode = Parameters.Add_Shapes(NULL, "INPUT", _TL("Shapes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Table_Field(pNode, "SIZE", _TL("Size field"), _TL("")); Parameters.Add_Value(NULL, "MAXSIZE", _TL("Maximum size"), _TL(""), PARAMETER_TYPE_Double, 100, 0, true); Parameters.Add_Value(NULL, "MINSIZE", _TL("Minimum size"), _TL(""), PARAMETER_TYPE_Double, 10, 0, true); Parameters.Add_Choice(NULL, "TYPE", _TL("Type"), _TL(""), _TW("Sectors|" "Bars|"), 0); m_pExtraParameters = Add_Parameters("EXTRA", _TL("Fields for diagram"), _TL("")); }//constructor CCreateChartLayer::~CCreateChartLayer(void) {} bool CCreateChartLayer::On_Execute(void){ CSG_Shapes *pInput; int i=0; int iType; int iSizeField; if (GetExtraParameters()){ iSizeField = Parameters("SIZE")->asInt(); m_fMaxSize = (double) Parameters("MAXSIZE")->asDouble(); m_fMinSize = (double) Parameters("MINSIZE")->asDouble(); if (m_fMinSize > m_fMaxSize){ m_fMinSize = m_fMaxSize; }//if iType = Parameters("TYPE")->asInt(); pInput = Parameters("INPUT")->asShapes(); m_fMaxValue = pInput->Get_Maximum(iSizeField); m_fMinValue = pInput->Get_Minimum(iSizeField); if (iType == TYPE_PIE){ m_pOutput = SG_Create_Shapes(SHAPE_TYPE_Polygon, _TL("Chart (sectors):")); }//if else{ m_pOutput = SG_Create_Shapes(SHAPE_TYPE_Polygon, _TL("Chart (bars):")); }//else m_pOutput->Add_Field(_TL("Field (ID)"), SG_DATATYPE_Int); m_pOutput->Add_Field(_TL("Field (Name)"), SG_DATATYPE_String); for (i = 0; i < pInput->Get_Count(); i++){ if (iType == TYPE_PIE){ // AddPieChart(pInput->Get_Shape(i),m_pOutput->Get_Type()); AddPieChart(pInput->Get_Shape(i),pInput->Get_Type()); }//if else{ // AddBarChart(pInput->Get_Shape(i),m_pOutput->Get_Type()); AddBarChart(pInput->Get_Shape(i),pInput->Get_Type()); }//else }//for DataObject_Add(m_pOutput, false); delete [] m_bIncludeParam; return true; }//if delete [] m_bIncludeParam; return false; }//method bool CCreateChartLayer::GetExtraParameters(){ int i; CSG_Shapes *pInput; CSG_Parameter *pParam; CSG_String sName; bool bIsValidSelection = false; pInput = Parameters("INPUT")->asShapes(); m_pExtraParameters->Create(this, _TL("Fields for diagram"), _TL(""), SG_T("EXTRA")); m_bIncludeParam = new bool [pInput->Get_Field_Count() ]; for (i = 0; i < pInput->Get_Field_Count(); i++) { switch( pInput->Get_Field_Type(i) ) { default: break; case SG_DATATYPE_Byte: case SG_DATATYPE_Char: case SG_DATATYPE_Word: case SG_DATATYPE_Short: case SG_DATATYPE_DWord: case SG_DATATYPE_Int: case SG_DATATYPE_ULong: case SG_DATATYPE_Long: case SG_DATATYPE_Float: case SG_DATATYPE_Double: // is numeric field m_pExtraParameters->Add_Value( NULL, SG_Get_String(i,0).c_str(), pInput->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false ); break; } }//for if(Dlg_Parameters("EXTRA")){ for (i = 0; i < pInput->Get_Field_Count(); i++){ sName = SG_Get_String(i,0); if (pParam = Get_Parameters("EXTRA")->Get_Parameter(sName.c_str())){ m_bIncludeParam[i] = pParam->asBool(); bIsValidSelection = true; }//try else{ m_bIncludeParam[i] = false; }//else }//for m_pExtraParameters->Destroy(); return bIsValidSelection; }//if m_pExtraParameters->Destroy(); return false; }//method void CCreateChartLayer::AddPieChart(CSG_Shape* pShape, int iType){ int i,j; int iSteps; int iSizeField; int iField; double fSum = 0; double fPartialSum = 0; double fSize; double fSectorSize; double dX, dY; CSG_Shape *pSector; CSG_Table_Record *pRecord; TSG_Point Point; iSizeField = Parameters("SIZE")->asInt(); pRecord = pShape; for (i = 0; i < pRecord->Get_Table()->Get_Field_Count(); i++){ if (m_bIncludeParam[i]){ fSum += pRecord->asFloat(i); }//if }//for fSize = pRecord->asFloat(iSizeField); fSize = m_fMinSize + (m_fMaxSize - m_fMinSize)/(m_fMaxValue - m_fMinValue) * (fSize - m_fMinValue); switch (iType){ case SHAPE_TYPE_Polygon: Point = ((CSG_Shape_Polygon*) pShape)->Get_Centroid(); break; case SHAPE_TYPE_Line: Point = GetLineMidPoint((CSG_Shape_Line*)pShape); break; case SHAPE_TYPE_Point: Point = pShape->Get_Point(0); break; default: break; }//switch dX = Point.x; dY = Point.y; fPartialSum = 0; iField = 1; for (i = 0; i < pRecord->Get_Table()->Get_Field_Count(); i++){ if (m_bIncludeParam[i]){ fSectorSize = pRecord->asFloat(i) / fSum; pSector = m_pOutput->Add_Shape(); pSector->Add_Point(dX,dY); iSteps = (int) (fSectorSize * 200.); for (j = 0; j < iSteps; j++){ pSector->Add_Point(dX + fSize * sin((fPartialSum + (double)j / 200.) * PI2), dY + fSize * cos((fPartialSum + (double)j / 200.) * PI2)); }//for fPartialSum +=fSectorSize; pSector->Add_Point(dX + fSize * sin(fPartialSum * PI2), dY + fSize * cos(fPartialSum * PI2)); pSector->Set_Value(0,iField); pSector->Set_Value(1,pRecord->Get_Table()->Get_Field_Name(i)); iField++; }//if }//for }//method void CCreateChartLayer::AddBarChart(CSG_Shape* pShape, int iType){ int i; int iSizeField; int iField; int iValidFields = 0; double fMax; double fMin; double fSize; double fBarHeight, fBarWidth; double dX, dY; CSG_Shape *pSector; CSG_Table_Record *pRecord; TSG_Point Point; iSizeField = Parameters("SIZE")->asInt(); pRecord = pShape; pRecord = pShape; for (i = 0; i < pRecord->Get_Table()->Get_Field_Count(); i++){ if (m_bIncludeParam[i]){ if (!iValidFields){ fMin = fMax = pRecord->asFloat(i); } else{ if (pRecord->asFloat(i) > fMax){ fMax = pRecord->asFloat(i); }//if if (pRecord->asFloat(i) < fMin){ fMin = pRecord->asFloat(i); }//if }//else iValidFields++; }//if }//for if (fMax > 0 && fMin > 0){ fMin = 0; }//if if (fMax < 0 && fMin < 0){ fMax = 0; }//if fSize = pRecord->asFloat(iSizeField); fSize = m_fMinSize + (m_fMaxSize - m_fMinSize)/(m_fMaxValue - m_fMinValue) * (fSize - m_fMinValue); switch (iType){ case SHAPE_TYPE_Polygon: Point = ((CSG_Shape_Polygon*) pShape)->Get_Centroid(); break; case SHAPE_TYPE_Line: Point = GetLineMidPoint((CSG_Shape_Line*)pShape); break; case SHAPE_TYPE_Point: Point = pShape->Get_Point(0); break; default: break; }//switch dX = Point.x; dY = Point.y; fBarWidth = fSize / (double)iValidFields; iField = 1; for (i = 0; i < pRecord->Get_Table()->Get_Field_Count(); i++){ if (m_bIncludeParam[i]){ fBarHeight = pRecord->asFloat(i) / (fMax - fMin) * fSize; pSector = m_pOutput->Add_Shape(); pSector->Add_Point(dX - fSize / 2. + fBarWidth * (iField - 1) , dY); pSector->Add_Point(dX - fSize / 2. + fBarWidth * iField, dY); pSector->Add_Point(dX - fSize / 2. + fBarWidth * iField, dY + fBarHeight); pSector->Add_Point(dX - fSize / 2. + fBarWidth * (iField - 1) , dY + fBarHeight); pSector->Set_Value(0,iField); pSector->Set_Value(1,pRecord->Get_Table()->Get_Field_Name(i)); iField++; }//if }//for }//method TSG_Point CCreateChartLayer::GetLineMidPoint(CSG_Shape_Line *pLine){ int i; double fDist, fAccDist = 0; double fLength = pLine->Get_Length(0) / 2.; TSG_Point Point, Point2, ReturnPoint; for (i = 0; i < pLine->Get_Point_Count(0) - 1; i++){ Point = pLine->Get_Point(i); Point2 = pLine->Get_Point(i+1); fDist = sqrt(pow(Point.x - Point2.x,2.) + pow(Point.y - Point2.y,2.)); if (fAccDist <= fLength && fAccDist + fDist > fLength){ ReturnPoint.x = Point.x + (Point2.x - Point.x) * (fLength - fAccDist) / fDist; ReturnPoint.y = Point.y + (Point2.y - Point.y) * (fLength - fAccDist) / fDist; return ReturnPoint; }//if fAccDist += fDist; }//for return pLine->Get_Point(pLine->Get_Point_Count(0) / 2); }//method saga-2.3.1/src/modules/shapes/shapes_lines/0000775000175000017500000000000012737740006021773 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/shapes/shapes_lines/Lines_From_Polygons.cpp0000744000175000017500000001424612737416202026432 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // Lines_From_Polygons.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Lines_From_Polygons.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLines_From_Polygons::CLines_From_Polygons(void) { Set_Name (_TL("Convert Polygons to Lines")); Set_Author (SG_T("O.Conrad (c) 2005")); Set_Description (_TW( "Convert polygons to lines." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLines_From_Polygons::On_Execute(void) { CSG_Shapes *pLines, *pPolygons; pPolygons = Parameters("POLYGONS") ->asShapes(); pLines = Parameters("LINES") ->asShapes(); //----------------------------------------------------- if( pPolygons->Get_Count() <= 0 ) { Error_Set(_TL("no polygons in input")); return( false ); } //----------------------------------------------------- pLines->Create(SHAPE_TYPE_Line, pPolygons->Get_Name(), pPolygons, pPolygons->Get_Vertex_Type()); for(int iPolygon=0; iPolygonGet_Count(); iPolygon++) { CSG_Shape *pPolygon = pPolygons ->Get_Shape(iPolygon); CSG_Shape *pLine = pLines ->Add_Shape(pPolygon, SHAPE_COPY_ATTR); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pLine->Add_Point(pPolygon->Get_Point(iPoint, iPart), iPart); if( pPolygons->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pLine->Set_Z(pPolygon->Get_Z(iPoint, iPart), iPoint, iPart); if( pPolygons->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pLine->Set_M(pPolygon->Get_M(iPoint, iPart), iPoint, iPart); } } } if( !CSG_Point(pPolygon->Get_Point(0, iPart)).is_Equal(pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart)) ) { pLine->Add_Point(pPolygon->Get_Point(0, iPart), iPart); if( pPolygons->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pLine->Set_Z(pPolygon->Get_Z(0, iPart), pLine->Get_Point_Count(iPart) - 1, iPart); if( pPolygons->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pLine->Set_M(pPolygon->Get_M(0, iPart), pLine->Get_Point_Count(iPart) - 1, iPart); } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_lines/line_simplification.cpp0000744000175000017500000002335112737416203026522 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_simplification.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_simplification.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CStack : public CSG_Stack { public: CStack(void) : CSG_Stack(2 * sizeof(int)) {} bool Push (int iAnchor, int iFloater) { int *Record = (int *)Get_Record_Push(); if( Record ) { Record[0] = iAnchor; Record[1] = iFloater; return( true ); } return( false ); } bool Pop (int &iAnchor, int &iFloater) { int *Record = (int *)Get_Record_Pop(); if( Record ) { iAnchor = Record[0]; iFloater = Record[1]; return( true ); } return( false ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Simplification::CLine_Simplification(void) { //----------------------------------------------------- Set_Name (_TL("Line Simplification")); Set_Author (SG_T("O. Conrad (c) 2010")); Set_Description (_TW( "Line simplification implementing the Ramer-Douglas-Peucker algorithm.\n" "\n" "Refererences:\n" "- Ramer, U. (1972): An iterative procedure for the polygonal approximation of plane curves. Computer Graphics and Image Processing, 1(3), 244-256\n" "- Douglas, D., Peucker, T. (1973): Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. The Canadian Cartographer 10(2), 112-122\n" "\n" "- Polyline Reduction source code at mappinghacks.com\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL("Line or polygon shapefile to simplify."), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Simplified Lines"), _TL("If not set points will be removed from the input data set."), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "TOLERANCE" , _TL("Tolerance"), _TL("Maximum deviation allowed between original and simplified curve [map units]."), PARAMETER_TYPE_Double, 1.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Simplification::On_Execute(void) { CSG_Shapes *pLines = Parameters("LINES")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() <= 0 ) { Error_Set(_TL("invalid or empty shapes layer")); return( false ); } if( pLines->Get_Type() != SHAPE_TYPE_Line && pLines->Get_Type() != SHAPE_TYPE_Polygon ) { Error_Set(_TL("line simplification can only be applied to lines and polygons")); return( false ); } if( Parameters("OUTPUT")->asShapes() && Parameters("OUTPUT")->asShapes() != pLines ) { pLines = Parameters("OUTPUT")->asShapes(); pLines->Create(*Parameters("LINES")->asShapes()); } //----------------------------------------------------- CSG_Array Keep(sizeof(bool)); m_Tolerance = Parameters("TOLERANCE")->asDouble(); int nTotal = 0; int nRemoved = 0; for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { CSG_Shape *pLine = pLines->Get_Shape(iLine); for(int iPart=0; iPartGet_Part_Count(); iPart++) { nTotal += pLine->Get_Point_Count(iPart); Keep.Set_Array(pLine->Get_Point_Count(iPart), false); if( Simplify(pLine, iPart, (bool *)Keep.Get_Array()) ) { for(int iPoint=pLine->Get_Point_Count(iPart)-1; iPoint>=0; iPoint--) { if( !((bool *)Keep.Get_Array())[iPoint] ) { pLine->Del_Point(iPoint, iPart); nRemoved ++; } } } } } Message_Add(CSG_String::Format(SG_T("\n%s: %0.2f%% (%d / %d)"), _TL("Reduction"), 100.0 * nRemoved / (double)nTotal, nRemoved, nTotal), false); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Simplification::Simplify(CSG_Shape *pLine, int iPart, bool *Keep) { int iVertexMax, iVertex, iAnchor, iFloater; double dVertexMax, dVertex, dLength, dProjScalar; TSG_Point Anchor, Floater, Vertex, vAnchor, vVertex; CStack Stack; memset(Keep, 0, sizeof(bool) * pLine->Get_Point_Count(iPart)); Stack.Push(0, pLine->Get_Point_Count(iPart) - 1); while( Stack.Pop(iAnchor, iFloater) && Process_Get_Okay() ) { Anchor = pLine->Get_Point(iAnchor , iPart); Floater = pLine->Get_Point(iFloater, iPart); while( Anchor.x == Floater.x && Anchor.y == Floater.y ) { if( iAnchor >= iFloater - 1 ) { return( false ); } Keep[iFloater--] = iAnchor == 0 && iFloater == pLine->Get_Point_Count(iPart) - 1; Floater = pLine->Get_Point(iFloater, iPart); } vAnchor.x = Floater.x - Anchor.x; vAnchor.y = Floater.y - Anchor.y; dLength = SG_Get_Length(vAnchor.x, vAnchor.y); vAnchor.x = vAnchor.x / dLength; vAnchor.y = vAnchor.y / dLength; for(iVertex=iVertexMax=iAnchor+1, dVertexMax=0.0; iVertexGet_Point(iVertex, iPart); vVertex.x = Vertex.x - Anchor.x; vVertex.y = Vertex.y - Anchor.y; dLength = SG_Get_Length(Vertex.x, Vertex.y); dProjScalar = vVertex.x * vAnchor.x + vVertex.y * vAnchor.y; //dot product: if( dProjScalar < 0.0 ) { dVertex = dLength; } else { vVertex.x = Vertex.x - Floater.x; vVertex.y = Vertex.y - Floater.y; dLength = SG_Get_Length(vVertex.x, vVertex.y); dProjScalar = vVertex.x * (-vAnchor.x) + vVertex.y * (-vAnchor.y); //dot product: if( dProjScalar < 0.0 ) { dVertex = dLength; } else //calculate perpendicular distance to line (pythagorean theorem): { dVertex = sqrt(fabs(dLength*dLength - dProjScalar*dProjScalar)); } } if( dVertexMax < dVertex ) { dVertexMax = dVertex; iVertexMax = iVertex; } } if( dVertexMax <= m_Tolerance ) { Keep[iAnchor] = true; Keep[iFloater] = true; } else { Stack.Push(iAnchor , iVertexMax); Stack.Push(iVertexMax, iFloater ); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_lines/Lines_From_Points.cpp0000744000175000017500000001464412737416202026076 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // Lines_From_Points.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Lines_From_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLines_From_Points::CLines_From_Points(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Convert Points to Line(s)")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "Converts points to line(s)." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "ORDER" , _TL("Order by..."), _TL(""), true ); Parameters.Add_Table_Field( pNode , "SEPARATE" , _TL("Separate by..."), _TL(""), true ); Parameters.Add_Table_Field( pNode , "ELEVATION" , _TL("Elevation"), _TL(""), true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLines_From_Points::On_Execute(void) { int Order, Separate, Elevation; CSG_String s; CSG_Shape *pLine , *pPoint; CSG_Shapes *pLines, *pPoints; pPoints = Parameters("POINTS" )->asShapes(); pLines = Parameters("LINES" )->asShapes(); Order = Parameters("ORDER" )->asInt(); Separate = Parameters("SEPARATE" )->asInt(); Elevation = Parameters("ELEVATION")->asInt(); //------------------------------------------------- if( pPoints->Get_Count() < 1 ) { return( false ); } //------------------------------------------------- pLines->Create(SHAPE_TYPE_Line, pPoints->Get_Name(), NULL, Elevation >= 0 ? SG_VERTEX_TYPE_XYZ : SG_VERTEX_TYPE_XY); pLines->Add_Field(SG_T("ID"), SG_DATATYPE_Int); if( Separate >= 0 ) { pLines->Add_Field(pPoints->Get_Field_Name(Separate), pPoints->Get_Field_Type(Separate)); pPoints->Set_Index(Separate, TABLE_INDEX_Ascending, Order, TABLE_INDEX_Ascending); } else { pPoints->Set_Index(Order, TABLE_INDEX_Ascending); } //------------------------------------------------- int iVertex = 0; for(int iPoint=0; iPointGet_Count(); iPoint++) { pPoint = pPoints->Get_Shape_byIndex(iPoint); if( pLines->Get_Count() == 0 || (Separate >= 0 && s.Cmp(pPoint->asString(Separate))) ) { pLine = pLines->Add_Shape(); iVertex = 0; pLine->Set_Value(0, pLines->Get_Count()); if( Separate >= 0 ) { pLine->Set_Value(1, s = pPoint->asString(Separate)); } } pLine->Add_Point(pPoint->Get_Point(0)); if( Elevation >= 0 ) { pLine->Set_Z(pPoint->asDouble(Elevation), iVertex); iVertex++; } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_lines/line_simplification.h0000744000175000017500000001044612737416203026170 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_simplification.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_simplification_H #define HEADER_INCLUDED__line_simplification_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Simplification : public CSG_Module { public: CLine_Simplification(void); protected: virtual bool On_Execute (void); private: double m_Tolerance; bool Simplify (CSG_Shape *pLine, int iPart, bool *Keep); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_simplification_H saga-2.3.1/src/modules/shapes/shapes_lines/line_polygon_intersection.cpp0000744000175000017500000002143212737416202027762 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_polygon_intersection.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_polygon_intersection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Polygon_Intersection::CLine_Polygon_Intersection(void) { //----------------------------------------------------- Set_Name (_TL("Line-Polygon Intersection")); Set_Author (SG_T("O. Conrad (c) 2010")); Set_Description (_TW( "Line-polygon intersection." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "INTERSECT" , _TL("Intersection"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("one multi-line per polygon"), _TL("keep original line attributes") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Polygon_Intersection::On_Execute(void) { int Method; CSG_Shapes *pLines, *pPolygons, *pNew_Lines, New_Lines; pLines = Parameters("LINES") ->asShapes(); pPolygons = Parameters("POLYGONS") ->asShapes(); pNew_Lines = Parameters("INTERSECT") ->asShapes(); Method = Parameters("METHOD") ->asInt(); if( !pLines ->is_Valid() || pLines ->Get_Count() < 1 || !pPolygons->is_Valid() || pPolygons->Get_Count() < 1 || pLines->Get_Extent().Intersects(pPolygons->Get_Extent()) == INTERSECTION_None ) { Error_Set(_TL("no shapes for intersection found")); return( false ); } //-------------------------------------------------------- switch( Method ) { case 0: pNew_Lines->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pLines->Get_Name(), _TL("Intersection"), pPolygons->Get_Name()), pPolygons ); break; case 1: default: pNew_Lines->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pLines->Get_Name(), _TL("Intersection"), pPolygons->Get_Name()), pLines ); break; } New_Lines.Create(SHAPE_TYPE_Line, NULL, pLines); //-------------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { if( Get_Intersection((CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon), pLines, New_Lines) ) { switch( Method ) { case 0: { CSG_Shape *pNew_Line = pNew_Lines->Add_Shape(pPolygons->Get_Shape(iPolygon), SHAPE_COPY_ATTR); for(int iLine=0, jPart=0; iLineGet_Part_Count(); iPart++, jPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pNew_Line->Add_Point(pLine->Get_Point(iPoint), jPart); } } } } break; case 1: { for(int iLine=0; iLineAdd_Shape(New_Lines.Get_Shape(iLine)); } } break; } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Polygon_Intersection::Get_Intersection(CSG_Shape_Polygon *pPolygon, CSG_Shapes *pLines, CSG_Shapes &New_Lines) { if( !pLines->Select(pPolygon->Get_Extent()) ) { return( false ); } New_Lines.Del_Records(); for(int iSelection=0; iSelectionGet_Selection_Count(); iSelection++) { CSG_Shape *pNew_Line, *pLine = pLines->Get_Selection(iSelection); for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point B, A = pLine->Get_Point(0, iPart); if( pPolygon->Contains(A) ) { pNew_Line = New_Lines.Add_Shape(pLine, SHAPE_COPY_ATTR); pNew_Line ->Add_Point(A); } else { pNew_Line = NULL; } for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { B = A; A = pLine->Get_Point(iPoint, iPart); if( pNew_Line ) { if( pPolygon->Contains(A) ) { pNew_Line ->Add_Point(A); } else { pNew_Line ->Add_Point(Get_Intersection(pPolygon, A, B)); pNew_Line = NULL; } } else if( pPolygon->Contains(A) ) { pNew_Line = New_Lines.Add_Shape(pLine, SHAPE_COPY_ATTR); pNew_Line ->Add_Point(Get_Intersection(pPolygon, A, B)); pNew_Line ->Add_Point(A); } } } } return( New_Lines.Get_Count() > 0 ); } //--------------------------------------------------------- TSG_Point CLine_Polygon_Intersection::Get_Intersection(CSG_Shape_Polygon *pPolygon, const TSG_Point &a, const TSG_Point &b) { TSG_Point c = a; for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point A, B; B = pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { A = B; B = pPolygon->Get_Point(iPoint, iPart); if( SG_Get_Crossing(c, A, B, a, b) ) { return( c ); } } } return( c ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_lines/Lines_From_Points.h0000744000175000017500000001062112737416202025532 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // Lines_From_Points.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Lines_From_Points_H #define HEADER_INCLUDED__Lines_From_Points_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLines_From_Points : public CSG_Module { public: CLines_From_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Lines_From_Points_H saga-2.3.1/src/modules/shapes/shapes_lines/line_properties.h0000744000175000017500000001026712737416203025353 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_properties.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_properties_H #define HEADER_INCLUDED__line_properties_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Properties : public CSG_Module { public: CLine_Properties(void); protected: virtual bool On_Execute(void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_properties_H saga-2.3.1/src/modules/shapes/shapes_lines/line_split_with_lines.cpp0000744000175000017500000002742312737416203027074 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_split_with_lines.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_split_with_lines.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_split_with_lines.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Split_with_Lines::CLine_Split_with_Lines(void) { //----------------------------------------------------- Set_Name (_TL("Split Lines with Lines")); Set_Author (SG_T("O. Conrad (c) 2014")); Set_Description (_TW( "Split Lines with Lines." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "SPLIT" , _TL("Split Features"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "INTERSECT" , _TL("Intersection"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("polylines"), _TL("separate lines") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Split_with_Lines::On_Execute(void) { CSG_Shapes *pLines, *pSplit, *pIntersect; pLines = Parameters("LINES" )->asShapes(); pSplit = Parameters("SPLIT" )->asShapes(); pIntersect = Parameters("INTERSECT")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() < 1 || !pSplit->is_Valid() || pSplit->Get_Count() < 1 || pLines->Get_Extent().Intersects(pSplit->Get_Extent()) == INTERSECTION_None ) { Error_Set(_TL("no lines for splitting")); return( false ); } //-------------------------------------------------------- pIntersect->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pLines->Get_Name(), _TL("Split"), pSplit->Get_Name()), pLines ); //-------------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { CSG_Shape *pLine = pIntersect->Add_Shape(pLines->Get_Shape(iLine), SHAPE_COPY); for(int iSplit=0; iSplitGet_Count(); iSplit++) { CSG_Shape_Line *pSplit_Line = (CSG_Shape_Line *)pSplit->Get_Shape(iSplit); if( pLine->Intersects(pSplit_Line) ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pLine->Intersects(pSplit_Line->Get_Extent()) ) { Get_Intersection(pLine, pSplit_Line->Get_Part(iPart)); } } } } if( Parameters("OUTPUT")->asInt() == 1 ) { while( pLine->Get_Part_Count() > 1 ) { CSG_Shape_Line *pAdd = (CSG_Shape_Line *)pIntersect->Add_Shape(pLine, SHAPE_COPY_ATTR); // only attributes for(int iPoint=0; iPointGet_Point_Count(1); iPoint++) { pAdd->Add_Point(pLine->Get_Point(iPoint, 1)); } pLine->Del_Part(1); } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Split_with_Lines::Get_Intersection(CSG_Shape *pLine, CSG_Shape_Part *pSplit) { CSG_Shapes New(SHAPE_TYPE_Line); CSG_Shape *pNew = New.Add_Shape(); for(int iPart=0, jPart=0; iPartGet_Part_Count(); iPart++, jPart++) { TSG_Point A[2], B[2], C; pNew->Add_Point(A[0] = pLine->Get_Point(0, iPart), jPart); for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { A[1] = A[0]; A[0] = pLine->Get_Point(iPoint, iPart); B[0] = pSplit->Get_Point(0); for(int jPoint=1; jPointGet_Count(); jPoint++) { B[1] = B[0]; B[0] = pSplit->Get_Point(jPoint); if( SG_Get_Crossing(C, A[0], A[1], B[0], B[1], true) ) { pNew->Add_Point(C, jPart++); pNew->Add_Point(C, jPart); } } pNew->Add_Point(A[0], jPart); } } if( pNew->Get_Part_Count() > pLine->Get_Part_Count() ) { return( pLine->Assign(pNew, false) ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Split_at_Points::CLine_Split_at_Points(void) { //----------------------------------------------------- Set_Name (_TL("Split Lines at Points")); Set_Author (SG_T("O. Conrad (c) 2015")); Set_Description (_TW( "Split Lines at Points." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "SPLIT" , _TL("Split Features"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "INTERSECT" , _TL("Intersection"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("polylines"), _TL("separate lines") ), 1 ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Epsilon"), _TL(""), PARAMETER_TYPE_Double, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Split_at_Points::On_Execute(void) { CSG_Shapes *pLines, *pSplit, *pIntersect; pLines = Parameters("LINES" )->asShapes(); pSplit = Parameters("SPLIT" )->asShapes(); pIntersect = Parameters("INTERSECT")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() < 1 || !pSplit->is_Valid() || pSplit->Get_Count() < 1 || pLines->Get_Extent().Intersects(pSplit->Get_Extent()) == INTERSECTION_None ) { Error_Set(_TL("no lines for splitting")); return( false ); } //-------------------------------------------------------- pIntersect->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s: %s]"), pLines->Get_Name(), _TL("Split"), pSplit->Get_Name()), pLines ); double Epsilon = Parameters("EPSILON")->asDouble(); //-------------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { CSG_Shape *pLine = pIntersect->Add_Shape(pLines->Get_Shape(iLine), SHAPE_COPY); CSG_Rect Extent = pLine->Get_Extent(); Extent.Inflate(Epsilon, false); for(int iSplit=0; iSplitGet_Count(); iSplit++) { TSG_Point Point = pSplit->Get_Shape(iSplit)->Get_Point(0); if( Extent.Contains(Point) ) { Get_Intersection(pLine, Point, Epsilon); } } if( Parameters("OUTPUT")->asInt() == 1 ) { while( pLine->Get_Part_Count() > 1 ) { CSG_Shape_Line *pAdd = (CSG_Shape_Line *)pIntersect->Add_Shape(pLine, SHAPE_COPY_ATTR); // only attributes for(int iPoint=0; iPointGet_Point_Count(1); iPoint++) { pAdd->Add_Point(pLine->Get_Point(iPoint, 1)); } pLine->Del_Part(1); } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Split_at_Points::Get_Intersection(CSG_Shape *pLine, TSG_Point Point, double Epsilon) { int min_iPart, min_iPoint; double min_Dist = 1.1 * Epsilon; TSG_Point min_C; for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point C, B, A = pLine->Get_Point(0, iPart); for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { B = A; A = pLine->Get_Point(iPoint, iPart); double Dist = SG_Get_Nearest_Point_On_Line(Point, A, B, C, true); if( Dist < min_Dist ) { min_Dist = Dist; min_C = C; min_iPart = iPart; min_iPoint = iPoint; } } } if( min_Dist <= Epsilon ) { int iPoint; CSG_Shape_Part *pPart = ((CSG_Shape_Line *)pLine)->Get_Part(min_iPart); pLine->Add_Point(min_C, min_iPart = pLine->Get_Part_Count()); for(iPoint=min_iPoint; iPointGet_Count(); iPoint++) { pLine->Add_Point(pPart->Get_Point(iPoint), min_iPart); } for(iPoint=pPart->Get_Count()-1; iPoint>=min_iPoint; iPoint--) { pPart->Del_Point(iPoint); } pPart->Add_Point(min_C); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_lines/line_dissolve.h0000744000175000017500000001051512737416202025002 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_dissolve.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_dissolve_H #define HEADER_INCLUDED__line_dissolve_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Dissolve : public CSG_Module { public: CLine_Dissolve(void); protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool Add_Line (CSG_Shape *pLine, CSG_Shape *pAdd); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_dissolve_H saga-2.3.1/src/modules/shapes/shapes_lines/Makefile.in0000664000175000017500000005727712737447617024076 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/shapes/shapes_lines ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_lines_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_lines_la_OBJECTS = line_dissolve.lo Lines_From_Points.lo \ Lines_From_Polygons.lo line_polygon_intersection.lo \ line_properties.lo line_simplification.lo line_smoothing.lo \ line_split_with_lines.lo MLB_Interface.lo libshapes_lines_la_OBJECTS = $(am_libshapes_lines_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_lines_la_SOURCES) DIST_SOURCES = $(libshapes_lines_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 911 2011-02-14 16:38:15Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_lines.la libshapes_lines_la_SOURCES = \ line_dissolve.cpp\ Lines_From_Points.cpp\ Lines_From_Polygons.cpp\ line_polygon_intersection.cpp\ line_properties.cpp\ line_simplification.cpp\ line_smoothing.cpp\ line_split_with_lines.cpp\ MLB_Interface.cpp\ line_dissolve.h\ Lines_From_Points.h\ Lines_From_Polygons.h\ line_polygon_intersection.h\ line_properties.h\ line_simplification.h\ line_smoothing.h\ line_split_with_lines.h\ MLB_Interface.h libshapes_lines_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/shapes/shapes_lines/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_lines/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_lines.la: $(libshapes_lines_la_OBJECTS) $(libshapes_lines_la_DEPENDENCIES) $(EXTRA_libshapes_lines_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_lines_la_OBJECTS) $(libshapes_lines_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Lines_From_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Lines_From_Polygons.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_dissolve.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_polygon_intersection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_properties.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_simplification.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_smoothing.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line_split_with_lines.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/shapes/shapes_lines/line_polygon_intersection.h0000744000175000017500000001067112737416202027432 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_polygon_intersection.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_polygon_intersection_H #define HEADER_INCLUDED__line_polygon_intersection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Polygon_Intersection : public CSG_Module { public: CLine_Polygon_Intersection(void); protected: virtual bool On_Execute (void); private: bool Get_Intersection (CSG_Shape_Polygon *pPolygon, CSG_Shapes *pLines, CSG_Shapes &New_Lines); TSG_Point Get_Intersection (CSG_Shape_Polygon *pPolygon, const TSG_Point &a, const TSG_Point &b); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_polygon_intersection_H saga-2.3.1/src/modules/shapes/shapes_lines/line_smoothing.cpp0000744000175000017500000005541312737416203025523 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_smoothing.cpp // // // // Copyright (C) 2014 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_smoothing.h" #define MIN_WEIGHT 0.0005 #define EPSILON 1.0e-07 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Smoothing::CLine_Smoothing(void) { //----------------------------------------------------- Set_Name (_TL("Line Smoothing")); Set_Author (SG_T("V. Wichmann, J. Engels (c) 2014")); Set_Description (_TW( "The module provides methods for line smoothing including iterative averaging " "(SIA) and Gaussian filtering.\n\n" "Iterative averaging (SIA) is described by Mansouryar & Hedayati (2012). " "A higher smoothing sensitivity results in a " "stronger smoothing in less iterations and vice versa. The 'improved SIA " "model' simply applies a preservation factor in the first iteration and " "then runs the 'basic SIA model' for the following iterations.\n\n" "Gaussian filtering with shrinkage correction is described by Lowe (1989).\n\n" "In case the density of line vertices is too high, the 'Line Simplification' " "tool can be applied first. If the density of line vertices is too low, " "additional vertices can be inserted by applying the 'Convert Lines to Points' " "and the 'Convert Points to Line(s)' tools prior to smoothing.\n\n" "References:\n" "Lowe, D. (1989): Organization of Smooth Image Curves at Multiple Scales. " "International Journal of Computer Vision, 3: 119-130. " "(pdf)\n\n" "Mansouryar, M. & Hedayati, A. (2012): Smoothing Via Iterative Averaging (SIA) " "- A Basic Technique for Line Smoothing. International Journal of Computer and " "Electrical Engineering Vol. 4, No. 3: 307-311. " "(pdf)\n\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES_IN" , _TL("Lines"), _TL("The input line shapefile to smooth."), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "LINES_OUT" , _TL("Smoothed Lines"), _TL("The smoothed output line shapefile."), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL("Choose the method to apply."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("basic SIA model"), _TL("improved SIA model"), _TL("Gaussian Filtering") ), 2 ); Parameters.Add_Value( NULL , "SENSITIVITY" , _TL("Sensitivity"), _TL("Half the size of the moving window [vertex count], controls smoothing sensitivity."), PARAMETER_TYPE_Int, 3, 1, true ); Parameters.Add_Value( NULL , "ITERATIONS" , _TL("Iterations"), _TL("The number of smoothing iterations [-]."), PARAMETER_TYPE_Int, 10, 1, true ); Parameters.Add_Value( NULL , "PRESERVATION" , _TL("Preservation"), _TL("The smoothing preservation factor [-]."), PARAMETER_TYPE_Double, 10.0, 1.0, true ); Parameters.Add_Value( NULL , "SIGMA" , _TL("Sigma"), _TL("Standard deviation of the Gaussian filter [-]."), PARAMETER_TYPE_Double, 2.0, 0.5, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CLine_Smoothing::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("SENSITIVITY", pParameter->asInt() <= 1); pParameters->Set_Enabled("ITERATIONS", pParameter->asInt() <= 1); pParameters->Set_Enabled("PRESERVATION", pParameter->asInt() == 1); pParameters->Set_Enabled("SIGMA", pParameter->asInt() == 2); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Smoothing::On_Execute(void) { CSG_Shapes *pLines, *pSmooth; int iMethod, iSS, iSI; double dSP, dSigma; bool bResult; pLines = Parameters("LINES_IN")->asShapes(); pSmooth = Parameters("LINES_OUT")->asShapes(); iMethod = Parameters("METHOD")->asInt(); iSS = Parameters("SENSITIVITY")->asInt(); iSI = Parameters("ITERATIONS")->asInt(); dSP = Parameters("PRESERVATION")->asDouble(); dSigma = Parameters("SIGMA")->asDouble(); //-------------------------------------------------------- pSmooth->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s_smoothed"), pLines->Get_Name()), pLines, pLines->Get_Vertex_Type()); if( iMethod <= 1 ) { bResult = Calc_SIA(pLines, pSmooth, iMethod, iSS, iSI, dSP); } else { bResult = Calc_Gaussian(pLines, pSmooth, dSigma); } return( bResult ); } //--------------------------------------------------------- bool CLine_Smoothing::Calc_SIA(CSG_Shapes *pLines, CSG_Shapes *pSmooth, int iMethod, int iSS, int iSI, double dSP) { int iOffset; if( iSS > iSI ) { SG_UI_Msg_Add(_TL("WARNING: smoothing sensitivity is greater than the number of iterations!"), true); } if( iMethod == 1 && iSI < 2 ) { SG_UI_Msg_Add_Error(_TL("The improved SIA model requires more than one smoothing iteration!")); return( false ); } //-------------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { CSG_Shape *pLine = pLines->Get_Shape(iLine); CSG_Shape *pSmoothed = pSmooth->Add_Shape(pLine, SHAPE_COPY_ATTR); //-------------------------------------------------------- for(int iPart=0; iPartGet_Part_Count(); iPart++) { std::vector verticesA(pLine->Get_Point_Count(iPart)); std::vector verticesB(pLine->Get_Point_Count(iPart)); TSG_Point p; for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { p.x = pLine->Get_Point(iPoint, iPart).x; p.y = pLine->Get_Point(iPoint, iPart).y; verticesB.at(iPoint) = p; } //-------------------------------------------------------- for(int i=0; i= (int)verticesA.size() - iSS ) { iOffset = (int)verticesA.size() - 1 - iPoint; } if( iPoint - iOffset < 0 ) // validate lower ... { iOffset = 0; } if( iPoint + iOffset >= verticesA.size() ) // ... and upper limit { iOffset = (int)verticesA.size() - 1 - iPoint; } if( iMethod == 1 && i == 0 ) // improved SIA, apply preservation in first iteration { p.x = (verticesA.at(iPoint - iOffset).x + verticesA.at(iPoint).x + verticesA.at(iPoint + iOffset).x) / 3.0; p.y = (verticesA.at(iPoint - iOffset).y + verticesA.at(iPoint).y + verticesA.at(iPoint + iOffset).y) / 3.0; TSG_Point p_GA; // vector GA (triangle centroid - point) p_GA.x = verticesA.at(iPoint).x - p.x; p_GA.y = verticesA.at(iPoint).y - p.y; double dLength = sqrt(p_GA.x * p_GA.x + p_GA.y * p_GA.y); if( dLength > 0.0 ) { double dScaled = dLength * dSP; // scale by preservation p.x = verticesA.at(iPoint).x + (p_GA.x / dLength) * dScaled; // shift point p.y = verticesA.at(iPoint).y + (p_GA.y / dLength) * dScaled; } else { p = verticesA.at(iPoint); } } else // basic SIA { p.x = (verticesA.at(iPoint - iOffset).x + verticesA.at(iPoint).x + verticesA.at(iPoint + iOffset).x) / 3.0; p.y = (verticesA.at(iPoint - iOffset).y + verticesA.at(iPoint).y + verticesA.at(iPoint + iOffset).y) / 3.0; } verticesB.at(iPoint) = p; } // iPoint } // iIteration //-------------------------------------------------------- for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pSmoothed->Add_Point(verticesB.at(iPoint).x, verticesB.at(iPoint).y, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSmoothed->Set_Z(pLine->Get_Z(iPoint, iPart), iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSmoothed->Set_M(pLine->Get_M(iPoint, iPart), iPoint, iPart); } } } } // iPart } // iLine return( true ); } //--------------------------------------------------------- bool CLine_Smoothing::Calc_Gaussian(CSG_Shapes *pLines, CSG_Shapes *pSmooth, double dSigma) { int half_window_width; bool bClosed; double variance; variance = dSigma * dSigma; double t0d = sqrt (-2.0 * variance * log ( MIN_WEIGHT )); half_window_width = (int) floor (t0d); double nfac = 1.0 / dSigma / sqrt (2.0 * M_PI); if( 2 * half_window_width + 1 < 3 ) { SG_UI_Msg_Add_Error(_TL("The length of the Gaussian window is too small, please provide a larger sigma.")); return( false ); } std::vector gauss_window(2 * half_window_width + 1); std::vector first_deriv_gauss_window(2 * half_window_width + 1); std::vector snd_deriv_gauss_window(2 * half_window_width + 1); std::vector gauss_window_corr(2 * half_window_width + 1); std::vector snd_deriv_gauss_window_corr(2 * half_window_width + 1); double zero_sum_weights = 0.0 ; double snd_sum_weights = 0.0 ; SG_UI_Msg_Add(CSG_String::Format(_TL("Length of the Gaussian window:\t %d"), 2 * half_window_width + 1), true); for (int k=-half_window_width, l=0; k<=half_window_width; k++, l++) { double kd = (double)k; gauss_window [l] = nfac * exp (-kd * kd / (2.0 * variance)); zero_sum_weights += gauss_window [l]; first_deriv_gauss_window [l] = -nfac * kd * exp (-kd * kd / (2.0 * variance)) / variance; snd_deriv_gauss_window [l] = nfac * (kd * kd / variance - 1.0) * exp (-kd * kd / (2.0 * variance)) / variance; snd_sum_weights += snd_deriv_gauss_window [l]; } // The filter kernels have to be corrected because of the discretization // The sum of the elements of the first-derivative-kernel is zero due to antisymmetry for (int k=-half_window_width, l=0; k<=half_window_width; k++, l++) { double kd = (double) k ; gauss_window_corr [l] = gauss_window [l] / zero_sum_weights ; snd_deriv_gauss_window_corr [l] = snd_deriv_gauss_window [l] - snd_sum_weights * gauss_window_corr [l] ; } //-------------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress (iLine, pLines->Get_Count ()); iLine++) { CSG_Shape *pLine = pLines->Get_Shape(iLine); CSG_Shape *pSmoothed = pSmooth->Add_Shape(pLine, SHAPE_COPY_ATTR); //-------------------------------------------------------- for(int iPart=0; iPartGet_Part_Count(); iPart++) { int curve_length = pLine -> Get_Point_Count(iPart); std::vector verticesA (curve_length) ; // the original points std::vector verticesB (curve_length) ; // the intermediate points (after smoothing) std::vector verticesC (curve_length) ; // the points after smoothing and shrinkage correction TSG_Point p; if (pLine->Get_Point(0, iPart).x == pLine->Get_Point(curve_length - 1, iPart).x && pLine->Get_Point(0, iPart).y == pLine->Get_Point(curve_length - 1, iPart).y ) { bClosed = true; curve_length--; } else bClosed = false; double mean_X = 0.0; double mean_Y = 0.0; for(int iPoint=0; iPointGet_Point(iPoint, iPart).x); mean_Y += (pLine->Get_Point(iPoint, iPart).y); } mean_X /= curve_length; mean_Y /= curve_length; for(int iPoint=0; iPointGet_Point(iPoint, iPart).x - mean_X; p.y = pLine->Get_Point(iPoint, iPart).y - mean_Y; verticesA.at(iPoint) = p; } if( curve_length < 2 * half_window_width + 1 ) { SG_UI_Msg_Add(_TL("WARNING: unable to smooth line because Gaussian window too large (number of line vertices too small or sigma too big)."), true); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pSmoothed->Add_Point(pLine->Get_Point(iPoint, iPart).x, pLine->Get_Point(iPoint, iPart).y, iPart); if( pLines->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pSmoothed->Set_Z(pLine->Get_Z(iPoint, iPart), iPoint, iPart); if( pLines->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pSmoothed->Set_M(pLine->Get_M(iPoint, iPart), iPoint, iPart); } } } continue; } for(int iPoint=0; iPoint curve_length - half_window_width - 1) && bClosed == false) { if( iPoint < half_window_width ) loc_hw = iPoint ; else loc_hw = curve_length - 1 - iPoint ; // same story as before, but with different window length std::vector gwloc(2 * loc_hw + 1); std::vector first_deriv_gwloc(2 * loc_hw + 1); std::vector snd_deriv_gwloc(2 * loc_hw + 1); std::vector gwloc_corr(2 * loc_hw + 1); std::vector first_deriv_gwloc_corr(2 * loc_hw + 1); std::vector snd_deriv_gwloc_corr(2 * loc_hw + 1); double zero_sum_loc = 0.0; double snd_sum_loc = 0.0; for(int k=-loc_hw, l=0; k<=loc_hw; k++, l++) { double kd = (double)k; gwloc [l] = nfac * exp (-kd * kd / (2.0 * variance)); first_deriv_gwloc [l] = -kd * nfac * exp (-kd * kd / (2.0 * variance)) / variance; snd_deriv_gwloc [l] = nfac * (kd * kd / variance - 1.0) * exp (-kd * kd / (2.0 * variance)) / variance; zero_sum_loc += gwloc [l]; snd_sum_loc += snd_deriv_gwloc [l]; } // The filter kernels have to be corrected because of the discretization double first_k_sum_loc = 0.0 ; for(int k=-loc_hw, l=0; k<=loc_hw; k++, l++) { double kd = (double)k; gwloc_corr [l] = gwloc [l] / zero_sum_loc; snd_deriv_gwloc_corr [l] = snd_deriv_gwloc [l] - snd_sum_loc * gwloc_corr [l]; // attention: it is convolution not correlation, therefore the minus sign first_k_sum_loc -= kd * first_deriv_gwloc [l]; } double snd_kk_sum_loc = 0.0; for(int k=-loc_hw, l=0; k<=loc_hw; k++, l++) { double kd = (double)k; first_deriv_gwloc_corr [l] = first_deriv_gwloc [l] / first_k_sum_loc; snd_kk_sum_loc += kd * kd * snd_deriv_gwloc_corr [l]; } for(int k=-loc_hw, l=0; k<=loc_hw; k++, l++) { snd_deriv_gwloc_corr [l] *= (2.0 / snd_kk_sum_loc); } std::vector values_red_x(2 * half_window_width + 1); std::vector values_red_y(2 * half_window_width + 1); for(int l=iPoint - loc_hw, k=0; l<=iPoint + loc_hw; k++, l++) { values_red_x [k] = verticesA.at(l).x - mean_loc_x; values_red_y [k] = verticesA.at(l).y - mean_loc_y; } int lstart = iPoint - loc_hw; int lend = iPoint + loc_hw; for(int i=0, l=lstart; l<=lend; i++, l++) { value_x += gwloc_corr [i] * values_red_x [i]; value_y += gwloc_corr [i] * values_red_y [i]; // attention: it is convolution not correlation, and the first-derivative-kernel is antisymmetric first_deriv_x -= first_deriv_gwloc [i] * values_red_x [i]; first_deriv_y -= first_deriv_gwloc [i] * values_red_y [i]; snd_deriv_x += snd_deriv_gwloc_corr [i] * values_red_x [i]; snd_deriv_y += snd_deriv_gwloc_corr [i] * values_red_y [i]; } value_x += mean_loc_x; value_y += mean_loc_y; if( loc_hw <= 3 ) { p.x = value_x; p.y = value_y; verticesB.at(iPoint) = p; verticesC.at(iPoint) = p; continue; } } else // if( (half_window_width <= iPoint && iPoint < curve_length - half_window_width) || bClosed == true ) { std::vector values_red_x(2 * half_window_width + 1); std::vector values_red_y(2 * half_window_width + 1); loc_hw = half_window_width; for(int l=iPoint - half_window_width, k=0; l<=iPoint + half_window_width; k++, l++) { int leff = l; if( l < 0 ) leff = curve_length + l ; else if( l >= curve_length ) leff = l - curve_length ; values_red_x [k] = verticesA.at(leff).x - mean_loc_x; values_red_y [k] = verticesA.at(leff).y - mean_loc_y; } for(int l=iPoint - half_window_width, k=0; l<=iPoint + half_window_width; k++, l++) { value_x += gauss_window [k] * values_red_x [k]; value_y += gauss_window [k] * values_red_y [k]; first_deriv_x -= first_deriv_gauss_window [k] * values_red_x [k]; first_deriv_y -= first_deriv_gauss_window [k] * values_red_y [k]; snd_deriv_x += snd_deriv_gauss_window_corr [k] * values_red_x [k]; snd_deriv_y += snd_deriv_gauss_window_corr [k] * values_red_y [k]; } value_x += mean_loc_x; value_y += mean_loc_y; } double denom = first_deriv_x * first_deriv_x + first_deriv_y * first_deriv_y; if( abs(denom) < EPSILON ) { Error_Set(_TL("First Derivative is singular! Probably the shape containes consecutive identical points.\n\n")); return( false ); } double sqrt_denom = sqrt (denom); double kappa = (first_deriv_x * snd_deriv_y - first_deriv_y * snd_deriv_x) / (denom * sqrt_denom); p.x = value_x; p.y = value_y; verticesB.at(iPoint) = p; if( abs(kappa) < EPSILON ) { verticesC.at(iPoint) = verticesB.at(iPoint); continue; } // Newton's method for the determination of the (original) curvature radius double rsmooth = 1.0 / kappa; double r = rsmooth; for(int k=0; ; k++) { double efunc = exp (- denom * variance / (2.0 * r * r)); double f = r * efunc - rsmooth; double fs = efunc * (1.0 + denom * variance / r / r); if( abs(fs) < EPSILON ) { r = rsmooth; break; } r = r - f / fs; if( k == 5 || abs(f) < EPSILON ) { break; } } first_deriv_x /= sqrt_denom; first_deriv_y /= sqrt_denom; value_x += first_deriv_y * (r - rsmooth); value_y += first_deriv_x * (rsmooth - r); p.x = value_x; p.y = value_y; verticesC.at(iPoint) = p; } // iPoint //-------------------------------------------------------- for(int iPoint = 0 ; iPointAdd_Point(verticesC.at(iPoint).x + mean_X, verticesC.at(iPoint).y + mean_Y, iPart); if( pLines -> Get_Vertex_Type () != SG_VERTEX_TYPE_XY ) { pSmoothed-> Set_Z (pLine->Get_Z (iPoint, iPart), iPoint, iPart); if( pLines -> Get_Vertex_Type () == SG_VERTEX_TYPE_XYZM ) { pSmoothed -> Set_M (pLine -> Get_M (iPoint, iPart), iPoint, iPart); } } } } // iPart } // iLine return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_lines/Makefile.am0000744000175000017500000000161612737416202024030 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 911 2011-02-14 16:38:15Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_lines.la libshapes_lines_la_SOURCES =\ line_dissolve.cpp\ Lines_From_Points.cpp\ Lines_From_Polygons.cpp\ line_polygon_intersection.cpp\ line_properties.cpp\ line_simplification.cpp\ line_smoothing.cpp\ line_split_with_lines.cpp\ MLB_Interface.cpp\ line_dissolve.h\ Lines_From_Points.h\ Lines_From_Polygons.h\ line_polygon_intersection.h\ line_properties.h\ line_simplification.h\ line_smoothing.h\ line_split_with_lines.h\ MLB_Interface.h libshapes_lines_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/shapes/shapes_lines/line_dissolve.cpp0000744000175000017500000002220112737416202025330 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_dissolve.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_dissolve.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_dissolve.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Dissolve::CLine_Dissolve(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Line Dissolve")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Dissolves line shapes, which share the same attribute value(s)." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Table_Field( pNode , "FIELD_1" , _TL("1. Attribute"), _TL(""), false ); Parameters.Add_Table_Field( pNode , "FIELD_2" , _TL("2. Attribute"), _TL(""), true ); Parameters.Add_Table_Field( pNode , "FIELD_3" , _TL("3. Attribute"), _TL(""), true ); Parameters.Add_Shapes( NULL , "DISSOLVED" , _TL("Dissolved Lines"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Choice( NULL , "ALL" , _TL("Dissolve..."), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("lines with same attribute value(s)"), _TL("all lines") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CLine_Dissolve::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("LINES")) && pParameters->Get_Parameter("LINES")->asShapes() != NULL ) { int nFields = pParameters->Get_Parameter("LINES")->asShapes()->Get_Field_Count(); pParameters->Get_Parameter("FIELD_2")->Set_Value(nFields); pParameters->Get_Parameter("FIELD_3")->Set_Value(nFields); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Dissolve::On_Execute(void) { bool bAll; int Field_1, Field_2, Field_3, iLine; CSG_String Value; CSG_Shape *pLine , *pUnion; CSG_Shapes *pLines, *pUnions; //----------------------------------------------------- pLines = Parameters("LINES") ->asShapes(); pUnions = Parameters("DISSOLVED") ->asShapes(); Field_1 = Parameters("FIELD_1") ->asInt(); Field_2 = Parameters("FIELD_2") ->asInt(); Field_3 = Parameters("FIELD_3") ->asInt(); bAll = Parameters("ALL") ->asInt() == 1; //----------------------------------------------------- if( pLines->is_Valid() ) { pUnions->Create(SHAPE_TYPE_Line); //------------------------------------------------- if( bAll || Field_1 >= pLines->Get_Field_Count() ) { pUnions->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pLines->Get_Name(), _TL("Dissolved"))); pUnions->Add_Field(_TL("ID"), SG_DATATYPE_Int); pUnion = pUnions->Add_Shape(); for(iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { Add_Line(pUnion, pLines->Get_Shape(iLine)); } } //------------------------------------------------- else { Value = pLines->Get_Field_Name(Field_1); pUnions ->Add_Field(pLines->Get_Field_Name(Field_1), pLines->Get_Field_Type(Field_1)); if( Field_2 >= 0 ) { Value += CSG_String::Format(SG_T(", %s"), pLines->Get_Field_Name(Field_2)); pUnions ->Add_Field(pLines->Get_Field_Name(Field_2), pLines->Get_Field_Type(Field_2)); } if( Field_3 >= 0 ) { Value += CSG_String::Format(SG_T(", %s"), pLines->Get_Field_Name(Field_3)); pUnions ->Add_Field(pLines->Get_Field_Name(Field_3), pLines->Get_Field_Type(Field_3)); } pLines->Set_Index(Field_1, TABLE_INDEX_Ascending, Field_2, TABLE_INDEX_Ascending, Field_3, TABLE_INDEX_Ascending); pUnions->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pLines->Get_Name(), _TL("Dissolved"), Value.c_str())); for(iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(pLines->Get_Record_byIndex(iLine)->Get_Index()); CSG_String s(pLine->asString(Field_1)); if( Field_2 >= 0 ) s += pLine->asString(Field_2); if( Field_3 >= 0 ) s += pLine->asString(Field_3); if( iLine == 0 || Value.Cmp(s) ) { Value = s; pUnion = pUnions->Add_Shape(pLine, SHAPE_COPY_GEOM); pUnion->Set_Value(0, pLine->asString(Field_1)); if( Field_2 >= 0 ) pUnion->Set_Value(1, pLine->asString(Field_2)); if( Field_3 >= 0 ) pUnion->Set_Value(2, pLine->asString(Field_3)); } else { Add_Line(pUnion, pLine); } } } //------------------------------------------------- return( pUnions->is_Valid() ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Dissolve::Add_Line(CSG_Shape *pLine, CSG_Shape *pAdd) { if( pLine && pAdd ) { int nParts = pLine->Get_Part_Count(); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pAdd->Get_Point_Count(iPart) > 1 ) { int jPart = pLine->Get_Part_Count(); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pLine->Add_Point(pAdd->Get_Point(iPoint, iPart), jPart); } } } return( nParts < pLine->Get_Part_Count() ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_lines/line_smoothing.h0000744000175000017500000001103312737416203025156 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_smoothing.h // // // // Copyright (C) 2014 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_smoothing_H #define HEADER_INCLUDED__line_smoothing_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Smoothing : public CSG_Module { public: CLine_Smoothing(void); protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool Calc_SIA(CSG_Shapes *pLines, CSG_Shapes *pSmooth, int iMethod, int iSS, int iSI, double dSP); bool Calc_Gaussian(CSG_Shapes *pLines, CSG_Shapes *pSmooth, double dSigma); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_smoothing_H saga-2.3.1/src/modules/shapes/shapes_lines/Lines_From_Polygons.h0000744000175000017500000001063312737416202026073 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // Lines_From_Polygons.h // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Lines_From_Polygons_H #define HEADER_INCLUDED__Lines_From_Polygons_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLines_From_Polygons : public CSG_Module { public: CLines_From_Polygons(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Lines_From_Polygons_H saga-2.3.1/src/modules/shapes/shapes_lines/line_split_with_lines.h0000744000175000017500000001142412737416203026533 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: line_split_with_lines.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_split_with_lines.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__line_split_with_lines_H #define HEADER_INCLUDED__line_split_with_lines_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Split_with_Lines : public CSG_Module { public: CLine_Split_with_Lines(void); protected: virtual bool On_Execute (void); private: bool Get_Intersection (CSG_Shape *pLine, CSG_Shape_Part *pSplit); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLine_Split_at_Points : public CSG_Module { public: CLine_Split_at_Points(void); protected: virtual bool On_Execute (void); private: bool Get_Intersection (CSG_Shape *pLine, TSG_Point Point, double Epsilon); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__line_split_with_lines_H saga-2.3.1/src/modules/shapes/shapes_lines/MLB_Interface.h0000744000175000017500000000763712737416202024550 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__shapes_lines_H #define HEADER_INCLUDED__shapes_lines_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef shapes_lines_EXPORTS #define shapes_lines_EXPORT _SAGA_DLL_EXPORT #else #define shapes_lines_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_lines_H saga-2.3.1/src/modules/shapes/shapes_lines/line_properties.cpp0000744000175000017500000001505212737416203025703 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // line_properties.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "line_properties.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLine_Properties::CLine_Properties(void) { //----------------------------------------------------- Set_Name (_TL("Line Properties")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "Line properties: length, number of vertices." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Lines with Property Attributes"), _TL("If not set property attributes will be added to the orignal layer."), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "BPARTS" , _TL("Number of Parts"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BPOINTS" , _TL("Number of Vertices"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BLENGTH" , _TL("Length"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLine_Properties::On_Execute(void) { //------------------------------------------------- int bParts = Parameters("BPARTS") ->asBool() ? 0 : -1; int bPoints = Parameters("BPOINTS") ->asBool() ? 0 : -1; int bLength = Parameters("BLENGTH") ->asBool() ? 0 : -1; if( bParts && bPoints && bLength ) { Error_Set(_TL("no properties selected")); return( false ); } //------------------------------------------------- CSG_Shapes *pLines = Parameters("LINES")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() <= 0 ) { Error_Set(_TL("invalid lines layer")); return( false ); } if( Parameters("OUTPUT")->asShapes() && Parameters("OUTPUT")->asShapes() != pLines ) { pLines = Parameters("OUTPUT")->asShapes(); pLines->Create(*Parameters("LINES")->asShapes()); } //------------------------------------------------- if( !bParts ) { bParts = pLines->Get_Field_Count(); pLines->Add_Field(SG_T("NPARTS") , SG_DATATYPE_Int ); } if( !bPoints ) { bPoints = pLines->Get_Field_Count(); pLines->Add_Field(SG_T("NPOINTS"), SG_DATATYPE_Int ); } if( !bLength ) { bLength = pLines->Get_Field_Count(); pLines->Add_Field(SG_T("LENGTH") , SG_DATATYPE_Double); } //------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pLines->Get_Count()); i++) { CSG_Shape *pLine = pLines->Get_Shape(i); if( bParts >= 0 ) pLine->Set_Value(bParts , pLine->Get_Part_Count()); if( bPoints >= 0 ) pLine->Set_Value(bPoints, pLine->Get_Point_Count()); if( bLength >= 0 ) pLine->Set_Value(bLength, ((CSG_Shape_Line *)pLine)->Get_Length()); } //------------------------------------------------- if( pLines == Parameters("LINES")->asShapes() ) { DataObject_Update(pLines); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_lines/MLB_Interface.cpp0000744000175000017500000001221512737416202025067 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_lines // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Lines") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Wichmann (c) 2005-2014") ); case MLB_INFO_Description: return( _TL("Tools for lines.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Lines") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Lines_From_Polygons.h" #include "Lines_From_Points.h" #include "line_properties.h" #include "line_polygon_intersection.h" #include "line_simplification.h" #include "line_dissolve.h" #include "line_split_with_lines.h" #include "line_smoothing.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CLines_From_Polygons ); case 1: return( new CLines_From_Points ); case 2: return( new CLine_Properties ); case 3: return( new CLine_Polygon_Intersection ); case 4: return( new CLine_Simplification ); case 5: return( new CLine_Dissolve ); case 6: return( new CLine_Split_with_Lines ); case 8: return( new CLine_Split_at_Points ); case 7: return( new CLine_Smoothing ); case 10: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/shapes/shapes_polygons/0000775000175000017500000000000012737740006022533 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.cpp0000744000175000017500000002265612737416204031133 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* CPolygonStatisticsFromPoints.cpp Copyright (C) 2005 Victor Olaya Reworked (C) 2010 Olaf Conrad This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_StatisticsFromPoints.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygonStatisticsFromPoints::CPolygonStatisticsFromPoints(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Point Statistics for Polygons")); Set_Author (SG_T("V. Olaya, O. Conrad (c) 2005, 2010")); Set_Description (_TW( "Calculates statistics over all points falling in a polygon." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL, "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("") ); Parameters.Add_Shapes( NULL, "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL, "STATISTICS" , _TL("Statistics"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value(NULL, "SUM", _TL("Sum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "AVG", _TL("Mean" ), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value(NULL, "VAR", _TL("Variance" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "DEV", _TL("Deviation"), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "MIN", _TL("Minimum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "MAX", _TL("Maximum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(NULL, "NUM", _TL("Count" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Choice( NULL, "FIELD_NAME" , _TL("Field Naming"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("variable type + original name"), _TL("original name + variable type"), _TL("original name"), _TL("variable type") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygonStatisticsFromPoints::On_Execute(void) { //----------------------------------------------------- bool bSum = Parameters("SUM")->asBool(); bool bAvg = Parameters("AVG")->asBool(); bool bVar = Parameters("VAR")->asBool(); bool bDev = Parameters("DEV")->asBool(); bool bMin = Parameters("MIN")->asBool(); bool bMax = Parameters("MAX")->asBool(); bool bNum = Parameters("NUM")->asBool(); if( !bSum && !bAvg && !bVar && !bDev && !bMin && !bMax && !bNum ) { Error_Set(_TL("no target variable in selection")); return( false ); } //----------------------------------------------------- CSG_Parameter_Table_Fields *pFields = Parameters("FIELDS")->asTableFields(); if( pFields->Get_Count() <= 0 ) { Error_Set(_TL("no attributes in selection")); return( false ); } //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS" )->asShapes(); CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( pPolygons->Get_Count() <= 0 || pPoints->Get_Count() <= 0 ) { Error_Set(_TL("no records in input data")); return( false ); } //----------------------------------------------------- if( Parameters("STATISTICS")->asShapes() == NULL ) { Parameters("STATISTICS")->Set_Value(pPolygons); } else if( pPolygons != Parameters("STATISTICS")->asShapes() ) { Parameters("STATISTICS")->asShapes()->Assign(pPolygons); pPolygons = Parameters("STATISTICS")->asShapes(); } //----------------------------------------------------- int i, n, Offset = pPolygons->Get_Field_Count(); for(i=0; iGet_Count(); i++) { CSG_String sName = pPoints->Get_Field_Name(pFields->Get_Index(i)); if( bSum ) { pPolygons->Add_Field(Get_Field_Name("SUM", sName), SG_DATATYPE_Double); } if( bAvg ) { pPolygons->Add_Field(Get_Field_Name("AVG", sName), SG_DATATYPE_Double); } if( bVar ) { pPolygons->Add_Field(Get_Field_Name("VAR", sName), SG_DATATYPE_Double); } if( bDev ) { pPolygons->Add_Field(Get_Field_Name("DEV", sName), SG_DATATYPE_Double); } if( bMin ) { pPolygons->Add_Field(Get_Field_Name("MIN", sName), SG_DATATYPE_Double); } if( bMax ) { pPolygons->Add_Field(Get_Field_Name("MAX", sName), SG_DATATYPE_Double); } if( bNum ) { pPolygons->Add_Field(Get_Field_Name("NUM", sName), SG_DATATYPE_Long ); } } //----------------------------------------------------- CSG_Simple_Statistics *Statistics = new CSG_Simple_Statistics[pFields->Get_Count()]; for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); //------------------------------------------------- for(i=0; iGet_Count(); i++) { Statistics[i].Invalidate(); } //------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Process_Get_Okay(); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); if( pPolygon->Contains(pPoint->Get_Point(0)) ) { for(i=0; iGet_Count(); i++) { if( !pPoint->is_NoData(pFields->Get_Index(i))) { Statistics[i].Add_Value(pPoint->asDouble(pFields->Get_Index(i))); } } } } //------------------------------------------------- for(i=0, n=Offset; iGet_Count(); i++) { if( Statistics[i].Get_Count() > 0 ) { if( bSum ) { pPolygon->Set_Value (n++, Statistics[i].Get_Sum()); } if( bAvg ) { pPolygon->Set_Value (n++, Statistics[i].Get_Mean()); } if( bVar ) { pPolygon->Set_Value (n++, Statistics[i].Get_Variance()); } if( bDev ) { pPolygon->Set_Value (n++, Statistics[i].Get_StdDev()); } if( bMin ) { pPolygon->Set_Value (n++, Statistics[i].Get_Minimum()); } if( bMax ) { pPolygon->Set_Value (n++, Statistics[i].Get_Maximum()); } if( bNum ) { pPolygon->Set_Value (n++, (double)Statistics[i].Get_Count()); } } else { if( bSum ) { pPolygon->Set_NoData(n++); } if( bAvg ) { pPolygon->Set_NoData(n++); } if( bVar ) { pPolygon->Set_NoData(n++); } if( bDev ) { pPolygon->Set_NoData(n++); } if( bMin ) { pPolygon->Set_NoData(n++); } if( bMax ) { pPolygon->Set_NoData(n++); } if( bNum ) { pPolygon->Set_Value (n++, 0.0); } } } } //----------------------------------------------------- delete[](Statistics); DataObject_Update(pPolygons); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CPolygonStatisticsFromPoints::Get_Field_Name(const CSG_String &Type, const CSG_String &Name) { CSG_String s; switch( Parameters("FIELD_NAME")->asInt() ) { default: case 0: s.Printf(SG_T("%s_%s"), Type.c_str(), Name.c_str()); break; case 1: s.Printf(SG_T("%s_%s"), Name.c_str(), Type.c_str()); break; case 2: s.Printf(SG_T("%s" ), Name.c_str() ); break; case 3: s.Printf(SG_T("%s" ), Type.c_str() ); break; } return( s ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_to_edges_nodes.h0000744000175000017500000001105412737416204027434 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_to_edges_nodes.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_to_edges_nodes.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__polygon_to_edges_nodes_H #define HEADER_INCLUDED__polygon_to_edges_nodes_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_to_Edges_Nodes : public CSG_Module { public: CPolygon_to_Edges_Nodes(void); protected: virtual bool On_Execute (void); private: CSG_PRQuadTree m_Vertices, m_Nodes; CSG_Shapes *m_pEdges, *m_pNodes; bool Find_Node (CSG_Shape *pPolygon, int iPart, int &iPoint); bool Trace_Edge (CSG_Shape *pPolygon, int iPart, int iPoint); int Add_Node (TSG_Point &Point, int Edge_ID); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__polygon_to_edges_nodes_H saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_Union.cpp0000744000175000017500000004064112737416204026042 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Union.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Union.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Dissolve::CPolygon_Dissolve(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Polygon Dissolve")); Set_Author ("O.Conrad (c) 2008"); Set_Description (_TW( "Merges polygons, which share the same attribute value, and " "(optionally) dissolves borders between adjacent polygon parts. " "If no attribute or combination of attributes is chosen, all polygons will be merged. " "\nUses the free and open source software library Clipper created by Angus Johnson.\n" "Clipper Homepage\n" "Clipper at SourceForge\n" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field(pNode, "FIELD_1", _TL("1. Attribute"), _TL(""), true); Parameters.Add_Table_Field(pNode, "FIELD_2", _TL("2. Attribute"), _TL(""), true); Parameters.Add_Table_Field(pNode, "FIELD_3", _TL("3. Attribute"), _TL(""), true); Parameters.Add_Shapes( NULL , "DISSOLVED" , _TL("Dissolved Polygons"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "BND_KEEP" , _TL("Keep Boundaries"), _TL(""), PARAMETER_TYPE_Bool, false ); pNode = Parameters.Add_Table_Fields( pNode , "STAT_FIELDS" , _TL("Statistics"), _TL("") ); Parameters.Add_Value(pNode, "STAT_SUM", _TL("Sum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_AVG", _TL("Mean" ), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value(pNode, "STAT_MIN", _TL("Minimum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_MAX", _TL("Maximum" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_RNG", _TL("Range" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_DEV", _TL("Deviation"), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_VAR", _TL("Variance" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_LST", _TL("Listing" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "STAT_NUM", _TL("Count" ), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Choice( pNode, "STAT_NAMING" , _TL("Field Naming"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("variable type + original name"), _TL("original name + variable type"), _TL("original name"), _TL("variable type") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPolygon_Dissolve::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("POLYGONS")) && pParameters->Get_Parameter("POLYGONS")->asShapes() != NULL ) { int nFields = pParameters->Get_Parameter("POLYGONS")->asShapes()->Get_Field_Count(); pParameters->Get_Parameter("FIELD_2")->Set_Value(nFields); pParameters->Get_Parameter("FIELD_3")->Set_Value(nFields); } return( 0 ); } //--------------------------------------------------------- int CPolygon_Dissolve::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FIELD_1")) ) { pParameters->Get_Parameter("FIELD_2")->Set_Enabled(pParameter->asInt() >= 0); pParameters->Get_Parameter("FIELD_3")->Set_Enabled(pParameter->asInt() >= 0 && pParameters->Get_Parameter("FIELD_2")->asInt() >= 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FIELD_2")) ) { pParameters->Get_Parameter("FIELD_3")->Set_Enabled(pParameter->asInt() >= 0 && pParameters->Get_Parameter("FIELD_1")->asInt() >= 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("STAT_FIELDS")) ) { pParameters->Get_Parameter("STAT_SUM")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_AVG")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_MIN")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_MAX")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_RNG")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_DEV")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_VAR")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_LST")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_NUM")->Set_Enabled(pParameter->asInt() > 0); pParameters->Get_Parameter("STAT_NAMING")->Set_Enabled(pParameter->asInt() > 0); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Dissolve::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( !pPolygons->is_Valid() || pPolygons->Get_Count() < 2 ) { Error_Set(_TL("invalid or empty polygons layer")); return( false ); } //----------------------------------------------------- CSG_Shapes *pUnions = Parameters("DISSOLVED")->asShapes(); pUnions->Create(SHAPE_TYPE_Polygon); int Field_1 = Parameters("FIELD_1")->asInt(); int Field_2 = Parameters("FIELD_2")->asInt(); if( Field_1 < 0 ) Field_2 = -1; int Field_3 = Parameters("FIELD_3")->asInt(); if( Field_2 < 0 ) Field_3 = -1; if( Field_1 >= 0 ) { CSG_String s = pPolygons->Get_Field_Name(Field_1); pUnions->Add_Field(pPolygons->Get_Field_Name(Field_1), pPolygons->Get_Field_Type(Field_1)); if( Field_2 >= 0 ) { s += CSG_String(" | ") + pPolygons->Get_Field_Name(Field_2); pUnions->Add_Field(pPolygons->Get_Field_Name(Field_2), pPolygons->Get_Field_Type(Field_2)); if( Field_3 >= 0 ) { s += CSG_String(" | ") + pPolygons->Get_Field_Name(Field_3); pUnions->Add_Field(pPolygons->Get_Field_Name(Field_3), pPolygons->Get_Field_Type(Field_3)); } } pPolygons->Set_Index(Field_1, TABLE_INDEX_Ascending, Field_2, TABLE_INDEX_Ascending, Field_3, TABLE_INDEX_Ascending); pUnions->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pPolygons->Get_Name(), _TL("Dissolved"), s.c_str())); } else // if( Field_1 < 0 ) { pUnions->Set_Name(CSG_String::Format(SG_T("%s [%s: %s]"), pPolygons->Get_Name(), _TL("Dissolved"), _TL("All"))); } Init_Statistics(pUnions, pPolygons); //----------------------------------------------------- CSG_String Value; CSG_Shape *pUnion = NULL; bool bDissolve = Parameters("BND_KEEP")->asBool() == false; //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(pPolygons->Get_Record_byIndex(iPolygon)->Get_Index()); CSG_String s; if( Field_1 >= 0 ) s = pPolygon->asString(Field_1); if( Field_2 >= 0 ) s += pPolygon->asString(Field_2); if( Field_3 >= 0 ) s += pPolygon->asString(Field_3); if( pUnion == NULL || (Field_1 >= 0 && Value.Cmp(s)) ) { Set_Union(pUnion, bDissolve); Value = s; pUnion = pUnions->Add_Shape(pPolygon, SHAPE_COPY_GEOM); if( Field_1 >= 0 ) pUnion->Set_Value(0, pPolygon->asString(Field_1)); if( Field_2 >= 0 ) pUnion->Set_Value(1, pPolygon->asString(Field_2)); if( Field_3 >= 0 ) pUnion->Set_Value(2, pPolygon->asString(Field_3)); Add_Statistics(pUnion, pPolygon, true); } else { for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0, nParts=pUnion->Get_Part_Count(); iPointGet_Point_Count(iPart); iPoint++) { pUnion->Add_Point(pPolygon->Get_Point(iPoint, iPart), nParts); } } Add_Statistics(pUnion, pPolygon, false); } } Set_Union(pUnion, bDissolve); //----------------------------------------------------- if( m_Statistics ) { delete[](m_Statistics); } m_List.Clear(); return( pUnions->is_Valid() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Dissolve::Init_Statistics(CSG_Shapes *pUnions, CSG_Shapes *pPolygons) { m_Stat_pFields = Parameters("STAT_FIELDS")->asTableFields(); m_bSUM = Parameters("STAT_SUM")->asBool(); m_bAVG = Parameters("STAT_AVG")->asBool(); m_bMIN = Parameters("STAT_MIN")->asBool(); m_bMAX = Parameters("STAT_MAX")->asBool(); m_bRNG = Parameters("STAT_RNG")->asBool(); m_bDEV = Parameters("STAT_DEV")->asBool(); m_bVAR = Parameters("STAT_VAR")->asBool(); m_bLST = Parameters("STAT_LST")->asBool(); m_bNUM = Parameters("STAT_NUM")->asBool(); if( m_Stat_pFields->Get_Count() > 0 && (m_bSUM || m_bAVG || m_bMIN || m_bMAX || m_bRNG || m_bDEV || m_bVAR || m_bLST || m_bNUM) ) { m_Statistics = new CSG_Simple_Statistics[m_Stat_pFields->Get_Count()]; m_Stat_Offset = pUnions->Get_Field_Count(); for(int iField=0; iFieldGet_Count(); iField++) { CSG_String s = pPolygons->Get_Field_Name(m_Stat_pFields->Get_Index(iField)); if( m_bSUM ) pUnions->Add_Field(Get_Statistics_Name("SUM", s), SG_DATATYPE_Double); if( m_bAVG ) pUnions->Add_Field(Get_Statistics_Name("AVG", s), SG_DATATYPE_Double); if( m_bMIN ) pUnions->Add_Field(Get_Statistics_Name("MIN", s), SG_DATATYPE_Double); if( m_bMAX ) pUnions->Add_Field(Get_Statistics_Name("MAX", s), SG_DATATYPE_Double); if( m_bRNG ) pUnions->Add_Field(Get_Statistics_Name("RNG", s), SG_DATATYPE_Double); if( m_bDEV ) pUnions->Add_Field(Get_Statistics_Name("STD", s), SG_DATATYPE_Double); if( m_bVAR ) pUnions->Add_Field(Get_Statistics_Name("VAR", s), SG_DATATYPE_Double); if( m_bNUM ) pUnions->Add_Field(Get_Statistics_Name("NUM", s), SG_DATATYPE_Int ); if( m_bLST ) pUnions->Add_Field(Get_Statistics_Name("LST", s), SG_DATATYPE_String); } if( m_bLST ) { m_List.Set_Count(m_Stat_pFields->Get_Count()); } return( true ); } m_Statistics = NULL; if( pUnions->Get_Field_Count() == 0 ) { pUnions->Add_Field("OID", SG_DATATYPE_Int); } return( false ); } //--------------------------------------------------------- CSG_String CPolygon_Dissolve::Get_Statistics_Name(const CSG_String &Type, const CSG_String &Name) { CSG_String s; switch( Parameters("STAT_NAMING")->asInt() ) { default: case 0: s.Printf(SG_T("%s_%s"), Type.c_str(), Name.c_str()); break; case 1: s.Printf(SG_T("%s_%s"), Name.c_str(), Type.c_str()); break; case 2: s.Printf(SG_T("%s" ), Name.c_str() ); break; case 3: s.Printf(SG_T("%s" ), Type.c_str() ); break; } return( s ); } //--------------------------------------------------------- bool CPolygon_Dissolve::Add_Statistics(CSG_Shape *pUnion, CSG_Shape *pPolygon, bool bReset) { if( m_Statistics ) { for(int iField=0; iFieldGet_Count(); iField++) { if( bReset ) { m_Statistics[iField].Create(); if( iField < m_List.Get_Count() ) { m_List[iField].Clear(); } } m_Statistics[iField] += pPolygon->asDouble(m_Stat_pFields->Get_Index(iField)); if( iField < m_List.Get_Count() ) { if( !m_List[iField].is_Empty() ) { m_List[iField] += "|"; } m_List[iField] += pPolygon->asString(m_Stat_pFields->Get_Index(iField)); } } return( true ); } return( false ); } //--------------------------------------------------------- bool CPolygon_Dissolve::Set_Union(CSG_Shape *pUnion, bool bDissolve) { if( !pUnion ) { return( false ); } if( bDissolve ) { SG_Polygon_Dissolve(pUnion); } if( m_Statistics ) { for(int iField=0, jField=m_Stat_Offset; iFieldGet_Count(); iField++) { if( m_bSUM ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Sum ()); if( m_bAVG ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Mean ()); if( m_bMIN ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Minimum ()); if( m_bMAX ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Maximum ()); if( m_bRNG ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Range ()); if( m_bDEV ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_StdDev ()); if( m_bVAR ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Variance()); if( m_bNUM ) pUnion->Set_Value(jField++, m_Statistics[iField].Get_Count ()); if( m_bLST ) pUnion->Set_Value(jField++, m_List [iField]); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_flatten.cpp0000744000175000017500000001646212737416204026453 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_flatten.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygon // // // //-------------------------------------------------------// // // // polygon_flatten.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_flatten.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Flatten::CPolygon_Flatten(void) { //----------------------------------------------------- Set_Name (_TL("Flatten Polygon Layer")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "Removes invalid polygons, i.e. polygons with less than three vertices, " "and merges polygons belonging spatially together, i.e. forming outer " "and inner rings. Inner rings are not preserved as separate polygon, " "but become new part of the polygon forming the outer ring. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Flatten::On_Execute(void) { CSG_Shapes *pShapes = Parameters("INPUT")->asShapes(); if( !pShapes->is_Valid() || pShapes->Get_Count() <= 1 ) { Message_Add(_TL("less than two polygons in layer, nothing to do!")); return( false ); } if( Parameters("OUTPUT")->asShapes() != NULL && pShapes != Parameters("OUTPUT")->asShapes() ) { pShapes = Parameters("OUTPUT")->asShapes(); pShapes->Create(*Parameters("INPUT")->asShapes()); pShapes->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pShapes->Get_Name(), _TL("dissolved inner rings"))); } //----------------------------------------------------- int i, j, k, n; int *Container = (int *)SG_Malloc(pShapes->Get_Count() * sizeof(int)); //----------------------------------------------------- Process_Set_Text(_TL("find inner rings")); for(i=0, n=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { CSG_Shape *pShape = pShapes->Get_Shape(i); if( !pShape->is_Valid() ) { Container[i] = -2; } else { for(j=0, k=-1; k<0 && jGet_Count(); j++) { if( j > i || (j < i && Container[j] != i) ) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pShapes->Get_Shape(j); if( pPolygon->Intersects(pShape) == INTERSECTION_Contains ) { k = j; n ++; } } } Container[i] = k; } } Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("number of inner rings"), n)); if( n == 0 ) { SG_Free(Container); return( true ); } //----------------------------------------------------- Process_Set_Text(_TL("solve inner rings")); for(i=0, n=0; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++) { if( Container[i] >= 0 ) { j = Container[i]; while( Container[j] >= 0 ) { j = Container[j]; } CSG_Shape *pOuter = pShapes->Get_Shape(j); CSG_Shape *pInner = pShapes->Get_Shape(i); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0, jPart=pOuter->Get_Part_Count(); iPointGet_Point_Count(iPart); iPoint++) { pOuter->Add_Point(pInner->Get_Point(iPoint, iPart), jPart); } } pInner->Del_Parts(); // save memory n++; } } //----------------------------------------------------- Process_Set_Text(_TL("clean inner rings")); for(i=0, j=pShapes->Get_Count()-1; iGet_Count() && Set_Progress(i, pShapes->Get_Count()); i++, j--) { if( Container[j] != -1 ) // valid outer ring { pShapes->Del_Shape(j); } } //----------------------------------------------------- SG_Free(Container); if( pShapes == Parameters("INPUT")->asShapes() ) { DataObject_Update(pShapes); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/shape_index.cpp0000744000175000017500000001765412737416204025542 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Polygon // // // //-------------------------------------------------------// // // // Shape_Index.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "shape_index.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShape_Index::CShape_Index(void) { //----------------------------------------------------- Set_Name (_TL("Polygon Shape Indices")); Set_Author (SG_T("(c) 2008 by O.Conrad")); Set_Description (_TW( "Various indices describing the shape of polygons. " "Based on area, perimeter, maximum distance between the vertices of a polygon.\n" "\n" " - Interior Edge Ratio (Perimeter / Area)\n" " - Shape Index (Perimeter / (2 * SquareRoot(PI * Area))\n" "\n" "References:\n" "Lang, S., Blaschke, T. (2007): Landschaftsanalyse mit GIS.\n" "\n" "Forman, R.T.T., Godron, M. (1986): Landscape Ecology. Cambridge.\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "INDEX" , _TL("Shape Index"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); } //--------------------------------------------------------- CShape_Index::~CShape_Index(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShape_Index::On_Execute(void) { CSG_Shapes *pShapes, *pIndex; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); pIndex = Parameters("INDEX") ->asShapes(); //----------------------------------------------------- if( pShapes->is_Valid() ) { int iField = pShapes->Get_Field_Count(); if( pIndex == NULL ) { pIndex = pShapes; } if( pIndex != pShapes ) { pIndex->Create(SHAPE_TYPE_Polygon, _TL("Shape Index"), pShapes); } pIndex->Add_Field(_TL("Area") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("Perimeter") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("P/A") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("P/sqrt(A)") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("Max.Distance") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("D/A") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("D/sqrt(A)") , SG_DATATYPE_Double); pIndex->Add_Field(_TL("Shape Index") , SG_DATATYPE_Double); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape_Polygon *pShape = (CSG_Shape_Polygon *)pShapes->Get_Shape(iShape); double Area = pShape->Get_Area(); double Perimeter = pShape->Get_Perimeter(); double Distance = Get_Distance(pShape); if( Perimeter > 0.0 && Distance > 0.0 ) { if( pIndex != pShapes ) { pShape = (CSG_Shape_Polygon *)pIndex->Add_Shape(pShape, SHAPE_COPY); } pShape->Set_Value(iField + 0, Area); pShape->Set_Value(iField + 1, Perimeter); if (Area > 0.0) { pShape->Set_Value(iField + 2, Perimeter / Area); pShape->Set_Value(iField + 3, Perimeter / sqrt(Area)); } else { pShape->Set_NoData(iField + 2); pShape->Set_NoData(iField + 3); } pShape->Set_Value(iField + 4, Distance); if (Area > 0.0) { pShape->Set_Value(iField + 5, Distance / Area); pShape->Set_Value(iField + 6, Distance / sqrt(Area)); pShape->Set_Value(iField + 7, Perimeter / (2.0 * sqrt(M_PI * Area))); } else { pShape->Set_NoData(iField + 5); pShape->Set_NoData(iField + 6); pShape->Set_NoData(iField + 7); } } } if( pIndex == pShapes ) { DataObject_Update(pShapes); } return( pIndex->is_Valid() ); } //----------------------------------------------------- return( false ); } //--------------------------------------------------------- double CShape_Index::Get_Distance(CSG_Shape *pShape) { double dMax = 0.0; for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pShape->Get_Point_Count(iPart) > 2 ) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point A = pShape->Get_Point(iPoint, iPart); for(int jPoint=iPoint+1; jPointGet_Point_Count(iPart); jPoint++) { double d = SG_Get_Distance(A, pShape->Get_Point(jPoint, iPart)); if( dMax < d ) { dMax = d; } } } } } return( dMax ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_SelfIntersection.h0000744000175000017500000001057612737416204027703 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_SelfIntersection.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_SelfIntersection.h // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_SelfIntersection_H #define HEADER_INCLUDED__Polygon_SelfIntersection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_SelfIntersection : public CSG_Module { public: CPolygon_SelfIntersection(void); protected: virtual bool On_Execute (void); private: CSG_Shapes *m_pIntersect; void Add_Polygon (CSG_Shape *pPolygon, int ID); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_SelfIntersection_H saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_line_intersection.cpp0000744000175000017500000006035712737416204030535 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_line_intersection.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_line_intersection.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_line_intersection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSG_Network_Node { friend class CSG_Network; public: int Get_ID (void) const { return( m_ID ); } const TSG_Point & Get_Point (void) const { return( m_Point ); } int Get_Edge_Count (void) const { return( m_Edges.Get_Count() ); } int Get_Edge (int iEdge) const { return( iEdge >= 0 && iEdge < m_Edges.Get_Count() ? m_Edges[iEdge].asInt(0) : -1 ); } double Get_Direction (int iEdge) const { return( m_Edges[iEdge][1] ); } int Get_Edge_Next (int iEdge, bool bClockwise = true) const { if( Get_Edge_Count() > 1 ) { for(int i=0; iasInt(0) == iEdge ) { i = bClockwise ? i < m_Edges.Get_Count() - 1 ? i + 1 : 0 : i > 0 ? i - 1 : m_Edges.Get_Count() - 1; return( m_Edges.Get_Record_byIndex(i)->asInt(0) ); } } } return( -1 ); } private: int m_ID; TSG_Point m_Point; CSG_Table m_Edges; CSG_Network_Node(int ID, const TSG_Point &Point) { m_ID = ID; m_Point = Point; m_Edges.Add_Field(SG_T("ID") , SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("DIR"), SG_DATATYPE_Double); } bool Add_Edge (int ID, double Direction) { CSG_Table_Record *pEdge = m_Edges.Add_Record(); pEdge->Set_Value(0, ID); pEdge->Set_Value(1, Direction); m_Edges.Set_Index(1, TABLE_INDEX_Ascending); return( true ); } bool Del_Edge (int ID) { int n = 0; for(int i=m_Edges.Get_Count()-1; i>=0; i--) { if( m_Edges[i].asInt(0) == ID ) { m_Edges.Del_Record(i); n++; } } if( n > 0 ) { m_Edges.Set_Index(1, TABLE_INDEX_Ascending); return( true ); } return( false ); } }; //--------------------------------------------------------- class CSG_Network { public: CSG_Network (void); bool Create (void); CSG_Network (CSG_Shapes *pLines); bool Create (CSG_Shapes *pLines); virtual ~CSG_Network (void); bool Destroy (void); const CSG_Shapes & Get_Edges (void) const { return( m_Edges ); } int Get_Node_Count (void) const { return( (int)m_Nodes.Get_Size() ); } CSG_Network_Node & Get_Node (int i) const { return( *((CSG_Network_Node **)m_Nodes.Get_Array())[i] ); } bool Add_Shape (CSG_Shape *pShape); bool Update (void); bool Remove_End_Nodes (void); private: CSG_Array m_Nodes; CSG_Shapes m_Edges; void _On_Construction (void); bool _Add_Line (CSG_Shape *pLine, int ID); int _Add_Node (CSG_PRQuadTree &Search, int Edge_ID, const TSG_Point &Node_Point, const TSG_Point &Dir_Point); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Network::CSG_Network(void) { _On_Construction(); Create(); } bool CSG_Network::Create(void) { Destroy(); return( true ); } //--------------------------------------------------------- CSG_Network::CSG_Network(CSG_Shapes *pLines) { _On_Construction(); Create(pLines); } bool CSG_Network::Create(CSG_Shapes *pLines) { Destroy(); if( !pLines || pLines->Get_Type() != SHAPE_TYPE_Line || !pLines->is_Valid() ) { return( false ); } for(int iLine=0; iLineGet_Count(); iLine++) { Add_Shape(pLines->Get_Shape(iLine)); } return( true ); } //--------------------------------------------------------- CSG_Network::~CSG_Network(void) { Destroy(); } bool CSG_Network::Destroy(void) { for(int i=0; iis_Valid() ) { return( false ); } //----------------------------------------------------- CSG_Shapes Part(SHAPE_TYPE_Line); CSG_Shape *pPart = Part.Add_Shape(); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pShape->Get_Point_Count(iPart) > 1 ) { bool bAscending = pShape->Get_Type() != SHAPE_TYPE_Polygon || ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) != ((CSG_Shape_Polygon *)pShape)->is_Clockwise(iPart); CSG_Point q, p = pShape->Get_Point(0, iPart, bAscending); pPart->Add_Point(p); for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { if( !p.is_Equal(q = pShape->Get_Point(iPoint, iPart, bAscending)) ) { p = q; pPart->Add_Point(p); } } if( pPart->Get_Point_Count(0) > 1 ) { _Add_Line(pPart, pShape->Get_Type()); } pPart->Del_Parts(); } } return( true ); } //--------------------------------------------------------- bool CSG_Network::_Add_Line(CSG_Shape *pLine, int ID) { int iEdge, iPoint, iCrossing; CSG_Shape *pEdge, *pCrossing; CSG_Shapes Crossings(SHAPE_TYPE_Point); //----------------------------------------------------- // 1. find crossings Crossings.Add_Field(SG_T("LINE_POINT") , SG_DATATYPE_Int); Crossings.Add_Field(SG_T("EDGE_ID") , SG_DATATYPE_Int); Crossings.Add_Field(SG_T("EDGE_POINT") , SG_DATATYPE_Int); Crossings.Add_Field(SG_T("EDGE_DIST") , SG_DATATYPE_Double); for(iEdge=0; iEdgeIntersects(pLine) ) { TSG_Point a = pEdge->Get_Point(0); for(int iEdge_Point=1; iEdge_PointGet_Point_Count(0); iEdge_Point++) { TSG_Point b = a; a = pEdge->Get_Point(iEdge_Point); TSG_Point A = pLine->Get_Point(0); for(iPoint=1; iPointGet_Point_Count(0); iPoint++) { TSG_Point C, B = A; A = pLine->Get_Point(iPoint); if( SG_Get_Crossing(C, A, B, a, b) ) { pCrossing = Crossings.Add_Shape(); pCrossing->Add_Point(C); pCrossing->Set_Value(0, iPoint); pCrossing->Set_Value(1, iEdge); pCrossing->Set_Value(2, iEdge_Point); pCrossing->Set_Value(3, SG_Get_Distance(C, b)); } } } } } //----------------------------------------------------- // 2. add new line's vertices Crossings.Set_Index(0, TABLE_INDEX_Ascending); pEdge = m_Edges.Add_Shape(); pEdge ->Set_Value(3, ID); for(iCrossing=0, iPoint=0; iCrossingasInt(0) ) { pEdge->Add_Point(pLine->Get_Point(iPoint++)); } pEdge->Add_Point(pCrossing->Get_Point(0)); pEdge = m_Edges.Add_Shape(); pEdge ->Set_Value(3, ID); pEdge ->Add_Point(pCrossing->Get_Point(0)); } while( iPoint < pLine->Get_Point_Count(0) ) { pEdge->Add_Point(pLine->Get_Point(iPoint++)); } //----------------------------------------------------- // 3. split edges, if necessary Crossings.Set_Index(1, TABLE_INDEX_Descending, 2, TABLE_INDEX_Ascending, 3, TABLE_INDEX_Ascending); for(iCrossing=0; iCrossingasInt(1); pLine = m_Edges.Get_Shape(iEdge); ID = pLine->asInt(0); iPoint = 0; pEdge = m_Edges.Add_Shape(); pEdge ->Set_Value(3, pLine->asInt(3)); while( 1 ) { while( iPoint < pCrossing->asInt(2) ) { pEdge->Add_Point(pLine->Get_Point(iPoint++)); } pEdge->Add_Point(pCrossing->Get_Point(0)); if( ++iCrossing < Crossings.Get_Count() && iEdge == Crossings.Get_Shape_byIndex(iCrossing)->asInt(1) ) { pEdge = m_Edges.Add_Shape(); pEdge ->Set_Value(3, pLine->asInt(3)); pEdge->Add_Point(pCrossing->Get_Point(0)); pCrossing = Crossings.Get_Shape_byIndex(iCrossing); } else { if( iPoint < pLine->Get_Point_Count() ) { pEdge = m_Edges.Add_Shape(); pEdge ->Set_Value(3, pLine->asInt(3)); pEdge->Add_Point(pCrossing->Get_Point(0)); while( iPoint < pLine->Get_Point_Count() ) { pEdge->Add_Point(pLine->Get_Point(iPoint++)); } } break; } } m_Edges.Del_Shape(iEdge); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Network::Update(void) { int iEdge; //----------------------------------------------------- for(iEdge=m_Edges.Get_Count()-1; iEdge>=0; iEdge--) { CSG_Shape *pEdge = m_Edges.Get_Shape(iEdge); if( !(((CSG_Shape_Line *)pEdge)->Get_Length() > 0.0) ) { m_Edges.Del_Shape(iEdge); } } //----------------------------------------------------- for(int i=0; iSet_Value(0, iEdge); pEdge->Set_Value(1, _Add_Node(Search, iEdge, pEdge->Get_Point(0), pEdge->Get_Point(1) )); pEdge->Set_Value(2, _Add_Node(Search, iEdge, pEdge->Get_Point(pEdge->Get_Point_Count(0) - 1), pEdge->Get_Point(pEdge->Get_Point_Count(0) - 2) )); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- int CSG_Network::_Add_Node(CSG_PRQuadTree &Search, int Edge_ID, const TSG_Point &Node_Point, const TSG_Point &Dir_Point) { int Node_ID; double Distance; CSG_PRQuadTree_Leaf *pLeaf = Search.Get_Nearest_Leaf(Node_Point, Distance); if( !pLeaf || Distance > 0.0 )//00001 ) { Node_ID = Get_Node_Count(); m_Nodes.Inc_Array(); ((CSG_Network_Node **)m_Nodes.Get_Array())[Node_ID] = new CSG_Network_Node(Node_ID, Node_Point); Search.Add_Point(Node_Point.x, Node_Point.y, Node_ID); } else { Node_ID = (int)pLeaf->Get_Z(); } Get_Node(Node_ID).Add_Edge(Edge_ID, SG_Get_Angle_Of_Direction(Node_Point, Dir_Point)); return( Node_ID ); } //--------------------------------------------------------- bool CSG_Network::Remove_End_Nodes(void) { int iEdge, n; //----------------------------------------------------- for(iEdge=0; iEdgeasInt(3) == SHAPE_TYPE_Line ) { bool bRemove = false; for(int iNode=1; iNode<=2 && !bRemove; iNode++) { CSG_Network_Node &Node = Get_Node(pEdge->asInt(iNode)); CSG_Point Point = Node.Get_Point(); CSG_Shape *pNext; if( ( (pNext = m_Edges.Get_Shape(Node.Get_Edge_Next(pEdge->asInt(0), true))) != NULL && pNext->asInt(3) == SHAPE_TYPE_Polygon && !Point.is_Equal(pNext->Get_Point(0, 0, false)) ) || ( (pNext = m_Edges.Get_Shape(Node.Get_Edge_Next(pEdge->asInt(0), false))) != NULL && pNext->asInt(3) == SHAPE_TYPE_Polygon && !Point.is_Equal(pNext->Get_Point(0, 0, true)) ) ) { bRemove = true; } } if( bRemove ) { Get_Node(pEdge->asInt(1)).Del_Edge(pEdge->asInt(0)); Get_Node(pEdge->asInt(2)).Del_Edge(pEdge->asInt(0)); pEdge->Set_Value(4, 1); } } } //----------------------------------------------------- do { for(n=0, iEdge=0; iEdgeasInt(3) == SHAPE_TYPE_Line && pEdge->asInt(4) == 0 ) { if( Get_Node(pEdge->asInt(1)).Get_Edge_Count() <= 1 || Get_Node(pEdge->asInt(2)).Get_Edge_Count() <= 1 ) { Get_Node(pEdge->asInt(1)).Del_Edge(pEdge->asInt(0)); Get_Node(pEdge->asInt(2)).Del_Edge(pEdge->asInt(0)); pEdge->Set_Value(4, 1); n++; } } } } while( n > 0 ); //----------------------------------------------------- for(iEdge=m_Edges.Get_Count()-1; iEdge>=0; iEdge--) { if( m_Edges[iEdge][4] ) { m_Edges.Del_Shape(iEdge); } } //----------------------------------------------------- return( Update() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Line_Intersection::CPolygon_Line_Intersection(void) { //----------------------------------------------------- Set_Name (_TL("Polygon-Line Intersection")); Set_Author (SG_T("O. Conrad (c) 2011")); Set_Description (_TW( "Polygon-line intersection. Splits polygons with lines. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "INTERSECT" , _TL("Intersection"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Line_Intersection::On_Execute(void) { CSG_Shapes *pPolygons; //-------------------------------------------------------- pPolygons = Parameters("POLYGONS") ->asShapes(); m_pLines = Parameters("LINES") ->asShapes(); m_pIntersection = Parameters("INTERSECT") ->asShapes(); //-------------------------------------------------------- if( !m_pLines ->is_Valid() || m_pLines ->Get_Count() < 1 || !pPolygons->is_Valid() || pPolygons->Get_Count() < 1 || m_pLines->Get_Extent().Intersects(pPolygons->Get_Extent()) == INTERSECTION_None ) { Error_Set(_TL("no shapes for intersection found")); return( false ); } //-------------------------------------------------------- m_pIntersection->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s: %s]"), pPolygons->Get_Name(), _TL("Intersection"), m_pLines->Get_Name()), pPolygons ); //-------------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { if( !Get_Intersection((CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon)) ) { m_pIntersection->Add_Shape(pPolygons->Get_Shape(iPolygon)); } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool Trace_Polygon(CSG_Shape *pPolygon, CSG_Network &Network, int iEdge) { bool bAscending = true; CSG_Shape *pEdge = Network.Get_Edges().Get_Shape(iEdge); if( pEdge->asInt(3) == SHAPE_TYPE_Polygon ) { if( pEdge->asInt(4) ) { return( false ); } bAscending = true; } else if( (pEdge->asInt(4) & 0x1) == 0 ) { bAscending = true; } else if( (pEdge->asInt(4) & 0x2) == 0 ) { bAscending = false; } else { return( false ); } while( pEdge != NULL ) { pEdge->Set_Value(4, pEdge->asInt(4) | (bAscending ? 0x1 : 0x2)); for(int iPoint=0; iPointGet_Point_Count(0); iPoint++) { pPolygon->Add_Point(pEdge->Get_Point(iPoint, 0, bAscending)); } int End_Node = pEdge->asInt(bAscending ? 2 : 1); iEdge = Network.Get_Node(End_Node).Get_Edge_Next(iEdge, false); pEdge = Network.Get_Edges().Get_Shape(iEdge); if( pEdge ) { bAscending = pEdge->asInt(3) == SHAPE_TYPE_Polygon || End_Node == pEdge->asInt(1); if( (pEdge->asInt(4) & (bAscending ? 0x1 : 0x2)) ) { pEdge = NULL; } } } return( pPolygon->is_Valid() ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Line_Intersection::Get_Intersection(CSG_Shape_Polygon *pPolygon) { CSG_Network Network; for(int iLine=0; iLineGet_Count(); iLine++) { CSG_Shape *pLine = m_pLines->Get_Shape(iLine); if( pLine->Intersects(pPolygon) ) { Network.Add_Shape(pLine); } } if( Network.Get_Edges().Get_Count() == 0 ) { return( false ); } Network.Add_Shape(pPolygon); Network.Update(); Network.Remove_End_Nodes(); //----------------------------------------------------- int iEdge, iPolygon; CSG_Shapes Intersection(SHAPE_TYPE_Polygon); Intersection.Add_Field(SG_T("ID"), SG_DATATYPE_Int); for(iEdge=0; iEdgeasInt(3) == SHAPE_TYPE_Polygon ) { Trace_Polygon(Intersection.Add_Shape(), Network, iEdge); } else if( pPolygon->Contains(pEdge->Get_Point(0)) && pPolygon->Contains(pEdge->Get_Point(pEdge->Get_Point_Count(0) - 1)) ) { Trace_Polygon(Intersection.Add_Shape(), Network, iEdge); Trace_Polygon(Intersection.Add_Shape(), Network, iEdge); } } //----------------------------------------------------- for(iPolygon=0; iPolygonGet_Point_Count() > 0 && ((CSG_Shape_Polygon *)pIntersect)->is_Clockwise(0) == true ) { pIntersect->Set_Value(0, m_pIntersection->Get_Count()); ((CSG_Table_Record *)m_pIntersection->Add_Shape(pIntersect, SHAPE_COPY_GEOM))->Assign(pPolygon); } } for(iPolygon=0; iPolygonGet_Point_Count() > 0 && ((CSG_Shape_Polygon *)pIntersect)->is_Clockwise(0) == false ) { for(int j=0; jContains(pIntersect->Get_Point(0)) ) { CSG_Shape *pShape = m_pIntersection->Get_Shape(Intersection[j].asInt(0)); for(int iPoint=0, iPart=pShape->Get_Part_Count(); iPointGet_Point_Count(0); iPoint++) { pShape->Add_Point(pIntersect->Get_Point(iPoint), iPart); } break; } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// /*/--------------------------------------------------------- { //----------------------------------------------------- CSG_Shapes p(SHAPE_TYPE_Point); p.Add_Field(SG_T("ID") , SG_DATATYPE_Int); p.Add_Field(SG_T("COUNT"), SG_DATATYPE_Int); for(int i=0; iAdd_Point(Network.Get_Node(i).Get_Point()); pNode->Set_Value(0, Network.Get_Node(i).Get_ID()); pNode->Set_Value(1, Network.Get_Node(i).Get_Edge_Count()); } DataObject_Add(SG_Create_Shapes(p)); DataObject_Add(SG_Create_Shapes(Network.Get_Edges())); //----------------------------------------------------- CSG_Shapes l(SHAPE_TYPE_Line); l.Add_Field(SG_T("ID") , SG_DATATYPE_Int); l.Add_Field(SG_T("COUNT"), SG_DATATYPE_Int); l.Add_Field(SG_T("EDGE") , SG_DATATYPE_Int); l.Add_Field(SG_T("DIR") , SG_DATATYPE_Double); l.Add_Field(SG_T("ORDER"), SG_DATATYPE_Int); for(int i=0; iSet_Value(0, Network.Get_Node(i).Get_ID()); pNode->Set_Value(1, Network.Get_Node(i).Get_Edge_Count()); pNode->Set_Value(2, Network.Get_Node(i).Get_Edge(j)); pNode->Set_Value(3, Network.Get_Node(i).Get_Direction(j) * M_RAD_TO_DEG); pNode->Set_Value(4, j); pNode->Add_Point(P); pNode->Add_Point( P.x + 10.0 * sin(Network.Get_Node(i).Get_Direction(j)), P.y + 10.0 * cos(Network.Get_Node(i).Get_Direction(j)) ); } } //----------------------------------------------------- CSG_Shapes p(SHAPE_TYPE_Point); p.Add_Field(SG_T("COUNT"), SG_DATATYPE_Int); for(int i=0; iAdd_Point(Network.Get_Node(i).Get_Point()); pNode->Set_Value(0, Network.Get_Node(i).Get_Edge_Count()); } DataObject_Add(SG_Create_Shapes(p)); }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_SelfIntersection.cpp0000744000175000017500000001745712737416204030243 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_SelfIntersection.cpp 1230 2011-11-22 11:12:10Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_SelfIntersection.cpp // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_SelfIntersection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_SelfIntersection::CPolygon_SelfIntersection(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Polygon Self-Intersection")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Self-intersection of one layer's polygons.\n" "Uses the free and open source software library Clipper created by Angus Johnson.\n" "Clipper Homepage\n" "Clipper at SourceForge\n" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field( pNode , "ID" , _TL("Identifier"), _TL(""), true ); Parameters.Add_Shapes( NULL , "INTERSECT" , _TL("Intersection"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_SelfIntersection::On_Execute(void) { int ID; CSG_Shapes *pPolygons, Intersect; pPolygons = Parameters("POLYGONS" )->asShapes(); m_pIntersect = Parameters("INTERSECT")->asShapes() ? Parameters("INTERSECT")->asShapes() : &Intersect; ID = Parameters("ID")->asInt(); if( ID >= pPolygons->Get_Field_Count() ) { ID = -1; } m_pIntersect->Create(SHAPE_TYPE_Polygon, pPolygons->Get_Name(), pPolygons); m_pIntersect->Add_Field("ID", SG_DATATYPE_String); //----------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pPolygons->Get_Count()); i++) { Add_Polygon(pPolygons->Get_Shape(i), ID); } //----------------------------------------------------- if( m_pIntersect->Get_Count() != pPolygons->Get_Count() ) { Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("number of added polygons"), m_pIntersect->Get_Count() - pPolygons->Get_Count())); if( m_pIntersect == &Intersect ) { pPolygons->Create(Intersect); DataObject_Update(pPolygons); } else { m_pIntersect->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("self-intersection"))); } } else { Message_Add(_TL("no self-intersecting polygons detected")); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPolygon_SelfIntersection::Add_Polygon(CSG_Shape *pPolygon, int ID) { CSG_String sID; if( ID >= 0 ) { sID = pPolygon->asString(ID); } else { sID = SG_Get_String(pPolygon->Get_Index() + 1, 0); } ID = m_pIntersect->Get_Field_Count() - 1; //----------------------------------------------------- if( !m_pIntersect->Select(pPolygon->Get_Extent()) ) { pPolygon = m_pIntersect->Add_Shape(pPolygon); pPolygon ->Set_Value(ID, sID); return; } //----------------------------------------------------- CSG_Shapes Intersect(m_pIntersect->Get_Type(), SG_T(""), m_pIntersect); int nIntersects = m_pIntersect->Get_Count(); pPolygon = m_pIntersect->Add_Shape(pPolygon); pPolygon ->Set_Value(ID, sID); for(int i=0; iis_Valid(); i++) { if( pPolygon != m_pIntersect->Get_Shape(i) && pPolygon->Intersects(m_pIntersect->Get_Shape(i)) ) { CSG_Shape *pOriginal = Intersect.Add_Shape(m_pIntersect->Get_Shape(i)); CSG_Shape *pIntersect = Intersect.Add_Shape(); if( SG_Polygon_Intersection(pOriginal, pPolygon, pIntersect) ) { pIntersect = m_pIntersect->Add_Shape(pIntersect); pIntersect ->Set_Value(ID, CSG_String::Format(SG_T("%s|%s"), pPolygon->asString(ID), pOriginal->asString(ID))); SG_Polygon_Difference(m_pIntersect->Get_Shape(i), pPolygon); SG_Polygon_Difference(pPolygon, pOriginal); } Intersect.Del_Shapes(); } } m_pIntersect->Select(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_Centroids.cpp0000744000175000017500000001406112737416204026701 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Centroids.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Centroids.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Centroids::CPolygon_Centroids(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Polygon Centroids")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Creates a points layer containing the centroids of the input polygon layer." )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "CENTROIDS" , _TL("Centroids"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); //----------------------------------------------------- pNode = Parameters.Add_Value( NULL , "METHOD" , _TL("Centroids for each part"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- } //--------------------------------------------------------- CPolygon_Centroids::~CPolygon_Centroids(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Centroids::On_Execute(void) { bool bPart; int iShape, iPart; CSG_Shape *pCentroid; CSG_Shape_Polygon *pPolygon; CSG_Shapes *pPolygons, *pCentroids; pPolygons = Parameters("POLYGONS") ->asShapes(); pCentroids = Parameters("CENTROIDS") ->asShapes(); bPart = Parameters("METHOD") ->asBool(); if( pPolygons->Get_Type() == SHAPE_TYPE_Polygon && pPolygons->Get_Count() > 0 ) { pCentroids->Create(SHAPE_TYPE_Point, pPolygons->Get_Name(), pPolygons); //------------------------------------------------- for(iShape=0; iShapeGet_Count(); iShape++) { pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iShape); if( bPart ) { for(iPart=0; iPartGet_Part_Count(); iPart++) { pCentroid = pCentroids->Add_Shape(pPolygon, SHAPE_COPY_ATTR); pCentroid->Add_Point(pPolygon->Get_Centroid(iPart)); } } else { pCentroid = pCentroids->Add_Shape(pPolygon, SHAPE_COPY_ATTR); pCentroid->Add_Point(pPolygon->Get_Centroid()); } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_line_intersection.h0000744000175000017500000001062512737416204030173 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_line_intersection.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_line_intersection.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__polygon_line_intersection_H #define HEADER_INCLUDED__polygon_line_intersection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Line_Intersection : public CSG_Module { public: CPolygon_Line_Intersection(void); protected: virtual bool On_Execute (void); private: CSG_Shapes *m_pLines, *m_pIntersection; bool Get_Intersection (CSG_Shape_Polygon *pPolygon); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__polygon_line_intersection_H saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_Clip.h0000744000175000017500000001150712737416204025305 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Clip.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Clip.h // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Clip_H #define HEADER_INCLUDED__Polygon_Clip_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Clip : public CSG_Module { public: CPolygon_Clip(void); protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool Clip_Shapes (CSG_Shapes *pClip, CSG_Shapes *pInput, CSG_Shapes *pOutput); void Clip_Points (CSG_Shapes *pClip, CSG_Shapes *pInput, CSG_Shapes *pOutput); void Clip_Lines (CSG_Shapes *pClip, CSG_Shapes *pInput, CSG_Shapes *pOutput); void Clip_Polygons (CSG_Shapes *pClip, CSG_Shapes *pInput, CSG_Shapes *pOutput); TSG_Point Get_Crossing (CSG_Shape_Polygon *pPolygon, const TSG_Point &a, const TSG_Point &b); bool Dissolve (CSG_Shapes *pPolygons, CSG_Shapes *pOutput); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Clip_H saga-2.3.1/src/modules/shapes/shapes_polygons/Polygons_From_Lines.h0000744000175000017500000001130212737416204026627 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygons_From_Lines.h // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygons_From_Lines_H #define HEADER_INCLUDED__Polygons_From_Lines_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygons_From_Lines : public CSG_Module { public: CPolygons_From_Lines(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); private: bool Add_Part (CSG_Shape *pPolygon, CSG_Shape *pLine, int iPart_Polygon, int iPart_Line, bool bAscending = true); bool Add_Line (CSG_Shape *pPolygon, CSG_Shape *pLine, int iPart_Polygon = 0); bool Get_Part (CSG_Point Point, CSG_Shape *pLine, int &iPart, bool &bAscending); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygons_From_Lines_H saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_shared_edges.h0000744000175000017500000001413112737416204027067 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_shared_edges.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_shared_edges.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__polygon_shared_edges_H #define HEADER_INCLUDED__polygon_shared_edges_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Shared_Edges : public CSG_Module { public: ////// public members and functions: ////////////// CPolygon_Shared_Edges(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("Landsat") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute (void); private: ///// private members and functions: ///////////// bool m_bDouble; int m_Field; CSG_Shapes *m_pEdges, *m_pNodes; bool Get_Shared_Edges (CSG_Shape_Part *pA, CSG_Shape_Part *pB, double Epsilon); int Get_Next_Vertex (CSG_Shape_Part *pPoints, int iPoint, bool bAscending); int Check_Vertices (CSG_Shape_Part *pPolygon, CSG_Shape_Part *pVertices, double Epsilon); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Vertex_Check : public CSG_Module { public: ////// public members and functions: ////////////// CPolygon_Vertex_Check(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("Landsat") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute (void); private: ///// private members and functions: ///////////// CSG_Shapes *m_pAdded; bool Check_Vertices (CSG_Shape_Part *pPolygon, CSG_Shape_Part *pVertices, double Epsilon); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__polygon_shared_edges_H saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_Clip.cpp0000744000175000017500000003127312737416204025642 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Polygon_Clip.cpp 1230 2011-11-22 11:12:10Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Clip.cpp // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Clip.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Clip::CPolygon_Clip(void) { //----------------------------------------------------- Set_Name (_TL("Polygon Clipping")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Clipping of vector layers with a polygon layer.\n" "Uses the free and open source software library Clipper created by Angus Johnson.\n" "Clipper Homepage\n" "Clipper at SourceForge\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "CLIP" , _TL("Clip Features"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "S_INPUT" , _TL("Input Features"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "S_OUTPUT" , _TL("Output Features"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes_List( NULL , "M_INPUT" , _TL("Input Features"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes_List( NULL , "M_OUTPUT" , _TL("Output Features"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "DISSOLVE" , _TL("Dissolve Clip Features"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "MULTIPLE" , _TL("Multiple Input Features"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPolygon_Clip::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("MULTIPLE")) ) { pParameters->Get_Parameter("S_INPUT" )->Set_Enabled(pParameter->asBool() == false); pParameters->Get_Parameter("S_OUTPUT")->Set_Enabled(pParameter->asBool() == false); pParameters->Get_Parameter("M_INPUT" )->Set_Enabled(pParameter->asBool() == true); pParameters->Get_Parameter("M_OUTPUT")->Set_Enabled(pParameter->asBool() == true); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Clip::On_Execute(void) { CSG_Shapes Clip, *pClip = Parameters("CLIP")->asShapes(); if( Parameters("DISSOLVE")->asBool() && Dissolve(pClip, &Clip) ) { pClip = &Clip; } //----------------------------------------------------- if( !Parameters("MULTIPLE")->asBool() ) // single input mode { return( Clip_Shapes(pClip, Parameters("S_INPUT" )->asShapes(), Parameters("S_OUTPUT")->asShapes() )); } //----------------------------------------------------- else // multiple input mode { CSG_Parameter_Shapes_List *pInput = Parameters("M_INPUT" )->asShapesList(); CSG_Parameter_Shapes_List *pOutput = Parameters("M_OUTPUT")->asShapesList(); pOutput->Del_Items(); for(int i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Shapes *pShapes = SG_Create_Shapes(); if( Clip_Shapes(pClip, pInput->asShapes(i), pShapes) ) { pOutput->Add_Item(pShapes); } else { delete(pShapes); } } return( pOutput->Get_Count() > 0 ); } } //--------------------------------------------------------- bool CPolygon_Clip::Clip_Shapes(CSG_Shapes *pClip, CSG_Shapes *pInput, CSG_Shapes *pOutput) { pOutput->Create(pInput->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pInput->Get_Name(), _TL("clipped")), pInput); switch( pInput->Get_Type() ) { case SHAPE_TYPE_Point: Clip_Points (pClip, pInput, pOutput); break; case SHAPE_TYPE_Points: Clip_Points (pClip, pInput, pOutput); break; case SHAPE_TYPE_Line: Clip_Lines (pClip, pInput, pOutput); break; case SHAPE_TYPE_Polygon: Clip_Polygons(pClip, pInput, pOutput); break; } return( pOutput->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPolygon_Clip::Clip_Points(CSG_Shapes *pClips, CSG_Shapes *pInputs, CSG_Shapes *pOutputs) { for(int iClip=0; iClipGet_Count() && Set_Progress(iClip, pClips->Get_Count()); iClip++) { CSG_Shape_Polygon *pClip = (CSG_Shape_Polygon *)pClips->Get_Shape(iClip); for(int iInput=0; iInputGet_Count(); iInput++) { CSG_Shape *pInput = pInputs->Get_Shape(iInput); CSG_Shape *pOutput = NULL; for(int iPoint=0; iPointGet_Point_Count(0); iPoint++) { if( pClip->Contains(pInput->Get_Point(iPoint, 0)) ) { if( pOutput == NULL ) { pOutput = pOutputs->Add_Shape(pInput, SHAPE_COPY_ATTR); } pOutput->Add_Point(pInput->Get_Point(iPoint, 0)); } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPolygon_Clip::Clip_Lines(CSG_Shapes *pClips, CSG_Shapes *pInputs, CSG_Shapes *pOutputs) { for(int iClip=0; iClipGet_Count() && Set_Progress(iClip, pClips->Get_Count()); iClip++) { CSG_Shape_Polygon *pClip = (CSG_Shape_Polygon *)pClips->Get_Shape(iClip); if( pInputs->Select(pClip->Get_Extent()) ) { for(int iInput=0; iInputGet_Selection_Count(); iInput++) { CSG_Shape *pNew_Line, *pLine = pInputs->Get_Selection(iInput); for(int iPart=0, jPart=-1; iPartGet_Part_Count(); iPart++) { TSG_Point B, A = pLine->Get_Point(0, iPart); bool bIn = pClip->Contains(A); if( bIn ) { pNew_Line = pOutputs->Add_Shape(pLine, SHAPE_COPY_ATTR); pNew_Line->Add_Point(A, ++jPart); } for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { B = A; A = pLine->Get_Point(iPoint, iPart); if( bIn ) { if( pClip->Contains(A) ) { pNew_Line->Add_Point(A, jPart); } else { pNew_Line->Add_Point(Get_Crossing(pClip, A, B), jPart); bIn = false; } } else if( pClip->Contains(A) ) { if( jPart < 0 ) { pNew_Line = pOutputs->Add_Shape(pLine, SHAPE_COPY_ATTR); } pNew_Line->Add_Point(Get_Crossing(pClip, A, B), ++jPart); pNew_Line->Add_Point(A, jPart); bIn = true; } } } } } } } //--------------------------------------------------------- TSG_Point CPolygon_Clip::Get_Crossing(CSG_Shape_Polygon *pPolygon, const TSG_Point &a, const TSG_Point &b) { TSG_Point c = a; for(int iPart=0; iPartGet_Part_Count(); iPart++) { TSG_Point A, B; B = pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { A = B; B = pPolygon->Get_Point(iPoint, iPart); if( SG_Get_Crossing(c, A, B, a, b) ) { return( c ); } } } return( c ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPolygon_Clip::Clip_Polygons(CSG_Shapes *pClips, CSG_Shapes *pInputs, CSG_Shapes *pOutputs) { for(int iClip=0; iClipGet_Count() && Process_Get_Okay(); iClip++) { Process_Set_Text(CSG_String::Format(SG_T("%s: %d/%d"), _TL("clip features"), iClip + 1, pClips->Get_Count())); CSG_Shape *pClip = pClips->Get_Shape(iClip); for(int iInput=0; iInputGet_Count() && Set_Progress(iInput, pInputs->Get_Count()); iInput++) { CSG_Shape *pOutput = pOutputs->Add_Shape(pInputs->Get_Shape(iInput)); if( !SG_Polygon_Intersection(pOutput, pClip) ) { pOutputs->Del_Shape(pOutputs->Get_Count() - 1); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Clip::Dissolve(CSG_Shapes *pPolygons, CSG_Shapes *pOutput) { pOutput->Create(SHAPE_TYPE_Polygon); pOutput->Add_Field(_TL("ID"), SG_DATATYPE_Int); CSG_Shape *pDissolved = pOutput->Add_Shape(pPolygons->Get_Shape(0), SHAPE_COPY_GEOM); for(int iPolygon=1; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(iPolygon); for(int iPart=0; iPartGet_Part_Count(); iPart++) { CSG_Shape_Part *pPart = ((CSG_Shape_Polygon *)pPolygon)->Get_Part(iPart); for(int iPoint=0, nParts=pDissolved->Get_Part_Count(); iPointGet_Count(); iPoint++) { pDissolved->Add_Point(pPart->Get_Point(iPoint), nParts); } } } return( SG_Polygon_Dissolve(pDissolved) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_flatten.h0000744000175000017500000001164012737416204026111 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_flatten.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygon // // // //-------------------------------------------------------// // // // polygon_flatten.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__polygon_flatten_H #define HEADER_INCLUDED__polygon_flatten_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Flatten : public CSG_Module { public: ////// public members and functions: ////////////// CPolygon_Flatten(void); protected: /// protected members and functions: /////////// virtual bool On_Execute (void); private: ///// private members and functions: ///////////// }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__polygon_flatten_H saga-2.3.1/src/modules/shapes/shapes_polygons/Polygons_From_Lines.cpp0000744000175000017500000001760312737416204027174 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygons_From_Lines.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygons_From_Lines.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygons_From_Lines::CPolygons_From_Lines(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Convert Lines to Polygons")); Set_Author ("O.Conrad (c) 2005"); Set_Description (_TW( "Converts lines to polygons. " "Line arcs are closed to polygons simply by connecting the last point with the first. " "Optionally parts of polylines can be merged into one polygon optionally. " )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); pNode = Parameters.Add_Shapes( NULL , "LINES" , _TL("Lines"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); pNode = Parameters.Add_Value( NULL , "SINGLE" , _TL("Create Single Multipart Polygon"), _TL(""), PARAMETER_TYPE_Bool, false ); pNode = Parameters.Add_Value( NULL , "MERGE" , _TL("Merge Line Parts to One Polygon"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygons_From_Lines::On_Execute(void) { bool bSingle, bMerge; CSG_Shape *pLine , *pPolygon; CSG_Shapes *pLines, *pPolygons; pPolygons = Parameters("POLYGONS")->asShapes(); pLines = Parameters("LINES" )->asShapes(); bSingle = Parameters("SINGLE" )->asBool (); bMerge = Parameters("MERGE" )->asBool (); if( pLines->Get_Count() <= 0 ) { return( false ); } if( !bSingle ) { pPolygons ->Create(SHAPE_TYPE_Polygon, pLines->Get_Name(), pLines); } else { pPolygons ->Create(SHAPE_TYPE_Polygon, pLines->Get_Name()); pPolygons ->Add_Field(SG_T("ID"), SG_DATATYPE_Int); pPolygon = pPolygons ->Add_Shape(); pPolygon ->Set_Value(0, 1); } //----------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { pLine = pLines->Get_Shape(iLine); if( pLine->is_Valid() ) { if( !bSingle ) { pPolygon = pPolygons->Add_Shape(pLine, SHAPE_COPY_ATTR); } if( !bMerge || pLine->Get_Part_Count() == 1 ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { Add_Part(pPolygon, pLine, pPolygon->Get_Part_Count(), iPart); } } else // if( bMerge && pLine->Get_Part_Count() > 1 ) { CSG_Shapes Copy(SHAPE_TYPE_Line); Add_Line(pPolygon, Copy.Add_Shape(pLine)); } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygons_From_Lines::Add_Part(CSG_Shape *pPolygon, CSG_Shape *pLine, int iPart_Polygon, int iPart_Line, bool bAscending) { for(int iPoint=0; iPointGet_Point_Count(iPart_Line); iPoint++) { pPolygon->Add_Point(pLine->Get_Point(iPoint, iPart_Line, bAscending), iPart_Polygon); } return( true ); } //--------------------------------------------------------- bool CPolygons_From_Lines::Add_Line(CSG_Shape *pPolygon, CSG_Shape *pLine, int iPart_Polygon) { bool bAscending; int iPart_Line; Add_Part(pPolygon, pLine, iPart_Polygon, 0); pLine->Del_Part(0); while( pLine->Get_Part_Count() > 0 ) { if( Get_Part(pPolygon->Get_Point(0, iPart_Polygon, false), pLine, iPart_Line, bAscending) ) { Add_Part(pPolygon, pLine, iPart_Polygon, iPart_Line, bAscending); pLine->Del_Part(iPart_Line); } else // start a new polygon part { Add_Part(pPolygon, pLine, ++iPart_Polygon, 0); pLine->Del_Part(0); } } return( true ); } //--------------------------------------------------------- bool CPolygons_From_Lines::Get_Part(CSG_Point Point, CSG_Shape *pLine, int &iPart, bool &bAscending) { for(iPart=0; iPartGet_Part_Count(); iPart++) { if( Point.is_Equal(pLine->Get_Point(0, iPart, bAscending = true)) ) { return( true ); } if( Point.is_Equal(pLine->Get_Point(0, iPart, bAscending = false)) ) { return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_Centroids.h0000744000175000017500000001053612737416204026351 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Centroids.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Centroids_H #define HEADER_INCLUDED__Polygon_Centroids_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Centroids : public CSG_Module { public: CPolygon_Centroids(void); virtual ~CPolygon_Centroids(void); protected: virtual bool On_Execute(void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Centroids_H saga-2.3.1/src/modules/shapes/shapes_polygons/add_point_attributes.cpp0000744000175000017500000002112312737416204027444 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // add_point_attributes.cpp // // // // Copyright (C) 2014 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "add_point_attributes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CAdd_Point_Attributes::CAdd_Point_Attributes(void) { Set_Name (_TL("Add Point Attributes to Polygons")); Set_Author (SG_T("V. Wichmann (c) 2014")); Set_Description (_TW( "Spatial join for polygons. Retrieves for each polygon the selected " "attributes from that point, which is contained in the polygon. In case " "a polygon contains more than one point, the last point wins.\n" "Optionally, the module allows one to attach the geometrical properties " "(x,y(z,m)) of each point as additional attributes.\n\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Polygons"), _TL("Input polygon shapefile"), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL("Input point shapefile"), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("Attributes to add. Select none to add all") ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Result"), _TL("Optional output polygon shapefile"), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "ADD_LOCATION_INFO", _TL("Add Location Info"), _TL("Add location information from points (x,y,(z,m))"), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CAdd_Point_Attributes::On_Execute(void) { //----------------------------------------------------- bool bAddLocInfo = Parameters("ADD_LOCATION_INFO")->asBool(); //----------------------------------------------------- CSG_Shapes *pInput = Parameters("INPUT")->asShapes(); if( !pInput->is_Valid() ) { Error_Set(_TL("Invalid polygon layer.")); return( false ); } //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS")->asShapes(); if( !pPoints->is_Valid() ) { Error_Set(_TL("Invalid points layer.")); return( false ); } CSG_Parameter_Table_Fields *pFields = Parameters("FIELDS")->asTableFields(); if( pFields->Get_Count() == 0 ) // no fields specified, so add all { CSG_String sFields; for(int iField=0; iFieldGet_Field_Count(); iField++) { sFields += CSG_String::Format(SG_T("%d,"), iField); } pFields->Set_Value(sFields); } //----------------------------------------------------- CSG_Shapes *pOutput = Parameters("OUTPUT")->asShapes(); if( pOutput && pOutput != pInput ) { pOutput->Create(*pInput); } else { Parameters("OUTPUT")->Set_Value(pOutput = pInput); } pOutput->Set_Name(CSG_String::Format(SG_T("%s_%s"), pInput->Get_Name(), pPoints->Get_Name())); //----------------------------------------------------- int outField = pOutput->Get_Field_Count(); int iXField = -1; for(int iField=0; iFieldGet_Count(); iField++) { int jField = pFields->Get_Index(iField); pOutput->Add_Field(pPoints->Get_Field_Name(jField), pPoints->Get_Field_Type(jField)); } if( bAddLocInfo ) { pOutput->Add_Field(SG_T("X"), SG_DATATYPE_Float); iXField = pOutput->Get_Field_Count() - 1; pOutput->Add_Field(SG_T("Y"), SG_DATATYPE_Float); if( pPoints->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pOutput->Add_Field(SG_T("Z"), SG_DATATYPE_Float); if( pPoints->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pOutput->Add_Field(SG_T("M"), SG_DATATYPE_Float); } } } //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pOutput->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pOutput->Get_Shape(iPolygon); //------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Process_Get_Okay(); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); if( pPolygon->Contains(pPoint->Get_Point(0)) ) { for(int iField=0; iFieldGet_Count(); iField++) { int jField = pFields->Get_Index(iField); switch( pPoints->Get_Field_Type(jField) ) { case SG_DATATYPE_String: case SG_DATATYPE_Date: pPolygon->Set_Value(outField + iField, pPoint->asString(jField)); break; default: pPolygon->Set_Value(outField + iField, pPoint->asDouble(jField)); break; } } if( bAddLocInfo ) { pPolygon->Set_Value(iXField , pPoint->Get_Point(0).x); pPolygon->Set_Value(iXField + 1, pPoint->Get_Point(0).y); if( pPoints->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pPolygon->Set_Value(iXField + 2, pPoint->Get_Z(0)); if( pPoints->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZM ) { pPolygon->Set_Value(iXField + 3, pPoint->Get_M(0)); } } } } } // iPoint } // iPolygon //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_Geometrics.cpp0000744000175000017500000001215412737416204027051 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* Polygon_Geometrics.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Geometrics.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Geometrics::CPolygon_Geometrics(void) { Set_Name (_TL("Polygon Properties")); Set_Author (_TL("V.Olaya (c) 2004, O.Conrad (c) 2011")); Set_Description (_TW( "General and geometric properties of polygons." )); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Polygons with Property Attributes"), _TL("If not set property attributes will be added to the orignal layer."), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "BPARTS" , _TL("Number of Parts"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BPOINTS" , _TL("Number of Vertices"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BLENGTH" , _TL("Perimeter"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "BAREA" , _TL("Area"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Geometrics::On_Execute(void) { //------------------------------------------------- int bParts = Parameters("BPARTS") ->asBool() ? 0 : -1; int bPoints = Parameters("BPOINTS") ->asBool() ? 0 : -1; int bLength = Parameters("BLENGTH") ->asBool() ? 0 : -1; int bArea = Parameters("BAREA") ->asBool() ? 0 : -1; if( bParts && bPoints && bLength && bArea ) { Error_Set(_TL("no properties selected")); return( false ); } //------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( !pPolygons->is_Valid() || pPolygons->Get_Count() <= 0 ) { Error_Set(_TL("invalid lines layer")); return( false ); } if( Parameters("OUTPUT")->asShapes() && Parameters("OUTPUT")->asShapes() != pPolygons ) { pPolygons = Parameters("OUTPUT")->asShapes(); pPolygons->Create(*Parameters("POLYGONS")->asShapes()); } //------------------------------------------------- if( !bParts ) { bParts = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("NPARTS") , SG_DATATYPE_Int ); } if( !bPoints ) { bPoints = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("NPOINTS") , SG_DATATYPE_Int ); } if( !bLength ) { bLength = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("PERIMETER"), SG_DATATYPE_Double); } if( !bArea ) { bArea = pPolygons->Get_Field_Count(); pPolygons->Add_Field(SG_T("AREA") , SG_DATATYPE_Double); } //------------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pPolygons->Get_Count()); i++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(i); if( bParts >= 0 ) pPolygon->Set_Value(bParts , pPolygon->Get_Part_Count()); if( bPoints >= 0 ) pPolygon->Set_Value(bPoints, pPolygon->Get_Point_Count()); if( bLength >= 0 ) pPolygon->Set_Value(bLength, ((CSG_Shape_Polygon *)pPolygon)->Get_Perimeter()); if( bArea >= 0 ) pPolygon->Set_Value(bArea , ((CSG_Shape_Polygon *)pPolygon)->Get_Area()); } //------------------------------------------------- if( pPolygons == Parameters("POLYGONS")->asShapes() ) { DataObject_Update(pPolygons); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/shape_index.h0000744000175000017500000001021512737416204025171 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Polygon // // // //-------------------------------------------------------// // // // Shape_Index.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shape_Index_H #define HEADER_INCLUDED__Shape_Index_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShape_Index : public CSG_Module { public: CShape_Index(void); virtual ~CShape_Index(void); protected: virtual bool On_Execute (void); private: double Get_Distance (CSG_Shape *pShape); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shape_Index_H saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_to_points.h0000744000175000017500000001026212737416204026471 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Polygon // // // //-------------------------------------------------------// // // // Polygon_To_Points.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_To_Points_H #define HEADER_INCLUDED__Polygon_To_Points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_To_Points : public CSG_Module { public: CPolygon_To_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Shapes|Conversion") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_To_Points_H saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_Union.h0000744000175000017500000001200712737416204025502 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Union.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Union_H #define HEADER_INCLUDED__Polygon_Union_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Dissolve : public CSG_Module { public: CPolygon_Dissolve(void); protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool m_bSUM, m_bAVG, m_bMIN, m_bMAX, m_bRNG, m_bDEV, m_bVAR, m_bLST, m_bNUM; int m_Stat_Offset; CSG_Strings m_List; CSG_Parameter_Table_Fields *m_Stat_pFields; CSG_Simple_Statistics *m_Statistics; CSG_String Get_Statistics_Name (const CSG_String &Type, const CSG_String &Name); bool Init_Statistics (CSG_Shapes *pUnions, CSG_Shapes *pPolygons); bool Add_Statistics (CSG_Shape *pUnion, CSG_Shape *pPolygon, bool bReset); bool Set_Union (CSG_Shape *pUnion, bool bDissolve); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Union_H saga-2.3.1/src/modules/shapes/shapes_polygons/Makefile.in0000664000175000017500000006167512737447617024633 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/shapes/shapes_polygons ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_polygons_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_polygons_la_OBJECTS = add_point_attributes.lo \ MLB_Interface.lo Polygon_Centroids.lo Polygon_Clip.lo \ polygon_flatten.lo Polygon_Geometrics.lo \ Polygon_Intersection.lo Polygon_SelfIntersection.lo \ Polygon_StatisticsFromPoints.lo Polygon_Union.lo \ Polygons_From_Lines.lo polygon_line_intersection.lo \ polygon_shared_edges.lo polygon_split_parts.lo \ polygon_to_edges_nodes.lo polygon_to_points.lo shape_index.lo libshapes_polygons_la_OBJECTS = $(am_libshapes_polygons_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_polygons_la_SOURCES) DIST_SOURCES = $(libshapes_polygons_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id$ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_polygons.la libshapes_polygons_la_SOURCES = \ add_point_attributes.cpp\ MLB_Interface.cpp\ Polygon_Centroids.cpp\ Polygon_Clip.cpp\ polygon_flatten.cpp\ Polygon_Geometrics.cpp\ Polygon_Intersection.cpp\ Polygon_SelfIntersection.cpp\ Polygon_StatisticsFromPoints.cpp\ Polygon_Union.cpp\ Polygons_From_Lines.cpp\ polygon_line_intersection.cpp\ polygon_shared_edges.cpp\ polygon_split_parts.cpp\ polygon_to_edges_nodes.cpp\ polygon_to_points.cpp\ shape_index.cpp\ add_point_attributes.h\ MLB_Interface.h\ Polygon_Centroids.h\ Polygon_Clip.h\ polygon_flatten.h\ Polygon_Geometrics.h\ Polygon_Intersection.h\ Polygon_SelfIntersection.h\ Polygon_StatisticsFromPoints.h\ Polygon_Union.h\ Polygons_From_Lines.h\ polygon_line_intersection.h\ polygon_shared_edges.h\ polygon_split_parts.h\ polygon_to_edges_nodes.h\ polygon_to_points.h\ shape_index.h libshapes_polygons_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/shapes/shapes_polygons/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_polygons/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_polygons.la: $(libshapes_polygons_la_OBJECTS) $(libshapes_polygons_la_DEPENDENCIES) $(EXTRA_libshapes_polygons_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_polygons_la_OBJECTS) $(libshapes_polygons_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Centroids.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Clip.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Geometrics.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Intersection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_SelfIntersection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_StatisticsFromPoints.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Union.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygons_From_Lines.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/add_point_attributes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_flatten.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_line_intersection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_shared_edges.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_split_parts.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_to_edges_nodes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/polygon_to_points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shape_index.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_split_parts.h0000744000175000017500000001040712737416204027020 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_split_parts.h 915 2011-02-15 08:43:36Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_split_parts.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__polygon_split_parts_H #define HEADER_INCLUDED__polygon_split_parts_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Split_Parts : public CSG_Module { public: CPolygon_Split_Parts(void); protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__polygon_split_parts_H saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_Geometrics.h0000744000175000017500000000447512737416204026525 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* Polygon_Geometrics.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Geometrics_H #define HEADER_INCLUDED__Polygon_Geometrics_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Geometrics : public CSG_Module { public: CPolygon_Geometrics(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Geometrics_H saga-2.3.1/src/modules/shapes/shapes_polygons/Makefile.am0000744000175000017500000000236112737416204024570 0ustar00oconradoconrad00000000000000# # $Id$ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_polygons.la libshapes_polygons_la_SOURCES =\ add_point_attributes.cpp\ MLB_Interface.cpp\ Polygon_Centroids.cpp\ Polygon_Clip.cpp\ polygon_flatten.cpp\ Polygon_Geometrics.cpp\ Polygon_Intersection.cpp\ Polygon_SelfIntersection.cpp\ Polygon_StatisticsFromPoints.cpp\ Polygon_Union.cpp\ Polygons_From_Lines.cpp\ polygon_line_intersection.cpp\ polygon_shared_edges.cpp\ polygon_split_parts.cpp\ polygon_to_edges_nodes.cpp\ polygon_to_points.cpp\ shape_index.cpp\ add_point_attributes.h\ MLB_Interface.h\ Polygon_Centroids.h\ Polygon_Clip.h\ polygon_flatten.h\ Polygon_Geometrics.h\ Polygon_Intersection.h\ Polygon_SelfIntersection.h\ Polygon_StatisticsFromPoints.h\ Polygon_Union.h\ Polygons_From_Lines.h\ polygon_line_intersection.h\ polygon_shared_edges.h\ polygon_split_parts.h\ polygon_to_edges_nodes.h\ polygon_to_points.h\ shape_index.h libshapes_polygons_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_StatisticsFromPoints.h0000744000175000017500000000517312737416204030573 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /******************************************************************************* PolygonStatisticsFromPoints.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PolygonStatisticsFromPoints_H #define HEADER_INCLUDED__PolygonStatisticsFromPoints_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygonStatisticsFromPoints : public CSG_Module { public: CPolygonStatisticsFromPoints(void); protected: virtual bool On_Execute (void); private: CSG_String Get_Field_Name (const CSG_String &Type, const CSG_String &Name); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PolygonStatisticsFromPoints_H saga-2.3.1/src/modules/shapes/shapes_polygons/add_point_attributes.h0000744000175000017500000000775112737416204027124 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // add_point_attributes.h // // // // Copyright (C) 2014 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__add_point_attributes_H #define HEADER_INCLUDED__add_point_attributes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CAdd_Point_Attributes : public CSG_Module { public: CAdd_Point_Attributes(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__add_point_attributes_H saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_to_edges_nodes.cpp0000744000175000017500000002220612737416204027770 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_to_edges_nodes.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_to_edges_nodes.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_to_edges_nodes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_to_Edges_Nodes::CPolygon_to_Edges_Nodes(void) { //----------------------------------------------------- Set_Name (_TL("Polygons to Edges and Nodes")); Set_Author (SG_T("O. Conrad (c) 2011")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "EDGES" , _TL("Edges"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "NODES" , _TL("Nodes"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_to_Edges_Nodes::On_Execute(void) { CSG_Shapes *pPolygons; pPolygons = Parameters("POLYGONS") ->asShapes(); m_pEdges = Parameters("EDGES") ->asShapes(); m_pNodes = Parameters("NODES") ->asShapes(); if( !m_Vertices.Create(pPolygons, -1) ) { Error_Set(_TL("initialisation error")); return( false ); } //----------------------------------------------------- m_pEdges->Create(SHAPE_TYPE_Line , CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Edges"))); m_pEdges->Add_Field(_TL("ID") , SG_DATATYPE_Int); m_pEdges->Add_Field(_TL("NODE_A"), SG_DATATYPE_Int); m_pEdges->Add_Field(_TL("NODE_B"), SG_DATATYPE_Int); m_pEdges->Add_Field(_TL("FACE_A"), SG_DATATYPE_Int); m_pEdges->Add_Field(_TL("FACE_B"), SG_DATATYPE_Int); m_pNodes->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Nodes"))); m_pNodes->Add_Field(_TL("ID") , SG_DATATYPE_Int); m_pNodes->Add_Field(_TL("COUNT") , SG_DATATYPE_Int); m_pNodes->Add_Field(_TL("EDGES") , SG_DATATYPE_String); m_Nodes.Create(pPolygons->Get_Extent()); //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(iPolygon); for(int iPart=0, iPoint; iPartGet_Part_Count(); iPart++) { if( !Find_Node(pPolygon, iPart, iPoint = 0) ) { CSG_Shape *pEdge = m_pEdges->Add_Shape(); for(iPoint=0; iPointGet_Point_Count(); iPoint++) { pEdge->Add_Point(pPolygon->Get_Point(iPoint, iPart)); } } else { do { Trace_Edge(pPolygon, iPart, iPoint); } while( Find_Node(pPolygon, iPart, ++iPoint) ); } } } //----------------------------------------------------- m_Vertices .Destroy(); m_Nodes .Destroy(); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_to_Edges_Nodes::Find_Node(CSG_Shape *pPolygon, int iPart, int &iPoint) { for( ; iPointGet_Point_Count(iPart); iPoint++) { double Distance; CSG_PRQuadTree_Leaf *pLeaf = m_Vertices.Get_Nearest_Leaf(pPolygon->Get_Point(iPoint, iPart), Distance); if( pLeaf->has_Statistics() && ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Count() > 2 ) { return( true ); } } return( false ); } //--------------------------------------------------------- bool CPolygon_to_Edges_Nodes::Trace_Edge(CSG_Shape *pPolygon, int iPart, int aPoint) { CSG_Shape *pEdge = m_pEdges->Add_Shape(); for(int iPoint=aPoint; pEdge->Get_Point_Count(0)Get_Point_Count(iPart); iPoint=iPointGet_Point_Count(iPart)-1 ? iPoint+1 : 0) { double Distance; CSG_PRQuadTree_Leaf *pLeaf = m_Vertices.Get_Nearest_Leaf(pPolygon->Get_Point(iPoint, iPart), Distance); pEdge->Add_Point(pPolygon->Get_Point(iPoint, iPart)); if( iPoint != aPoint && pLeaf->has_Statistics() ) { if( ((CSG_PRQuadTree_Leaf_List *)pLeaf)->Get_Count() > 2 ) // Node { TSG_Point A = pPolygon->Get_Point(aPoint, iPart); TSG_Point B = pPolygon->Get_Point(iPoint, iPart); if( pEdge->Get_Point_Count(0) > 2 || (A.x != B.x || A.y != B.y) ) { int Node_A = Add_Node(A, pEdge->Get_Index()); int Node_B = Add_Node(B, pEdge->Get_Index()); pEdge->Set_Value(0, pEdge->Get_Index()); pEdge->Set_Value(1, Node_A < Node_B ? Node_A : Node_B); pEdge->Set_Value(2, Node_A < Node_B ? Node_B : Node_A); pEdge->Set_Value(3, pPolygon->Get_Index()); return( true ); } m_pEdges->Del_Shape(pEdge); return( false ); } } } m_pEdges->Del_Shape(pEdge); return( false ); } //--------------------------------------------------------- int CPolygon_to_Edges_Nodes::Add_Node(TSG_Point &Point, int Edge_ID) { int Node_ID; double Distance; CSG_Shape *pNode; CSG_PRQuadTree_Leaf *pLeaf = m_Nodes.Get_Nearest_Leaf(Point, Distance); if( !pLeaf || Distance > 0.0 ) { Node_ID = m_pNodes->Get_Count(); pNode = m_pNodes->Add_Shape(); pNode ->Set_Value(0, Node_ID); pNode ->Set_Value(1, 1); pNode ->Set_Value(2, CSG_String::Format(SG_T("%d"), Edge_ID)); pNode ->Set_Value(3, -1); pNode ->Add_Point(Point); m_Nodes.Add_Point(Point.x, Point.y, Node_ID); } else { Node_ID = (int)pLeaf->Get_Z(); pNode = m_pNodes->Get_Shape(Node_ID); pNode ->Add_Value(1, 1); pNode ->Set_Value(2, CSG_String::Format(SG_T("%s|%d"), pNode->asString(2), Edge_ID)); } return( pNode->Get_Index() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_to_points.cpp0000744000175000017500000001560712737416204027034 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Polygon // // // //-------------------------------------------------------// // // // Polygon_To_Points.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_to_points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_To_Points::CPolygon_To_Points(void) { //----------------------------------------------------- Set_Name (_TL("Convert Polygon/Line Vertices to Points")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_To_Points::On_Execute(void) { CSG_Shapes *pShapes, *pPoints; pShapes = Parameters("SHAPES") ->asShapes(); pPoints = Parameters("POINTS") ->asShapes(); //----------------------------------------------------- if( pShapes->is_Valid() ) { pPoints->Create(SHAPE_TYPE_Point, pShapes->Get_Name()); pPoints->Add_Field(SG_T("ID") , SG_DATATYPE_String); pPoints->Add_Field(SG_T("ID_SHAPE") , SG_DATATYPE_Int); pPoints->Add_Field(SG_T("ID_PART") , SG_DATATYPE_Int); pPoints->Add_Field(SG_T("ID_POINT") , SG_DATATYPE_Int); if( pShapes->Get_Type() == SHAPE_TYPE_Polygon ) { pPoints->Add_Field(SG_T("CLOCKWISE"), SG_DATATYPE_String); pPoints->Add_Field(SG_T("LAKE") , SG_DATATYPE_String); } switch( pShapes->Get_Vertex_Type() ) { case SG_VERTEX_TYPE_XY: break; case SG_VERTEX_TYPE_XYZ: pPoints->Add_Field(SG_T("Z"), SG_DATATYPE_Double); break; case SG_VERTEX_TYPE_XYZM: pPoints->Add_Field(SG_T("Z"), SG_DATATYPE_Double); pPoints->Add_Field(SG_T("M"), SG_DATATYPE_Double); break; } for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { CSG_Shape *pPoint = pPoints->Add_Shape(); pPoint->Add_Point(pShape->Get_Point(iPoint, iPart)); int n = 0; pPoint->Set_Value(n++, CSG_String::Format(SG_T("%d/%d/%d"), iShape, iPart, iPoint)); pPoint->Set_Value(n++, iShape); pPoint->Set_Value(n++, iPart); pPoint->Set_Value(n++, iPoint); if( pShapes->Get_Type() == SHAPE_TYPE_Polygon ) { pPoint->Set_Value(n++, ((CSG_Shape_Polygon *)pShape)->is_Clockwise(iPart) ? SG_T("Y") : SG_T("N")); pPoint->Set_Value(n++, ((CSG_Shape_Polygon *)pShape)->is_Lake (iPart) ? SG_T("Y") : SG_T("N")); } switch( pShapes->Get_Vertex_Type() ) { case SG_VERTEX_TYPE_XY: break; case SG_VERTEX_TYPE_XYZ: pPoint->Set_Value(n++, pShape->Get_Z(iPoint, iPart)); break; case SG_VERTEX_TYPE_XYZM: pPoint->Set_Value(n++, pShape->Get_Z(iPoint, iPart)); pPoint->Set_Value(n++, pShape->Get_M(iPoint, iPart)); break; } } } } return( pPoints->is_Valid() ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/MLB_Interface.h0000744000175000017500000000766012737416204025306 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__shapes_polygons_H #define HEADER_INCLUDED__shapes_polygons_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef shapes_polygons_EXPORTS #define shapes_polygons_EXPORT _SAGA_DLL_EXPORT #else #define shapes_polygons_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_polygon_H saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_Intersection.h0000744000175000017500000001424712737416204027070 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Intersection.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Intersection_H #define HEADER_INCLUDED__Polygon_Intersection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Overlay : public CSG_Module { public: CPolygon_Overlay(const CSG_String &Name); virtual CSG_String Get_MenuPath (void) { return( _TL("Overlay") ); } protected: bool Add_Description (const CSG_String &Text); bool Initialize (CSG_Shapes **ppA, CSG_Shapes **ppB, bool bBothAttributes); bool Get_Intersection (CSG_Shapes *pA, CSG_Shapes *pB); bool Get_Difference (CSG_Shapes *pA, CSG_Shapes *pB, bool bInvert = false); private: bool m_bSplit, m_bInvert; CSG_Shapes *m_pA, *m_pB, *m_pAB; CSG_Shape * Add_Polygon (int id_A, int id_B); void Add_Polygon (CSG_Shape *pShape, int id_A, int id_B = -1); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPolygon_Intersection : public CPolygon_Overlay { public: CPolygon_Intersection(void); protected: virtual bool On_Execute (void); }; //--------------------------------------------------------- class CPolygon_Difference : public CPolygon_Overlay { public: CPolygon_Difference(void); protected: virtual bool On_Execute (void); }; //--------------------------------------------------------- class CPolygon_SymDifference : public CPolygon_Overlay { public: CPolygon_SymDifference(void); protected: virtual bool On_Execute (void); }; //--------------------------------------------------------- class CPolygon_Union : public CPolygon_Overlay { public: CPolygon_Union(void); protected: virtual bool On_Execute (void); }; //--------------------------------------------------------- class CPolygon_Identity : public CPolygon_Overlay { public: CPolygon_Identity(void); protected: virtual bool On_Execute (void); }; //--------------------------------------------------------- class CPolygon_Update : public CPolygon_Overlay { public: CPolygon_Update(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Intersection_H saga-2.3.1/src/modules/shapes/shapes_polygons/Polygon_Intersection.cpp0000744000175000017500000003560212737416204027421 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // Polygon_Intersection.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Intersection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Overlay::CPolygon_Overlay(const CSG_String &Name) { //----------------------------------------------------- Set_Name (Name); Set_Author (SG_T("O.Conrad (c) 2003-13")); Set_Description (_TW( "Uses the free and open source software library Clipper created by Angus Johnson.\n" "Clipper Homepage\n" "Clipper at SourceForge\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "A" , _TL("Layer A"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "B" , _TL("Layer B"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "RESULT" , Name, _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "SPLIT" , _TL("Split Parts"), _TL("Set true if you want multipart polygons to become separate polygons."), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Overlay::Add_Description(const CSG_String &Text) { Set_Description(Text + "\n" + Get_Description()); return( true ); } //--------------------------------------------------------- bool CPolygon_Overlay::Initialize(CSG_Shapes **ppA, CSG_Shapes **ppB, bool bBothAttributes) { *ppA = Parameters("A")->asShapes(); if( (*ppA)->Get_Type() != SHAPE_TYPE_Polygon || !(*ppA)->is_Valid() ) return( false ); *ppB = Parameters("B")->asShapes(); if( (*ppB)->Get_Type() != SHAPE_TYPE_Polygon || !(*ppB)->is_Valid() ) return( false ); m_bSplit = Parameters("SPLIT")->asBool(); m_pA = NULL; m_pB = NULL; m_pAB = Parameters("RESULT")->asShapes(); m_pAB->Create(SHAPE_TYPE_Polygon, SG_T(""), *ppA); m_pAB->Set_Name(CSG_String::Format(SG_T("%s [%s]-[%s]"), Get_Name().c_str(), (*ppA)->Get_Name(), (*ppB)->Get_Name())); if( bBothAttributes ) { for(int i=0; i<(*ppB)->Get_Field_Count(); i++) { m_pAB->Add_Field((*ppB)->Get_Field_Name(i), (*ppB)->Get_Field_Type(i)); } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Overlay::Get_Intersection(CSG_Shapes *pA, CSG_Shapes *pB) { m_bInvert = false; m_pA = pA; m_pB = pB; CSG_Shapes Tmp(SHAPE_TYPE_Polygon); CSG_Shape *pShape_AB = Tmp.Add_Shape(); //----------------------------------------------------- for(int id_A=0; id_AGet_Count() && Set_Progress(id_A, m_pA->Get_Count()); id_A++) { if( m_pB->Select(m_pA->Get_Shape(id_A)->Get_Extent()) ) { CSG_Shape *pShape_A = m_pA->Get_Shape(id_A); for(int id_B=0; id_BGet_Selection_Count(); id_B++) { CSG_Shape *pShape_B = m_pB->Get_Selection(id_B); if( SG_Polygon_Intersection(pShape_A, pShape_B, pShape_AB) ) { Add_Polygon(pShape_AB, id_A, pShape_B->Get_Index()); } } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Overlay::Get_Difference(CSG_Shapes *pA, CSG_Shapes *pB, bool bInvert) { m_bInvert = bInvert; m_pA = pA; m_pB = pB; CSG_Shapes Tmp(SHAPE_TYPE_Polygon); CSG_Shape *pShape_A = Tmp.Add_Shape(); //----------------------------------------------------- for(int id_A=0; id_AGet_Count() && Set_Progress(id_A, m_pA->Get_Count()); id_A++) { if( m_pB->Select(m_pA->Get_Shape(id_A)->Get_Extent()) ) { int nIntersections = 0; pShape_A->Assign(m_pA->Get_Shape(id_A)); for(int id_B=0; id_BGet_Selection_Count(); id_B++) { if( SG_Polygon_Difference(pShape_A, m_pB->Get_Selection(id_B)) ) { nIntersections++; } } if( nIntersections > 0 && pShape_A->is_Valid() ) { Add_Polygon(pShape_A, id_A); } } else { Add_Polygon(m_pA->Get_Shape(id_A), id_A); } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shape * CPolygon_Overlay::Add_Polygon(int id_A, int id_B) { CSG_Shape *pOriginal, *pNew = m_pAB->Add_Shape(); if( pNew ) { if( (pOriginal = m_pA->Get_Shape(id_A)) != NULL ) { for(int i=0, j=m_bInvert ? m_pB->Get_Field_Count() : 0; iGet_Field_Count(); i++, j++) { if( pNew->Get_Value(j) ) *pNew->Get_Value(j) = *pOriginal->Get_Value(i); } } if( (pOriginal = m_pB->Get_Shape(id_B)) != NULL ) { for(int i=0, j=m_bInvert ? 0 : m_pA->Get_Field_Count(); iGet_Field_Count(); i++, j++) { if( pNew->Get_Value(j) ) *pNew->Get_Value(j) = *pOriginal->Get_Value(i); } } } return( pNew ); } //--------------------------------------------------------- void CPolygon_Overlay::Add_Polygon(CSG_Shape *pShape, int id_A, int id_B) { int iPoint, iPart, jPart, nParts; CSG_Shape *pShape_Add; for(iPart=pShape->Get_Part_Count()-1; iPart>=0; iPart--) { if( ((CSG_Shape_Polygon *)pShape)->Get_Area(iPart) <= 0.0 ) { pShape->Del_Part(iPart); } else if( pShape->Get_Point_Count(iPart) <= 3 ) { CSG_Point a(pShape->Get_Point(0, iPart)), b(pShape->Get_Point(1, iPart)), c(pShape->Get_Point(2, iPart)); if( a == b || b == c || c == a ) { pShape->Del_Part(iPart); } } } if( pShape->is_Valid() ) { if( m_bSplit && pShape->Get_Part_Count() > 1 ) { for(iPart=0; iPartGet_Part_Count(); iPart++) { if( !((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) && (pShape_Add = Add_Polygon(id_A, id_B)) != NULL ) { for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pShape_Add->Add_Point(pShape->Get_Point(iPoint, iPart), 0); } for(jPart=0, nParts=0; jPartGet_Part_Count(); jPart++) { if( ((CSG_Shape_Polygon *)pShape)->is_Lake(jPart) && ((CSG_Shape_Polygon *)pShape)->Contains(pShape->Get_Point(0, jPart), iPart) ) { nParts++; for(iPoint=0; iPointGet_Point_Count(jPart); iPoint++) { pShape_Add->Add_Point(pShape->Get_Point(iPoint, jPart), nParts); } } } } } } else if( (pShape_Add = Add_Polygon(id_A, id_B)) != NULL ) { pShape_Add->Assign(pShape, false); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Intersection::CPolygon_Intersection(void) : CPolygon_Overlay(_TL("Intersect")) { Add_Description(_TW( "Calculates the geometric intersection of the overlayed polygon layers, " "i.e. layer A and layer B." )); } //--------------------------------------------------------- bool CPolygon_Intersection::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, true) ) { return( false ); } return( Get_Intersection(pA, pB) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Difference::CPolygon_Difference(void) : CPolygon_Overlay(_TL("Difference")) { Add_Description(_TW( "Calculates the geometric difference of the overlayed polygon layers, " "i.e. layer A less layer B. Sometimes referred to as \'Erase\' command." )); } //--------------------------------------------------------- bool CPolygon_Difference::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, false) ) { return( false ); } return( Get_Difference(pA, pB) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_SymDifference::CPolygon_SymDifference(void) : CPolygon_Overlay(_TL("Symmetrical Difference")) { Add_Description(_TW( "Calculates the symmetrical geometric difference of the overlayed polygon layers, " "i.e. layer A less layer B plus layer B less layer A." )); } //--------------------------------------------------------- bool CPolygon_SymDifference::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, true) ) { return( false ); } return( Get_Difference(pA, pB) && Get_Difference(pB, pA, true) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Union::CPolygon_Union(void) : CPolygon_Overlay(_TL("Union")) { Add_Description(_TW( "Calculates the geometric union of the overlayed polygon layers, " "i.e. the intersection plus the symmetrical difference of layers A and B." )); } //--------------------------------------------------------- bool CPolygon_Union::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, true) ) { return( false ); } return( Get_Intersection(pA, pB) && Get_Difference (pA, pB) && Get_Difference (pB, pA, true) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Identity::CPolygon_Identity(void) : CPolygon_Overlay(_TL("Identity")) { Add_Description(_TW( "Calculates the geometric intersection between both layers " "and adds the difference of layer A less layer B." )); } //--------------------------------------------------------- bool CPolygon_Identity::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, true) ) { return( false ); } return( Get_Intersection(pA, pB) && Get_Difference (pA, pB) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Update::CPolygon_Update(void) : CPolygon_Overlay(_TL("Update")) { Add_Description(_TW( "Updates features of layer A with the features of layer B, " "i.e. all features of layer B will be supplemented with the " "difference of layer A less layer B plus. It is assumed, " "that both input layers share the same attribute structure." )); } //--------------------------------------------------------- bool CPolygon_Update::On_Execute(void) { CSG_Shapes *pA, *pB; if( !CPolygon_Overlay::Initialize(&pA, &pB, false) ) { return( false ); } if( !Get_Difference(pA, pB) ) { return( false ); } //----------------------------------------------------- CSG_Shapes *pAB = Parameters("RESULT")->asShapes(); for(int i=0; iGet_Count(); i++) { pAB->Add_Shape(pB->Get_Shape(i)); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_shared_edges.cpp0000744000175000017500000003703612737416204027433 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_shared_edges.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_shared_edges.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_shared_edges.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Shared_Edges::CPolygon_Shared_Edges(void) { //----------------------------------------------------- Set_Name (_TL("Shared Polygon Edges")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field( pNode , "ATTRIBUTE" , _TL("Attribute"), _TL(""), true ); Parameters.Add_Shapes( NULL , "EDGES" , _TL("Edges"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); // Parameters.Add_Shapes( // NULL , "NODES" , _TL("Nodes"), // _TL(""), // PARAMETER_OUTPUT, SHAPE_TYPE_Point // ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Tolerance"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Value( NULL , "VERTICES" , _TL("Check Vertices"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "DOUBLE" , _TL("Double Edges"), _TL("give output of an edge twice, i.e. once for each of the two adjacent polygons"), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Shared_Edges::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); m_Field = Parameters("ATTRIBUTE")->asInt(); m_pEdges = Parameters("EDGES")->asShapes(); m_pEdges->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Edges"))); m_pEdges->Add_Field("ID_A", m_Field < 0 ? SG_DATATYPE_Int : pPolygons->Get_Field_Type(m_Field)); m_pEdges->Add_Field("ID_B", m_Field < 0 ? SG_DATATYPE_Int : pPolygons->Get_Field_Type(m_Field)); // m_pNodes = Parameters("NODES")->asShapes(); // m_pNodes->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Nodes"))); // m_pNodes->Add_Field("ID", SG_DATATYPE_Int); bool bVertices = Parameters("VERTICES")->asBool (); double Epsilon = Parameters("EPSILON" )->asDouble(); int iPolygon, nAdded = 0, nRemoved = 0; //----------------------------------------------------- if( bVertices ) { for(iPolygon=0; iPolygonGet_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); for(int iPart=0; iPartGet_Part_Count() && Process_Get_Okay(); iPart++) { CSG_Shape_Part *pPart = pPolygon->Get_Part(iPart); CSG_Point A = pPart->Get_Point(pPart->Get_Count() - 1); if( A != pPart->Get_Point(0) ) { pPart->Add_Point(A); } for(int iPoint=pPart->Get_Count()-2; iPoint>=0; iPoint--) { CSG_Point B = A; A = pPart->Get_Point(iPoint); if( A == B ) { pPart->Del_Point(iPoint + 1); nRemoved--; } } } } } //----------------------------------------------------- for(iPolygon=0; iPolygonGet_Count()-1 && Set_Progress(iPolygon, pPolygons->Get_Count()-1); iPolygon++) { CSG_Shape_Polygon *pA = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); for(int jPolygon=iPolygon+1; jPolygonGet_Count() && Process_Get_Okay(); jPolygon++) { CSG_Shape_Polygon *pB = (CSG_Shape_Polygon *)pPolygons->Get_Shape(jPolygon); for(int iPart=0; iPartGet_Part_Count() && Process_Get_Okay(); iPart++) { for(int jPart=0; jPartGet_Part_Count() && Process_Get_Okay(); jPart++) { if( pA->Get_Part(iPart)->Get_Extent().Intersects(pB->Get_Part(jPart)->Get_Extent()) ) { if( bVertices ) { nAdded += Check_Vertices(pA->Get_Part(iPart), pB->Get_Part(jPart), Epsilon); nAdded += Check_Vertices(pB->Get_Part(jPart), pA->Get_Part(iPart), Epsilon); } Get_Shared_Edges(pA->Get_Part(iPart), pB->Get_Part(jPart), Epsilon); } } } } } //----------------------------------------------------- if( Parameters("DOUBLE")->asBool() ) { for(int iEdge=0, nEdges=m_pEdges->Get_Count(); iEdgeGet_Shape(iEdge); CSG_Shape *pB = m_pEdges->Add_Shape(pA); *(pB->Get_Value(0)) = *(pA->Get_Value(1)); *(pB->Get_Value(1)) = *(pA->Get_Value(0)); } } //----------------------------------------------------- if( nAdded > 0 || nRemoved > 0 ) { Message_Add(CSG_String::Format(SG_T("\n%s: %d %s, %d %s\n"), _TL("Vertices"), nAdded , _TL("added" ), nRemoved, _TL("removed") ), false); DataObject_Update(pPolygons); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Shared_Edges::Get_Shared_Edges(CSG_Shape_Part *pA, CSG_Shape_Part *pB, double Epsilon) { int Edge_1st = m_pEdges->Get_Count(); CSG_Shape *pEdge = NULL; for(int iPoint=0, jPoint; iPointGet_Count(); iPoint++) { CSG_Point Point = pA->Get_Point(iPoint); if( !pEdge ) { for(jPoint=0; jPointGet_Count(); jPoint++) { if( Point.is_Equal(pB->Get_Point(jPoint), Epsilon) ) { pEdge = m_pEdges->Add_Shape(); pEdge ->Add_Point(Point); if( m_Field < 0 ) { pEdge->Set_Value(0, pA->Get_Owner()->Get_Index()); pEdge->Set_Value(1, pB->Get_Owner()->Get_Index()); } else { pEdge->Set_Value(0, pA->Get_Owner()->asString(m_Field)); pEdge->Set_Value(1, pB->Get_Owner()->asString(m_Field)); } break; } } } else { int j = jPoint; if( Point.is_Equal(pB->Get_Point(jPoint = Get_Next_Vertex(pB, j, false)), Epsilon) || Point.is_Equal(pB->Get_Point(jPoint = Get_Next_Vertex(pB, j, true )), Epsilon) ) { pEdge->Add_Point(Point); } else { pEdge = NULL; } } } //----------------------------------------------------- if( pEdge ) { CSG_Shape *pEdge_1st = m_pEdges->Get_Shape(Edge_1st); if( pEdge != pEdge_1st && SG_Is_Equal(pA->Get_Point(0), pEdge_1st->Get_Point(0)) ) { for(int i=0; iGet_Point_Count(0); i++) { pEdge->Add_Point(pEdge_1st->Get_Point(i)); } m_pEdges->Del_Shape(Edge_1st); } } //----------------------------------------------------- for(int iEdge=m_pEdges->Get_Count()-1; iEdge>=Edge_1st; iEdge--) { if( m_pEdges->Get_Shape(iEdge)->Get_Point_Count() <= 1 ) // touches at point { m_pEdges->Del_Shape(iEdge); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- int CPolygon_Shared_Edges::Get_Next_Vertex(CSG_Shape_Part *pPoints, int iPoint, bool bAscending) { if( bAscending ) { if( iPoint < pPoints->Get_Count() - 1 ) { iPoint ++; } else { iPoint = 1; } } else { if( iPoint > 0 ) { iPoint --; } else { iPoint = pPoints->Get_Count() - 2; } } return( iPoint ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPolygon_Shared_Edges::Check_Vertices(CSG_Shape_Part *pPolygon, CSG_Shape_Part *pVertices, double Epsilon) { int nAdded = 0; TSG_Point A = pPolygon->Get_Point(0, false); for(int iPoint=0; iPointGet_Count(); iPoint++) { TSG_Point B = A; A = pPolygon->Get_Point(iPoint); for(int iVertex=0; iVertexGet_Count(); iVertex++) { TSG_Point Vertex = pVertices->Get_Point(iVertex); if( (SG_Is_Between(Vertex.x, A.x, B.x, Epsilon) && SG_Is_Between(Vertex.y, A.y, B.y, Epsilon)) && !SG_Is_Equal(Vertex, A, Epsilon) && !SG_Is_Equal(Vertex, B, Epsilon) && SG_Is_Point_On_Line(Vertex, A, B, true, Epsilon) ) { pPolygon->Ins_Point(Vertex, iPoint++); nAdded++; } } } return( nAdded ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Vertex_Check::CPolygon_Vertex_Check(void) { //----------------------------------------------------- Set_Name (_TL("Polygon Vertex Check")); Set_Author ("O.Conrad (c) 2014"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "CHECKED" , _TL("Checked"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "ADDED" , _TL("Added"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Tolerance"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Vertex_Check::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( Parameters("CHECKED")->asShapes() && Parameters("CHECKED")->asShapes() != pPolygons ) { CSG_Shapes *pCopy = Parameters("CHECKED")->asShapes(); pCopy->Create(*pPolygons); pCopy->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("checked"))); pPolygons = pCopy; } if( (m_pAdded = Parameters("ADDED")->asShapes()) != NULL ) { m_pAdded->Create(SHAPE_TYPE_Point, _TL("Added")); } double Epsilon = Parameters("EPSILON")->asDouble(); //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Count()-1 && Set_Progress(iPolygon, pPolygons->Get_Count()-1); iPolygon++) { CSG_Shape_Polygon *pA = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); for(int jPolygon=iPolygon+1; jPolygonGet_Count() && Process_Get_Okay(); jPolygon++) { CSG_Shape_Polygon *pB = (CSG_Shape_Polygon *)pPolygons->Get_Shape(jPolygon); for(int iPart=0; iPartGet_Part_Count() && Process_Get_Okay(); iPart++) { for(int jPart=0; jPartGet_Part_Count() && Process_Get_Okay(); jPart++) { if( pA->Get_Part(iPart)->Get_Extent().Intersects(pB->Get_Part(jPart)->Get_Extent()) ) { Check_Vertices(pA->Get_Part(iPart), pB->Get_Part(jPart), Epsilon); Check_Vertices(pB->Get_Part(jPart), pA->Get_Part(iPart), Epsilon); } } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Vertex_Check::Check_Vertices(CSG_Shape_Part *pPolygon, CSG_Shape_Part *pVertices, double Epsilon) { TSG_Point A = pPolygon->Get_Point(0, false); for(int iPoint=0; iPointGet_Count(); iPoint++) { TSG_Point B = A; A = pPolygon->Get_Point(iPoint); for(int iVertex=0; iVertexGet_Count(); iVertex++) { TSG_Point Vertex = pVertices->Get_Point(iVertex); if( (SG_Is_Between(Vertex.x, A.x, B.x, Epsilon) && SG_Is_Between(Vertex.y, A.y, B.y, Epsilon)) && !SG_Is_Equal(Vertex, A, Epsilon) && !SG_Is_Equal(Vertex, B, Epsilon) && SG_Is_Point_On_Line(Vertex, A, B, true, Epsilon) ) { pPolygon->Ins_Point(Vertex, iPoint++); if( m_pAdded ) { m_pAdded->Add_Shape()->Add_Point(Vertex); } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/polygon_split_parts.cpp0000744000175000017500000001430712737416204027356 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: polygon_split_parts.cpp 915 2011-02-15 08:43:36Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // polygon_split_parts.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "polygon_split_parts.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Split_Parts::CPolygon_Split_Parts(void) { //----------------------------------------------------- Set_Name (_TL("Polygon Parts to Separate Polygons")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Splits parts of multipart polygons into separate polygons. " "This can be done only for islands (outer rings) or for all " "parts (inner and outer rings) by checking the 'ignore lakes' " "option." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "PARTS" , _TL("Polygon Parts"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "LAKES" , _TL("Ignore Lakes"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Split_Parts::On_Execute(void) { bool bIgnoreLakes; CSG_Shapes *pPolygons, *pParts; pPolygons = Parameters("POLYGONS") ->asShapes(); pParts = Parameters("PARTS") ->asShapes(); bIgnoreLakes = Parameters("LAKES") ->asBool(); pParts->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), pPolygons->Get_Name(), _TL("Parts")), pPolygons); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pPolygons->Get_Count()); iShape++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count() && Process_Get_Okay(); iPart++) { if( bIgnoreLakes || !((CSG_Shape_Polygon *)pPolygon)->is_Lake(iPart) ) { CSG_Shape *pPart = pParts->Add_Shape(pPolygon, SHAPE_COPY_ATTR); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pPart->Add_Point(pPolygon->Get_Point(iPoint, iPart)); } if( !bIgnoreLakes ) { for(int jPart=0; jPartGet_Part_Count(); jPart++) { if( ((CSG_Shape_Polygon *)pPolygon)->is_Lake(jPart) && ((CSG_Shape_Polygon *)pPart)->Contains(pPolygon->Get_Point(0, jPart)) ) { for(int jPoint=0, nPart=pPart->Get_Part_Count(); jPointGet_Point_Count(jPart); jPoint++) { pPart->Add_Point(pPolygon->Get_Point(jPoint, jPart), nPart); } } } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_polygons/MLB_Interface.cpp0000744000175000017500000001403412737416204025632 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_polygons // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Polygons") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Olaya, V. Wichmann (c) 2002-14") ); case MLB_INFO_Description: return( _TL("Tools for polygons.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Polygons") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Polygon_Intersection.h" #include "Polygon_Centroids.h" #include "Polygon_Geometrics.h" #include "Polygons_From_Lines.h" #include "Polygon_StatisticsFromPoints.h" #include "Polygon_Union.h" #include "polygon_to_points.h" #include "shape_index.h" #include "polygon_line_intersection.h" #include "polygon_to_edges_nodes.h" #include "polygon_split_parts.h" #include "Polygon_Clip.h" #include "Polygon_SelfIntersection.h" #include "add_point_attributes.h" #include "polygon_flatten.h" #include "polygon_shared_edges.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 1: return( new CPolygon_Centroids ); case 2: return( new CPolygon_Geometrics ); case 3: return( new CPolygons_From_Lines ); case 4: return( new CPolygonStatisticsFromPoints ); case 5: return( new CPolygon_Dissolve ); case 6: return( new CPolygon_To_Points ); case 7: return( new CShape_Index ); case 8: return( new CPolygon_Line_Intersection ); case 9: return( new CPolygon_to_Edges_Nodes ); case 10: return( new CPolygon_Split_Parts ); case 11: return( new CPolygon_Clip ); case 12: return( new CPolygon_SelfIntersection ); case 14: return( new CPolygon_Intersection ); case 15: return( new CPolygon_Difference ); case 16: return( new CPolygon_SymDifference ); case 17: return( new CPolygon_Union ); case 18: return( new CPolygon_Update ); case 19: return( new CPolygon_Identity ); case 20: return( new CAdd_Point_Attributes ); case 21: return( new CPolygon_Flatten ); case 22: return( new CPolygon_Shared_Edges ); //----------------------------------------------------- case 23: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/shapes/shapes_transect/0000775000175000017500000000000012737740007022505 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/shapes/shapes_transect/Makefile.in0000664000175000017500000005525112737447617024575 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/shapes/shapes_transect ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_transect_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_transect_la_OBJECTS = Polygon_Transect.lo \ MLB_Interface.lo libshapes_transect_la_OBJECTS = $(am_libshapes_transect_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_transect_la_SOURCES) DIST_SOURCES = $(libshapes_transect_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id$ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version -avoid-version pkglib_LTLIBRARIES = libshapes_transect.la libshapes_transect_la_SOURCES = \ Polygon_Transect.h\ MLB_Interface.h\ Polygon_Transect.cpp\ MLB_Interface.cpp libshapes_transect_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/shapes/shapes_transect/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_transect/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_transect.la: $(libshapes_transect_la_OBJECTS) $(libshapes_transect_la_DEPENDENCIES) $(EXTRA_libshapes_transect_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_transect_la_OBJECTS) $(libshapes_transect_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Polygon_Transect.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/shapes/shapes_transect/Makefile.am0000744000175000017500000000106212737416206024540 0ustar00oconradoconrad00000000000000# # $Id$ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version -avoid-version pkglib_LTLIBRARIES = libshapes_transect.la libshapes_transect_la_SOURCES =\ Polygon_Transect.h\ MLB_Interface.h\ Polygon_Transect.cpp\ MLB_Interface.cpp libshapes_transect_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/shapes/shapes_transect/Polygon_Transect.cpp0000744000175000017500000003057212737416206026512 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Transect // // // //-------------------------------------------------------// // // // Polygon_Transect.cpp // // // // Copyright (C) 2009 by // // Johan Van de Wauw // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Polygon_Transect.h" #include #include using std::map; using std::list; using std::pair; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPolygon_Transect::CPolygon_Transect(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("Transect through polygon shapefile")); Set_Author (_TL("Copyrights (c) 2009 Johan Van de Wauw")); Set_Description (_TW( "Transect for lines and polygon shapefiles\n" "\n" "The goal of this module is to create a transect along a line through a polygon map.\n" "Eg\n" "\n" "|____ST1_____!_ST2_!__ST1__!_______ST#_____|\n" "\n" "(Soil type 1 etc...)\n" "\n" "This is done by creating a table with the ID of each line, the distance \n" "to the starting point and the different transects:\n" "\n" "
|  line_id  |  start  |  end  |  code/field  |\n"
                    "|    0      |    0    |  124  |     ST1      |\n"
                    "|    0      |   124   |  300  |     ST2      |\n"
                    "|    0      |   300   | 1223  |     ST1      |\n"
                    "|    0      |  1223   | 2504  |     ST3      |\n"
                    "|    1      |    0    |  200  |     ST4      |\n"
                    "|   ...     |   ...   |  ...  |     ...      |
\n" "\n" "\n" "The module requires an input shape with all the line transects [Transect_Line] \n" "and a polygon theme [Theme]. You also have to select which field you want to have in \n" "the resulting table [Transect_Result]. This can be an ID of the polygon theme if you \n" "want to link the tables later on, or any other field [Theme_Field].\n") ); //----------------------------------------------------- // Define your parameters list... CSG_Parameter *pTheme; Parameters.Add_Shapes( NULL, "TRANSECT", _TL("Line Transect(s)"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); pTheme = Parameters.Add_Shapes( NULL, "THEME", _TL("Theme"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Table_Field( pTheme , "THEME_FIELD" , _TL("Theme Field"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table( NULL, "TRANSECT_RESULT", _TL("Result table"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CPolygon_Transect::~CPolygon_Transect(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPolygon_Transect::On_Execute(void) { CSG_Table *pTransect_Result; CSG_Shapes *pTheme, *pTransect; CSG_Shape_Line *pLine; CSG_Shape_Polygon *pTheme_Shape; int Theme_Field; pTransect = Parameters("TRANSECT")->asShapes(); pTheme = Parameters("THEME")->asShapes(); pTransect_Result = Parameters("TRANSECT_RESULT")->asTable(); Theme_Field = Parameters("THEME_FIELD")->asInt(); //----------------------------------------------------- // Check for valid parameter settings... //----------------------------------------------------- if (pTheme->Get_Type() != SHAPE_TYPE_Polygon){ Error_Set(CSG_String("[THEME] is not a polygon file")); return(false); } if (pTransect->Get_Type() != SHAPE_TYPE_Line){ Error_Set(CSG_String("[TRANSECT] is not a line shapefile")); return(false); } if (pTheme->Get_Count() ==0 || pTransect->Get_Count()==0) { Error_Set(CSG_String("[TRANSECT] or [THEME] is empty")); return(false); } if (!(pTheme->Get_Extent().Intersects(pTransect->Get_Extent()))) { Error_Set(CSG_String("[TRANSECT] and [THEME] do not intersect")); return(false); } const int LINE_ID = pTransect_Result->Get_Field_Count(); pTransect_Result->Add_Field(SG_T("line_id"), SG_DATATYPE_Int); const int START = pTransect_Result->Get_Field_Count(); pTransect_Result->Add_Field(SG_T("start"), SG_DATATYPE_Double); const int END = pTransect_Result->Get_Field_Count(); pTransect_Result->Add_Field(SG_T("end"), SG_DATATYPE_Double); const int POLY_ID = pTransect_Result->Get_Field_Count(); pTransect_Result->Add_Field(SG_T("poly_id"), SG_DATATYPE_Int); const int FIELD = pTransect_Result->Get_Field_Count(); pTransect_Result->Add_Field(SG_T("field"), pTheme->Get_Field_Type(Theme_Field)); // Short description of the algorithm: // For every line it is checked whether it crosses a polygon. If it does, // the points where it crosses are recorded in the map LineBorders, with // the polygon_id as key. for (int iLine=0; iLineGet_Count() && Set_Progress(iLine, pTransect->Get_Count()); iLine++) { pLine =(CSG_Shape_Line *) pTransect->Get_Shape(iLine); for (int iLinePart=0;iLinePartGet_Part_Count();iLinePart++) { CSG_Shape_Part *pLinePart =pLine->Get_Part(iLinePart); CSG_Rect LinePartExtent = pLinePart->Get_Extent(); map > LineBorders; for (int iShape=0; iShapeGet_Count();iShape++) { pTheme_Shape = (CSG_Shape_Polygon *) pTheme->Get_Shape(iShape); if (pLinePart->Get_Extent().Intersects(pTheme_Shape->Get_Extent())>0) { for (int iPart=0; iPartGet_Part_Count(); iPart++) { CSG_Shape_Polygon_Part *pPart = (CSG_Shape_Polygon_Part *) pTheme_Shape->Get_Part(iPart); if (pPart->Contains(pLinePart->Get_Point(0))) LineBorders[iShape].push_back(0); if (pPart->Contains(pLinePart->Get_Point(pLinePart->Get_Count()))) LineBorders[iShape].push_back(pLine->Get_Length(iLinePart)); for (int iPoint=0; iPointGet_Count();iPoint++) { int iPoint2 = (iPoint!=pPart->Get_Count()-1)?iPoint+1:0; TSG_Point Crossing; double Length=0; for (int iLinePartPoint=0; iLinePartPointGet_Count(); iLinePartPoint++) { if (SG_Get_Crossing(Crossing,pPart->Get_Point(iPoint),pPart->Get_Point(iPoint2), pLinePart->Get_Point(iLinePartPoint), pLinePart->Get_Point(iLinePartPoint+1))) { LineBorders[iShape].push_back(Length+SG_Get_Distance(Crossing, pLinePart->Get_Point(iLinePartPoint))); } Length+=SG_Get_Distance(pLinePart->Get_Point(iLinePartPoint), pLinePart->Get_Point(iLinePartPoint+1)); } } } } } // convert LineBorders to the result table // the table contains the lineids and the distance to the origin of the line, // and it is sorted by lineid, polygonid CSG_Table_Record *pRecord; for (map >::iterator shapeit=LineBorders.begin();shapeit!=LineBorders.end();++shapeit) { //shapeit->second.sort(); bool start=1; for (list::iterator i=shapeit->second.begin(); i!=shapeit->second.end();++i) { if (start){ pRecord =pTransect_Result->Add_Record(); pRecord->Set_Value(LINE_ID, iLine); pRecord->Set_Value(START, *i); pRecord->Set_Value(POLY_ID, shapeit->first); CSG_Table_Record *pTheme_Record =pTheme->Get_Shape(shapeit->first) ; if(pTheme->Get_Field_Type(Theme_Field)== SG_DATATYPE_String ) pRecord->Set_Value(FIELD, pTheme_Record->asString(Theme_Field)); else pRecord->Set_Value(FIELD, pTheme_Record->asDouble(Theme_Field)); start = 0; } else { pRecord->Set_Value(END, *i); start=1; } } } } } return( true ); } saga-2.3.1/src/modules/shapes/shapes_transect/MLB_Interface.h0000744000175000017500000000760712737416206025262 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes Transect // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2009 by // // Johan Van de Wauw // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__transect_H #define HEADER_INCLUDED__transect_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef transect_EXPORTS #define transect_EXPORT _SAGA_DLL_EXPORT #else #define transect_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__transect_H saga-2.3.1/src/modules/shapes/shapes_transect/MLB_Interface.cpp0000744000175000017500000001152612737416206025610 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Transect // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2009 by // // Johan Van de Wauw // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Transects" )); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( _TL("Johan Van de Wauw (c) 2009" )); case MLB_INFO_Description: return( _TL("A SAGA module to create transects through polygon files." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Lines|Transects" )); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Polygon_Transect.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { // Don't forget to continuously enumerate the case switches // when adding new modules! Also bear in mind that the // enumeration always has to start with [case 0:] and // that [default:] must return NULL!... CSG_Module *pModule; switch( i ) { case 0: pModule = new CPolygon_Transect; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/shapes/shapes_transect/Polygon_Transect.h0000744000175000017500000001020212737416206026143 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Transect // // // //-------------------------------------------------------// // // // Polygon_Transect.h // // // // Copyright (C) 2009 by // // Johan Van de Wauw // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Polygon_Transect_H #define HEADER_INCLUDED__Polygon_Transect_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CPolygon_Transect : public CSG_Module { public: ////// public members and functions: ////////////// CPolygon_Transect(void); // constructor virtual ~CPolygon_Transect(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Polygon_Transect_H saga-2.3.1/src/modules/shapes/Makefile.in0000664000175000017500000004663512737447617021415 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/shapes ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = shapes_tools shapes_polygons shapes_points shapes_lines shapes_grid shapes_transect all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/shapes/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/shapes/Makefile.am0000744000175000017500000000013712737416202021350 0ustar00oconradoconrad00000000000000SUBDIRS = shapes_tools shapes_polygons shapes_points shapes_lines shapes_grid shapes_transect saga-2.3.1/src/modules/shapes/shapes_grid/0000775000175000017500000000000012737740006021606 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Statistics_AddTo_Polygon.h0000744000175000017500000001220712737416202027637 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Statistics_AddTo_Polygon.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Statistics_AddTo_Polygon_H #define HEADER_INCLUDED__Grid_Statistics_AddTo_Polygon_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Statistics_AddTo_Polygon : public CSG_Module_Grid { public: CGrid_Statistics_AddTo_Polygon(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid Values") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool Get_Simple (CSG_Grid *pGrid, CSG_Shapes *pPolygons, CSG_Simple_Statistics *Statistics, bool bQuantiles, CSG_Grid &Index); bool Get_Simple_Index (CSG_Shapes *pPolygons, CSG_Grid &Index); bool Get_Precise (CSG_Grid *pGrid, CSG_Shapes *pPolygons, CSG_Simple_Statistics *Statistics, bool bQuantiles, bool bParallelized); bool Get_Precise (CSG_Grid *pGrid, CSG_Shape_Polygon *pPolygon, CSG_Simple_Statistics &Statistics, bool bQuantiles, int Method); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Statistics_AddTo_Polygon_H saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Statistics_AddTo_Polygon.cpp0000744000175000017500000005047712737416202030205 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Statistics_AddTo_Polygon.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // // quantile calculation: // // Copyright (C) 2007 by // // Johan Van de Wauw // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Statistics_AddTo_Polygon.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Statistics_AddTo_Polygon::CGrid_Statistics_AddTo_Polygon(void) { //----------------------------------------------------- Set_Name (_TL("Grid Statistics for Polygons")); Set_Author ("O.Conrad (c) 2003, Quantile Calculation (c) 2007 by Johan Van de Wauw"); Set_Description (_TW( "Zonal grid statistics. For each polygon statistics based on all covered grid cells will be calculated." )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "NAMING" , _TL("Field Naming"), _TL(""), CSG_String::Format("%s|%s|", _TL("grid number"), _TL("grid name") ), 1 ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("simple and fast"), _TL("polygon wise (cell centers)"), _TL("polygon wise (cell area)"), _TL("polygon wise (cell area weighted)") ), 0 ); Parameters.Add_Bool( NULL , "PARALLELIZED" , _TL("Use Multiple Cores"), _TL(""), false ); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "RESULT" , _TL("Statistics"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value(pNode, "COUNT" , _TL("Number of Cells" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MIN" , _TL("Minimum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MAX" , _TL("Maximum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "RANGE" , _TL("Range" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "SUM" , _TL("Sum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MEAN" , _TL("Mean" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "VAR" , _TL("Variance" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "STDDEV" , _TL("Standard Deviation"), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "QUANTILE", _TL("Quantile" ), _TL("Calculate distribution quantiles. Value specifies interval (median=50, quartiles=25, deciles=10, ...). Set to zero to omit quantile calculation."), PARAMETER_TYPE_Int, 0, 0, true, 50, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_Statistics_AddTo_Polygon::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("PARALLELIZED", pParameter->asInt() != 0 && SG_OMP_Get_Max_Num_Threads() > 1); } return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_FIELD_NAME(VAR) Naming == 0 ? CSG_String::Format("G%02d_%s", iGrid + 1, VAR) : CSG_String::Format("%s [%s]", pGrids->asGrid(iGrid)->Get_Name(), VAR) //--------------------------------------------------------- bool CGrid_Statistics_AddTo_Polygon::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPolygons = Parameters("POLYGONS")->asShapes(); if( pPolygons->Get_Count() <= 0 ) { Error_Set(_TL("no polygons in input layer")); return( false ); } //----------------------------------------------------- CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); if( pGrids->Get_Count() < 1 ) { Error_Set(_TL("no grids in selection")); return( false ); } if( !Get_System()->Get_Extent().Intersects(pPolygons->Get_Extent()) ) { Error_Set(_TL("no spatial intersection between grid(s) and polygon layer")); return( false ); } //----------------------------------------------------- int Quantile = Parameters("QUANTILE")->asInt(); int nFields = 0; int fCOUNT = Parameters("COUNT" )->asBool() ? nFields++ : -1; int fMIN = Parameters("MIN" )->asBool() ? nFields++ : -1; int fMAX = Parameters("MAX" )->asBool() ? nFields++ : -1; int fRANGE = Parameters("RANGE" )->asBool() ? nFields++ : -1; int fSUM = Parameters("SUM" )->asBool() ? nFields++ : -1; int fMEAN = Parameters("MEAN" )->asBool() ? nFields++ : -1; int fVAR = Parameters("VAR" )->asBool() ? nFields++ : -1; int fSTDDEV = Parameters("STDDEV" )->asBool() ? nFields++ : -1; int fQUANTILE = Quantile > 0 ? nFields++ : -1; if( nFields == 0 ) { Error_Set(_TL("no output parameter in selection")); return( false ); } //----------------------------------------------------- bool bParallelized = Parameters("PARALLELIZED")->is_Enabled() && Parameters("PARALLELIZED")->asBool(); int Naming = Parameters("NAMING")->asInt(); int Method = Parameters("METHOD")->asInt(); //----------------------------------------------------- CSG_Grid Index; if( Method == 0 && !Get_Simple_Index(pPolygons, Index) ) { Error_Set(_TL("no grids in selection")); return( false ); } //----------------------------------------------------- if( Parameters("RESULT")->asShapes() != NULL && Parameters("RESULT")->asShapes() != pPolygons ) { pPolygons = Parameters("RESULT")->asShapes(); pPolygons ->Assign(Parameters("POLYGONS")->asShapes()); pPolygons ->Set_Name(CSG_String::Format("%s [%s]", Parameters("POLYGONS")->asShapes()->Get_Name(), _TL("Grid Statistics"))); } CSG_Simple_Statistics *Statistics = new CSG_Simple_Statistics[pPolygons->Get_Count()]; //----------------------------------------------------- for(int iGrid=0; iGridGet_Count() && Process_Get_Okay(); iGrid++) { Process_Set_Text(CSG_String::Format("[%d/%d] %s", 1 + iGrid, pGrids->Get_Count(), pGrids->asGrid(iGrid)->Get_Name())); if( (Method == 0 && Get_Simple (pGrids->asGrid(iGrid), pPolygons, Statistics, Quantile > 0, Index)) || (Method != 0 && Get_Precise(pGrids->asGrid(iGrid), pPolygons, Statistics, Quantile > 0, bParallelized)) ) { nFields = pPolygons->Get_Field_Count(); if( fCOUNT >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("CELLS" )), SG_DATATYPE_Int ); if( fMIN >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("MIN" )), SG_DATATYPE_Double); if( fMAX >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("MAX" )), SG_DATATYPE_Double); if( fRANGE >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("RANGE" )), SG_DATATYPE_Double); if( fSUM >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("SUM" )), SG_DATATYPE_Double); if( fMEAN >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("MEAN" )), SG_DATATYPE_Double); if( fVAR >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("VARIANCE")), SG_DATATYPE_Double); if( fSTDDEV >= 0 ) pPolygons->Add_Field(GET_FIELD_NAME(_TL("STDDEV" )), SG_DATATYPE_Double); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile; iQuantile<100; iQuantile+=Quantile) { pPolygons->Add_Field(GET_FIELD_NAME(CSG_String::Format("Q%02d", iQuantile).c_str()), SG_DATATYPE_Double); } } //--------------------------------------------- for(int i=0; iGet_Count() && Set_Progress(i, pPolygons->Get_Count()); i++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(i); if( Statistics[i].Get_Count() == 0 ) { if( fCOUNT >= 0 ) pPolygon->Set_NoData(nFields + fCOUNT ); if( fMIN >= 0 ) pPolygon->Set_NoData(nFields + fMIN ); if( fMAX >= 0 ) pPolygon->Set_NoData(nFields + fMAX ); if( fRANGE >= 0 ) pPolygon->Set_NoData(nFields + fRANGE ); if( fSUM >= 0 ) pPolygon->Set_NoData(nFields + fSUM ); if( fMEAN >= 0 ) pPolygon->Set_NoData(nFields + fMEAN ); if( fVAR >= 0 ) pPolygon->Set_NoData(nFields + fVAR ); if( fSTDDEV >= 0 ) pPolygon->Set_NoData(nFields + fSTDDEV); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile, iField=nFields + fQUANTILE; iQuantile<100; iQuantile+=Quantile, iField++) { pPolygon->Set_NoData(iField); } } } else { if( fCOUNT >= 0 ) pPolygon->Set_Value(nFields + fCOUNT , Statistics[i].Get_Count ()); if( fMIN >= 0 ) pPolygon->Set_Value(nFields + fMIN , Statistics[i].Get_Minimum ()); if( fMAX >= 0 ) pPolygon->Set_Value(nFields + fMAX , Statistics[i].Get_Maximum ()); if( fRANGE >= 0 ) pPolygon->Set_Value(nFields + fRANGE , Statistics[i].Get_Range ()); if( fSUM >= 0 ) pPolygon->Set_Value(nFields + fSUM , Statistics[i].Get_Sum ()); if( fMEAN >= 0 ) pPolygon->Set_Value(nFields + fMEAN , Statistics[i].Get_Mean ()); if( fVAR >= 0 ) pPolygon->Set_Value(nFields + fVAR , Statistics[i].Get_Variance()); if( fSTDDEV >= 0 ) pPolygon->Set_Value(nFields + fSTDDEV, Statistics[i].Get_StdDev ()); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile, iField=nFields + fQUANTILE; iQuantile<100; iQuantile+=Quantile, iField++) { pPolygon->Set_Value(iField, Statistics[i].Get_Quantile(iQuantile)); } } } } } } //----------------------------------------------------- delete[](Statistics); DataObject_Update(pPolygons); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Statistics_AddTo_Polygon::Get_Precise(CSG_Grid *pGrid, CSG_Shapes *pPolygons, CSG_Simple_Statistics *Statistics, bool bQuantiles, bool bParallelized) { int Method = Parameters("METHOD")->asInt(); if( bParallelized ) { #pragma omp parallel for for(int i=0; iGet_Count(); i++) { Get_Precise(pGrid, (CSG_Shape_Polygon *)pPolygons->Get_Shape(i), Statistics[i], bQuantiles, Method); } } else { for(int i=0; iGet_Count() && Set_Progress(i, pPolygons->Get_Count()); i++) { Get_Precise(pGrid, (CSG_Shape_Polygon *)pPolygons->Get_Shape(i), Statistics[i], bQuantiles, Method); } } return( true ); } //--------------------------------------------------------- bool CGrid_Statistics_AddTo_Polygon::Get_Precise(CSG_Grid *pGrid, CSG_Shape_Polygon *pPolygon, CSG_Simple_Statistics &Statistics, bool bQuantiles, int Method) { //----------------------------------------------------- CSG_Shapes Intersect(SHAPE_TYPE_Polygon); CSG_Shape_Polygon *pCell, *pArea; if( Method == 3 ) // polygon wise (cell area weighted) { pCell = (CSG_Shape_Polygon *)Intersect.Add_Shape(); pArea = (CSG_Shape_Polygon *)Intersect.Add_Shape(); } //----------------------------------------------------- Statistics.Create(bQuantiles); int ax = Get_System()->Get_xWorld_to_Grid(pPolygon->Get_Extent().Get_XMin()) - 1; if( ax < 0 ) ax = 0; int bx = Get_System()->Get_xWorld_to_Grid(pPolygon->Get_Extent().Get_XMax()) + 1; if( bx >= Get_NX() ) bx = Get_NX() - 1; int ay = Get_System()->Get_yWorld_to_Grid(pPolygon->Get_Extent().Get_YMin()) - 1; if( ay < 0 ) ay = 0; int by = Get_System()->Get_yWorld_to_Grid(pPolygon->Get_Extent().Get_YMax()) + 1; if( by >= Get_NY() ) by = Get_NY() - 1; TSG_Point Center; TSG_Rect Cell; //----------------------------------------------------- Center.y = Get_System()->Get_yGrid_to_World(ay); Cell.yMin = Center.y - 0.5 * Get_Cellsize(); Cell.yMax = Cell.yMin + Get_Cellsize(); for(int y=ay; y<=by; y++, Center.y+=Get_Cellsize(), Cell.yMin+=Get_Cellsize(), Cell.yMax+=Get_Cellsize()) { Center.x = Get_System()->Get_xGrid_to_World(ax); Cell.xMin = Center.x - 0.5 * Get_Cellsize(); Cell.xMax = Cell.xMin + Get_Cellsize(); for(int x=ax; x<=bx; x++, Center.x+=Get_Cellsize(), Cell.xMin+=Get_Cellsize(), Cell.xMax+=Get_Cellsize()) { if( !pGrid->is_NoData(x, y) ) { switch( Method ) { //----------------------------------------- default: // polygon wise (cell centers) if( pPolygon->Contains(Center) ) { Statistics += pGrid->asDouble(x, y); } break; //----------------------------------------- case 2: // polygon wise (cell area) if( pPolygon->Intersects(Cell) ) { Statistics += pGrid->asDouble(x, y); } break; //----------------------------------------- case 3: // polygon wise (cell area weighted) switch( pPolygon->Intersects(Cell) ) { case INTERSECTION_None : break; case INTERSECTION_Identical: case INTERSECTION_Contains : Statistics.Add_Value(pGrid->asDouble(x, y), Get_Cellarea()); break; case INTERSECTION_Contained: Statistics.Add_Value(pGrid->asDouble(x, y), pPolygon->Get_Area()); break; case INTERSECTION_Overlaps : pCell->Del_Parts(); pCell->Add_Point(Cell.xMin, Cell.yMin); pCell->Add_Point(Cell.xMin, Cell.yMax); pCell->Add_Point(Cell.xMax, Cell.yMax); pCell->Add_Point(Cell.xMax, Cell.yMin); if( SG_Polygon_Intersection(pPolygon, pCell, pArea) ) { Statistics.Add_Value(pGrid->asDouble(x, y), pArea->Get_Area()); } break; } break; } } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Statistics_AddTo_Polygon::Get_Simple(CSG_Grid *pGrid, CSG_Shapes *pPolygons, CSG_Simple_Statistics *Statistics, bool bQuantiles, CSG_Grid &Index) { int i; for(i=0; iGet_Count(); i++) { Statistics[i].Create(bQuantiles); } for(int y=0; yis_NoData(x, y) && (i = Index.asInt(x, y)) >= 0 && i < pPolygons->Get_Count() ) { Statistics[i] += pGrid->asDouble(x, y); } } } return( true ); } //--------------------------------------------------------- bool CGrid_Statistics_AddTo_Polygon::Get_Simple_Index(CSG_Shapes *pPolygons, CSG_Grid &Index) { bool bFill, *bCrossing; int x, y, ix, xStart, xStop, iShape, iPart, iPoint; double yPos; TSG_Point pLeft, pRight, pa, pb, p; TSG_Rect Extent; CSG_Shape *pPolygon; //----------------------------------------------------- Index.Create(*Get_System(), pPolygons->Get_Count() < 32767 ? SG_DATATYPE_Short : SG_DATATYPE_Int); Index.Assign(-1.0); bCrossing = (bool *)SG_Malloc(Get_NX() * sizeof(bool)); //----------------------------------------------------- for(iShape=0; iShapeGet_Count() && Set_Progress(iShape, pPolygons->Get_Count()); iShape++) { pPolygon = pPolygons->Get_Shape(iShape); Extent = pPolygon->Get_Extent().m_rect; xStart = Get_System()->Get_xWorld_to_Grid(Extent.xMin) - 1; if( xStart < 0 ) xStart = 0; xStop = Get_System()->Get_xWorld_to_Grid(Extent.xMax) + 1; if( xStop >= Get_NX() ) xStop = Get_NX() - 1; pLeft.x = Get_XMin() - 1.0; pRight.x = Get_XMax() + 1.0; //------------------------------------------------- for(y=0, yPos=Get_YMin(); y= Extent.yMin && yPos <= Extent.yMax ) { memset(bCrossing, 0, Get_NX() * sizeof(bool)); pLeft.y = pRight.y = yPos; //----------------------------------------- for(iPart=0; iPartGet_Part_Count(); iPart++) { pb = pPolygon->Get_Point(pPolygon->Get_Point_Count(iPart) - 1, iPart); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pa = pb; pb = pPolygon->Get_Point(iPoint, iPart); if( ( (pa.y <= yPos && yPos < pb.y) || (pa.y > yPos && yPos >= pb.y) ) ) { SG_Get_Crossing(p, pa, pb, pLeft, pRight, false); ix = (int)((p.x - Get_XMin()) / Get_Cellsize() + 1.0); if( ix < 0) { ix = 0; } else if( ix >= Get_NX() ) { continue; } bCrossing[ix] = !bCrossing[ix]; } } } //----------------------------------------- for(x=xStart, bFill=false; x<=xStop; x++) { if( bCrossing[x] ) { bFill = !bFill; } if( bFill ) { Index.Set_Value(x, y, iShape); } } } } } //----------------------------------------------------- SG_Free(bCrossing); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/Grid_To_Contour.h0000744000175000017500000001310312737416202025012 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Contour.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_To_Contour_H #define HEADER_INCLUDED__Grid_To_Contour_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_To_Contour : public CSG_Module { public: CGrid_To_Contour(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Vectorization") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool m_bParts; CSG_Grid *m_pGrid, m_Edge; CSG_Shapes *m_pContours, *m_pPolygons; bool is_Edge (int x, int y); void Set_Row (int x, int y, bool bOn); bool Get_Row (int x, int y); void Set_Col (int x, int y, bool bOn); bool Get_Col (int x, int y); bool Get_Contour (double z); bool Get_Contour (double z, int x, int y); bool Get_Contour_Cell (int &Dir, int &x, int &y, bool &bRow); bool Get_Polygons (CSG_Shape_Line *pContour_Lo, CSG_Shape_Line *pContour_Hi); bool Add_Contour (CSG_Shapes &Segments, CSG_Shape_Polygon *pPolygon, CSG_Shape_Line *pContour); bool Add_Edge (CSG_Shapes &Segments, int x, int y); bool Add_Segment (CSG_Shape *pPolygon, int iPart, CSG_Shape *pContour, bool bAscending); CSG_Shape * Get_Segment (const CSG_Shapes &Segments, int &x, int &y, bool &bAscending); bool Split_Polygon_Parts (CSG_Shapes *pPolygons); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_To_Contour_H saga-2.3.1/src/modules/shapes/shapes_grid/grid_extent.cpp0000744000175000017500000001344612737416202024633 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_extent.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_extent.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_extent.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Extent::CGrid_Extent(void) { //----------------------------------------------------- Set_Name (_TL("Grid System Extent")); Set_Author (_TL("O. Conrad (c) 2011")); Set_Description (_TW( "Creates a polygon (rectangle) from a grid system's extent." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "CELLS" , _TL("Border"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("grid cells"), _TL("grid nodes") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Extent::On_Execute(void) { bool bCells; CSG_Grid_System *pSystem; CSG_Shapes *pShapes; //----------------------------------------------------- pSystem = Get_System(); pShapes = Parameters("SHAPES") ->asShapes(); bCells = Parameters("CELLS") ->asInt() == 0; //----------------------------------------------------- if( pSystem == NULL || !pSystem->is_Valid() ) { Error_Set(_TL("invalid grid system")); return( false ); } //----------------------------------------------------- pShapes->Create(SHAPE_TYPE_Polygon, _TL("Grid System Extent")); pShapes->Add_Field(_TL("NX") , SG_DATATYPE_Int); pShapes->Add_Field(_TL("NY") , SG_DATATYPE_Int); pShapes->Add_Field(_TL("CELLSIZE") , SG_DATATYPE_Double); CSG_Shape *pExtent = pShapes->Add_Shape(); pExtent->Set_Value(0, pSystem->Get_NX()); pExtent->Set_Value(1, pSystem->Get_NY()); pExtent->Set_Value(2, pSystem->Get_Cellsize()); pExtent->Add_Point(pSystem->Get_XMin(bCells), pSystem->Get_YMin(bCells)); pExtent->Add_Point(pSystem->Get_XMin(bCells), pSystem->Get_YMax(bCells)); pExtent->Add_Point(pSystem->Get_XMax(bCells), pSystem->Get_YMax(bCells)); pExtent->Add_Point(pSystem->Get_XMax(bCells), pSystem->Get_YMin(bCells)); pExtent->Add_Point(pSystem->Get_XMin(bCells), pSystem->Get_YMin(bCells)); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Statistics_For_Points.cpp0000744000175000017500000003122512737416202027553 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Statistics_For_Points.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Statistics_For_Points.cpp // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Statistics_For_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Statistics_For_Points::CGrid_Statistics_For_Points(void) { //----------------------------------------------------- Set_Name (_TL("Grid Statistics for Points")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "For each given point statistics based on all grid cells in the defined neighbourhood will be calculated." )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "KERNEL_TYPE" , _TL("Kernel Type"), _TL(""), CSG_String::Format("%s|%s|", _TL("square"), _TL("circle") ), 0 ); Parameters.Add_Value( NULL , "KERNEL_SIZE" , _TL("Kernel Size"), _TL("kernel size defined as radius number of cells"), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Choice( NULL , "NAMING" , _TL("Field Naming"), _TL(""), CSG_String::Format("%s|%s|", _TL("grid number"), _TL("grid name") ), 1 ); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "RESULT" , _TL("Statistics"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Value(pNode, "COUNT" , _TL("Number of Cells" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MIN" , _TL("Minimum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MAX" , _TL("Maximum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "RANGE" , _TL("Range" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "SUM" , _TL("Sum" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "MEAN" , _TL("Mean" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "VAR" , _TL("Variance" ), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "STDDEV" , _TL("Standard Deviation"), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_Value(pNode, "QUANTILE", _TL("Quantile" ), _TL("Calculate distribution quantiles. Value specifies interval (median=50, quartiles=25, deciles=10, ...). Set to zero to omit quantile calculation."), PARAMETER_TYPE_Int, 0, 0, true, 50, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Statistics_For_Points::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS")->asShapes(); if( pPoints->Get_Count() <= 0 ) { Error_Set(_TL("no points in input layer")); return( false ); } //----------------------------------------------------- CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); if( pGrids->Get_Count() < 1 ) { Error_Set(_TL("no grids in selection")); return( false ); } if( !Get_System()->Get_Extent().Intersects(pPoints->Get_Extent()) ) { Error_Set(_TL("no spatial intersection between grid(s) and points layer")); return( false ); } //----------------------------------------------------- if( !m_Kernel.Set_Radius(Parameters("KERNEL_SIZE")->asInt(), Parameters("KERNEL_TYPE")->asInt() == 0) ) { Error_Set(_TL("could not initialize kernel")); return( false ); } //----------------------------------------------------- int Quantile = Parameters("QUANTILE")->asInt(); int nFields = 0, offField; int fCOUNT = Parameters("COUNT" )->asBool() ? nFields++ : -1; int fMIN = Parameters("MIN" )->asBool() ? nFields++ : -1; int fMAX = Parameters("MAX" )->asBool() ? nFields++ : -1; int fRANGE = Parameters("RANGE" )->asBool() ? nFields++ : -1; int fSUM = Parameters("SUM" )->asBool() ? nFields++ : -1; int fMEAN = Parameters("MEAN" )->asBool() ? nFields++ : -1; int fVAR = Parameters("VAR" )->asBool() ? nFields++ : -1; int fSTDDEV = Parameters("STDDEV" )->asBool() ? nFields++ : -1; int fQUANTILE = Quantile > 0 ? nFields++ : -1; if( nFields == 0 ) { Error_Set(_TL("no output parameter in selection")); return( false ); } //----------------------------------------------------- if( Parameters("RESULT")->asShapes() != NULL && Parameters("RESULT")->asShapes() != pPoints ) { pPoints = Parameters("RESULT")->asShapes(); pPoints ->Assign(Parameters("POINTS")->asShapes()); pPoints ->Set_Name(CSG_String::Format("%s [%s]", Parameters("POINTS")->asShapes()->Get_Name(), _TL("Grid Statistics"))); } //----------------------------------------------------- { #define GET_FIELD_NAME(VAR) Naming == 0 ? CSG_String::Format(SG_T("G%02d_%s"), iGrid + 1, VAR) : CSG_String::Format(SG_T("%s [%s]"), pGrids->asGrid(iGrid)->Get_Name(), VAR) int Naming = Parameters("NAMING")->asInt(); offField = pPoints->Get_Field_Count(); for(int iGrid=0; iGridGet_Count(); iGrid++) { int iField = pPoints->Get_Field_Count(); if( fCOUNT >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("CELLS" )), SG_DATATYPE_Int ); if( fMIN >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("MIN" )), SG_DATATYPE_Double); if( fMAX >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("MAX" )), SG_DATATYPE_Double); if( fRANGE >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("RANGE" )), SG_DATATYPE_Double); if( fSUM >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("SUM" )), SG_DATATYPE_Double); if( fMEAN >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("MEAN" )), SG_DATATYPE_Double); if( fVAR >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("VARIANCE")), SG_DATATYPE_Double); if( fSTDDEV >= 0 ) pPoints->Add_Field(GET_FIELD_NAME(_TL("STDDEV" )), SG_DATATYPE_Double); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile; iQuantile<100; iQuantile+=Quantile) { pPoints->Add_Field(GET_FIELD_NAME(CSG_String::Format(SG_T("Q%02d"), iQuantile).c_str()), SG_DATATYPE_Double); if( iGrid == 0 && iQuantile > Quantile ) { nFields++; } } } } } //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); for(int iGrid=0; iGridGet_Count(); iGrid++) { CSG_Simple_Statistics Statistics(Quantile >= 0); int iField = offField + iGrid * nFields; if( !Get_Statistics(pPoint->Get_Point(0), pGrids->asGrid(iGrid), Statistics) ) { if( fCOUNT >= 0 ) pPoint->Set_NoData(iField + fCOUNT ); if( fMIN >= 0 ) pPoint->Set_NoData(iField + fMIN ); if( fMAX >= 0 ) pPoint->Set_NoData(iField + fMAX ); if( fRANGE >= 0 ) pPoint->Set_NoData(iField + fRANGE ); if( fSUM >= 0 ) pPoint->Set_NoData(iField + fSUM ); if( fMEAN >= 0 ) pPoint->Set_NoData(iField + fMEAN ); if( fVAR >= 0 ) pPoint->Set_NoData(iField + fVAR ); if( fSTDDEV >= 0 ) pPoint->Set_NoData(iField + fSTDDEV); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile; iQuantile<100; iQuantile+=Quantile, iField++) { pPoint->Set_NoData(iField + fQUANTILE); } } } else { if( fCOUNT >= 0 ) pPoint->Set_Value(iField + fCOUNT , Statistics.Get_Count ()); if( fMIN >= 0 ) pPoint->Set_Value(iField + fMIN , Statistics.Get_Minimum ()); if( fMAX >= 0 ) pPoint->Set_Value(iField + fMAX , Statistics.Get_Maximum ()); if( fRANGE >= 0 ) pPoint->Set_Value(iField + fRANGE , Statistics.Get_Range ()); if( fSUM >= 0 ) pPoint->Set_Value(iField + fSUM , Statistics.Get_Sum ()); if( fMEAN >= 0 ) pPoint->Set_Value(iField + fMEAN , Statistics.Get_Mean ()); if( fVAR >= 0 ) pPoint->Set_Value(iField + fVAR , Statistics.Get_Variance()); if( fSTDDEV >= 0 ) pPoint->Set_Value(iField + fSTDDEV, Statistics.Get_StdDev ()); if( fQUANTILE >= 0 ) { for(int iQuantile=Quantile; iQuantile<100; iQuantile+=Quantile, iField++) { pPoint->Set_Value(iField + fQUANTILE, Statistics.Get_Quantile(iQuantile)); } } } } } //----------------------------------------------------- DataObject_Update(pPoints); m_Kernel.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Statistics_For_Points::Get_Statistics(const TSG_Point &Point, CSG_Grid *pGrid, CSG_Simple_Statistics &Statistics) { int x = Get_System()->Get_xWorld_to_Grid(Point.x); int y = Get_System()->Get_yWorld_to_Grid(Point.y); for(int i=0; iis_InGrid(ix, iy) ) { Statistics += pGrid->asDouble(ix, iy); } } return( Statistics.Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/grid_rectangle_clip.h0000744000175000017500000001045612737416202025742 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_rectangle_clip.h // // // // Copyright (C) 2013 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_rectangle_clip_H #define HEADER_INCLUDED__grid_rectangle_clip_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Rectangle_Clip : public CSG_Module { public: CGrid_Rectangle_Clip(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Spatial Extent") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_rectangle_clip_H saga-2.3.1/src/modules/shapes/shapes_grid/Grid_To_Points.h0000744000175000017500000001074312737416202024644 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Points.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_To_Points_H #define HEADER_INCLUDED__Grid_To_Points_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_To_Points : public CSG_Module_Grid { public: CGrid_To_Points(void); virtual ~CGrid_To_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Vectorization") ); } protected: virtual bool On_Execute (void); private: bool is_Contained (double x, double y, CSG_Shapes *pPolygons); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_To_Points_H saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Classes_To_Shapes.cpp0000744000175000017500000005115712737416202026627 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Classes_To_Shapes.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Classes_To_Shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Classes_To_Shapes::CGrid_Classes_To_Shapes(void) { //----------------------------------------------------- Set_Name (_TL("Vectorising Grid Classes")); Set_Author ("O.Conrad (c) 2008"); Set_Description (_TW( "Vectorising grid classes." )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); CSG_Parameter *pNode = Parameters.Add_Choice( NULL , "CLASS_ALL" , _TL("Class Selection"), _TL(""), CSG_String::Format("%s|%s|", _TL("one single class specified by class identifier"), _TL("all classes") ), 1 ); Parameters.Add_Double( pNode , "CLASS_ID" , _TL("Class Identifier"), _TL(""), 1.0 ); Parameters.Add_Choice( NULL , "SPLIT" , _TL("Vectorised class as..."), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("one single (multi-)polygon object"), _TL("each island as separated polygon") ), 0 ); Parameters.Add_Value( NULL , "ALLVERTICES" , _TL("Keep Vertices on Straight Lines"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_Classes_To_Shapes::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "CLASS_ALL") ) { pParameters->Set_Enabled("CLASS_ID", pParameter->asInt() == 0); } return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::On_Execute(void) { //----------------------------------------------------- if( !Get_Classes() || !Get_Edges() ) { m_Classes.Destroy(); return( false ); } //----------------------------------------------------- if( Parameters("SPLIT")->asInt() == 1 ) { Split_Polygons(); } m_Classes.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::Get_Classes(void) { //----------------------------------------------------- CSG_Grid *pGrid = Parameters("GRID")->asGrid(); m_pPolygons = Parameters("POLYGONS")->asShapes(); m_pPolygons->Create(SHAPE_TYPE_Polygon); m_pPolygons->Add_Field("ID" , SG_DATATYPE_Int ); m_pPolygons->Add_Field("VALUE", pGrid->Get_Type ()); m_pPolygons->Add_Field("NAME" , SG_DATATYPE_String); DataObject_Set_Parameter(m_pPolygons, DataObject_Get_Parameter(pGrid, "COLORS_TYPE")); // Color Classification Type: Lookup Table DataObject_Set_Parameter(m_pPolygons, DataObject_Get_Parameter(pGrid, "LUT" )); // Lookup Table DataObject_Set_Parameter(m_pPolygons, "LUT_ATTRIB", 1); m_pPolygons->Set_Name(pGrid->Get_Name()); //----------------------------------------------------- CSG_Table *pLUT = NULL; if( DataObject_Get_Parameter(pGrid, "COLORS_TYPE") ) { if( DataObject_Get_Parameter(pGrid, "COLORS_TYPE")->asInt() == 1 ) // Color Classification Type: Lookup Table == 1 { if( DataObject_Get_Parameter(pGrid, "LUT") ) { pLUT = DataObject_Get_Parameter(pGrid, "LUT")->asTable(); } } } //----------------------------------------------------- Process_Set_Text(_TL("class identification")); m_Classes.Create(pGrid->Get_System(), SG_DATATYPE_Int); m_Classes.Set_NoData_Value(-1); m_Classes.Assign_NoData(); double Value = 0.0; //----------------------------------------------------- if( Parameters("CLASS_ALL")->asInt() == 1 ) { if( !pGrid->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } int x, y, id = -1; for(sLong i=0; iGet_Sorted(i, x, y, false) ) { if( m_pPolygons->Get_Count() == 0 || Value != pGrid->asDouble(x, y) ) { CSG_Shape *pPolygon = m_pPolygons->Add_Shape(); pPolygon->Set_Value(0, 1 + id++); pPolygon->Set_Value(1, Value = pGrid->asDouble(x, y)); pPolygon->Set_Value(2, Get_Class_Name(Value, pLUT)); } m_Classes.Set_Value(x, y, id); } } } //----------------------------------------------------- else { CSG_Shape *pPolygon = m_pPolygons->Add_Shape(); pPolygon->Set_Value(0, m_pPolygons->Get_Count()); pPolygon->Set_Value(1, Value = Parameters("CLASS_ID")->asDouble()); pPolygon->Set_Value(2, Get_Class_Name(Value, pLUT)); for(int y=0; yasDouble(x, y) == Value ) { m_Classes.Set_Value(x, y, 0); } } } } //----------------------------------------------------- return( m_pPolygons->Get_Count() > 0 ); } //--------------------------------------------------------- #define LUT_NAM 1 #define LUT_MIN 3 #define LUT_MAX 4 CSG_String CGrid_Classes_To_Shapes::Get_Class_Name(double Value, CSG_Table *pLUT) { if( pLUT ) // using LUT ? { for(int i=0; iGet_Count(); i++) { CSG_Table_Record *pClass = pLUT->Get_Record(i); if( Value >= pClass->asDouble(LUT_MIN) && Value <= pClass->asDouble(LUT_MAX) ) { return( pClass->asString(LUT_NAM) ); } } } return( SG_Get_String(Value, -2) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::Get_Edges(void) { /////////////////////////////////////////////////////// //----------------------------------------------------- Process_Set_Text(_TL("edge detection")); int y, nEdges = 0; m_Edges.Create(SG_DATATYPE_Int, 2 * Get_NX() + 1, 2 * Get_NY() + 1, 0.5 * Get_Cellsize(), Get_XMin() - 0.5 * Get_Cellsize(), Get_YMin() - 0.5 * Get_Cellsize()); m_Edges.Set_NoData_Value(-2); m_Edges.Assign_NoData(); m_bAllVertices = Parameters("ALLVERTICES")->asBool(); //----------------------------------------------------- for(y=0; y= 0 ) { for(int i=0; i<8; i+=2) { if( m_Edges.asInt(Get_xTo(i, x), Get_yTo(i, y)) == -1 ) { Get_Edge(Get_xTo(i, x), Get_yTo(i, y), i + 2, m_Edges.asInt(x, y)); break; } } } } } /////////////////////////////////////////////////////// //----------------------------------------------------- m_Edges.Destroy(); return( true ); } //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::Get_Edge(int x, int y, int i, int Class) { CSG_Shape *pPolygon = m_pPolygons->Get_Shape(Class); if( !pPolygon ) { return( false ); } //----------------------------------------------------- int xFirst, yFirst, ix, iy, iPart; xFirst = x; yFirst = y; iPart = pPolygon->Get_Part_Count(); pPolygon->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), iPart); //----------------------------------------------------- do { ix = Get_xTo(i + 2, x); iy = Get_yTo(i + 2, y); if( m_Edges.is_InGrid(ix, iy) && m_Edges.asInt(ix, iy) == -1 ) // go right ? { pPolygon->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), iPart); i = (i + 2) % 8; } else { if( m_Edges.asInt(ix, iy) == Class ) { m_Edges.Set_NoData(ix, iy); // erase class id in right cells } ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( m_Edges.is_InGrid(ix, iy) && m_Edges.asInt(ix, iy) == -1 ) // go ahead ? { if( m_bAllVertices ) { pPolygon->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), iPart); } } else { ix = Get_xTo(i + 6, x); iy = Get_yTo(i + 6, y); if( m_Edges.is_InGrid(ix, iy) && m_Edges.asInt(ix, iy) == -1 ) // go left ? { pPolygon->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), iPart); i = (i + 6) % 8; } else { return( false ); } } } x = ix; y = iy; } while( x != xFirst || y != yFirst ); pPolygon->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), iPart); if( pPolygon->Get_Point_Count(iPart) < 4 ) { pPolygon->Del_Part(iPart); return( false ); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::Split_Polygons(void) { Process_Set_Text(_TL("splitting polygon parts")); CSG_Shapes Polygons(*m_pPolygons); m_pPolygons->Del_Records(); for(int iPolygon=0; iPolygonGet_Part_Count() && Process_Get_Okay(); iPart++) { if( !pPolygon->is_Lake(iPart) ) { CSG_Shape *pShape = m_pPolygons->Add_Shape(pPolygon, SHAPE_COPY_ATTR); for(iPoint=0, jPart=0; iPointGet_Point_Count(iPart); iPoint++) { pShape->Add_Point(pPolygon->Get_Point(iPoint, iPart), jPart); } for(int kPart=0; kPartGet_Part_Count(); kPart++) { if( pPolygon->is_Lake(kPart) && pPolygon->Contains(pPolygon->Get_Point(0, kPart), iPart) ) { jPart++; for(iPoint=0; iPointGet_Point_Count(kPart); iPoint++) { pShape->Add_Point(pPolygon->Get_Point(iPoint, kPart), jPart); } } } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// /*/--------------------------------------------------------- class CSG_Vector_Topology { public: CSG_Vector_Topology(void) { m_Nodes.Create(SHAPE_TYPE_Point, SG_T("NODES")); m_Nodes.Add_Field(SG_T("ID") , SG_DATATYPE_Int); m_Edges.Create(SHAPE_TYPE_Line , SG_T("EDGES")); m_Edges.Add_Field(SG_T("ID") , SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("NODE_FROM") , SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("NODE_TO") , SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("FACE_LEFT") , SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("FACE_RIGHT"), SG_DATATYPE_Int); m_Edges.Add_Field(SG_T("PROCESSED") , SG_DATATYPE_Int); } virtual ~CSG_Vector_Topology(void) { Destroy(); } bool Destroy (void) { m_Nodes.Del_Records(); m_Edges.Del_Records(); return( true ); } bool Add_Node (int ID, double x, double y) { CSG_Shape *pNode = m_Nodes.Add_Shape(); pNode->Set_Point(x, y, 0); pNode->Set_Value(0, ID); return( true ); } bool Add_Node (int ID, const TSG_Point &Point) { return( Add_Node(ID, Point.x, Point.y) ); } CSG_Shapes m_Nodes, m_Edges; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Classes_To_Shapes::Get_Edges(void) { /////////////////////////////////////////////////////// //----------------------------------------------------- Process_Set_Text(_TL("edge detection")); int y, nEdges = 0; m_Topology.Destroy(); m_Edges.Create(SG_DATATYPE_Int, 2 * Get_NX() + 1, 2 * Get_NY() + 1, 0.5 * Get_Cellsize(), Get_XMin() - 0.5 * Get_Cellsize(), Get_YMin() - 0.5 * Get_Cellsize()); m_Edges.Set_NoData_Value(-2); m_Edges.Assign_NoData(); //----------------------------------------------------- for(y=0; y 2 ) { m_Topology.Add_Node(nNodes, m_Edges.Get_System().Get_Grid_to_World(x, y)); m_Edges.Set_Value(x, y, nNodes++); } } else { m_Edges.Set_Value(x, y, -2); } } } /////////////////////////////////////////////////////// //----------------------------------------------------- Process_Set_Text(_TL("edge collection")); //----------------------------------------------------- for(y=0; y= 0 ) // node { for(int i=0; i<8; i+=2) { if( m_Edges.is_InGrid(Get_xTo(i, x), Get_yTo(i, y)) ) { Get_Edge(x, y, i); } } } } } //----------------------------------------------------- for(y=0; yAdd_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), 0); pEdge->Set_Value(0, m_Topology.m_Edges.Get_Count() - 1); // edge id pEdge->Set_Value(1, m_Edges.asInt(x, y)); // from node int ix, iy; ix = Get_xTo(i - 1, x) / 2; iy = Get_yTo(i - 1, y) / 2; pEdge->Set_Value(3, m_Classes.is_InGrid(ix, iy) ? m_Classes.asInt(ix, iy) : -1); // left face ix = Get_xTo(i + 1, x) / 2; iy = Get_yTo(i + 1, y) / 2; pEdge->Set_Value(4, m_Classes.is_InGrid(ix, iy) ? m_Classes.asInt(ix, iy) : -1); // right face //----------------------------------------------------- do { x = Get_xTo(i, x); y = Get_yTo(i, y); if( m_Edges.asInt(x, y) >= 0 ) // node { pEdge->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), 0); pEdge->Set_Value(2, m_Edges.asInt(x, y)); // to node return( true ); } m_Edges.Set_NoData(x, y); //------------------------------------------------- if( !m_Edges.is_InGrid(Get_xTo(i, x), Get_yTo(i, y)) ) // do not go ahead ? { pEdge->Add_Point(m_Edges.Get_System().Get_Grid_to_World(x, y), 0); if( m_Edges.is_InGrid(Get_xTo(i + 2, x), Get_yTo(i + 2, y)) ) // go right ? { i = (i + 2) % 8; } else if( m_Edges.is_InGrid(Get_xTo(i + 6, x), Get_yTo(i + 6, y)) ) // go left ? { i = (i + 6) % 8; } else { i = -1; } } } while( i >= 0 ); //----------------------------------------------------- m_Topology.m_Edges.Del_Record(m_Topology.m_Edges.Get_Count() - 1); return( false ); }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/Grid_To_Points_Random.h0000744000175000017500000001034312737416202026140 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Points_Random.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_To_Points_Random_H #define HEADER_INCLUDED__Grid_To_Points_Random_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_To_Points_Random : public CSG_Module_Grid { public: CGrid_To_Points_Random(void); virtual ~CGrid_To_Points_Random(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Vectorization") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_To_Points_Random_H saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Statistics_For_Points.h0000744000175000017500000001121212737416202027212 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Statistics_For_Points.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Statistics_For_Points.h // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Statistics_For_Points_H #define HEADER_INCLUDED__Grid_Statistics_For_Points_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Statistics_For_Points : public CSG_Module_Grid { public: CGrid_Statistics_For_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid Values") ); } protected: virtual bool On_Execute (void); private: CSG_Grid_Cell_Addressor m_Kernel; bool Get_Statistics (const TSG_Point &Point, CSG_Grid *pGrid, CSG_Simple_Statistics &Statistics); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Statistics_For_Points_H saga-2.3.1/src/modules/shapes/shapes_grid/Grid_To_Points.cpp0000744000175000017500000002005312737416202025172 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Points.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_To_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_To_Points::CGrid_To_Points(void) { //----------------------------------------------------- Set_Name (_TL("Grid Values to Points")); Set_Author (SG_T("O.Conrad (c) 2001")); Set_Description (_TW( "This module saves grid values to point (grid nodes) or polygon (grid cells) shapes. Optionally only points " "can be saved, which are contained by polygons of the specified shapes layer. " "In addition, it is possible to exclude all cells that are coded NoData in the " "first grid of the grid list." )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "NODATA" , _TL("Exclude NoData Cells"), _TL(""), PARAMETER_TYPE_Bool , true ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("nodes"), _TL("cells") ) ); } //--------------------------------------------------------- CGrid_To_Points::~CGrid_To_Points(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Points::On_Execute(void) { bool bNoNoData; int x, y, iGrid, iPoint, Type; double xPos, yPos; CSG_Grid *pGrid; CSG_Parameter_Grid_List *pGrids; CSG_Shape *pShape; CSG_Shapes *pShapes, *pPolygons; //----------------------------------------------------- pGrids = Parameters("GRIDS") ->asGridList(); pPolygons = Parameters("POLYGONS")->asShapes(); pShapes = Parameters("SHAPES") ->asShapes(); bNoNoData = Parameters("NODATA") ->asBool(); Type = Parameters("TYPE") ->asInt(); //----------------------------------------------------- if( pGrids->Get_Count() > 0 ) { switch( Type ) { case 0: pShapes->Create(SHAPE_TYPE_Point , _TL("Grid Values [Nodes]")); break; case 1: pShapes->Create(SHAPE_TYPE_Polygon, _TL("Grid Values [Cells]")); break; } pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("X" , SG_DATATYPE_Double); pShapes->Add_Field("Y" , SG_DATATYPE_Double); for(iGrid=0; iGridGet_Count(); iGrid++) { pShapes->Add_Field(CSG_String::Format(SG_T("%s"),pGrids->asGrid(iGrid)->Get_Name()).BeforeFirst(SG_Char('.')).c_str(), SG_DATATYPE_Double); } //------------------------------------------------- for(y=0, yPos=Get_YMin() - (Type ? 0.5 * Get_Cellsize() : 0.0), iPoint=0; yasGrid(0)->is_NoData(x, y))) && (!pPolygons || is_Contained(xPos, yPos, pPolygons)) ) { pShape = pShapes->Add_Shape(); switch( Type ) { case 0: pShape->Add_Point(xPos, yPos); break; case 1: pShape->Add_Point(xPos , yPos ); pShape->Add_Point(xPos + Get_Cellsize(), yPos ); pShape->Add_Point(xPos + Get_Cellsize(), yPos + Get_Cellsize()); pShape->Add_Point(xPos , yPos + Get_Cellsize()); break; } pShape->Set_Value(0, ++iPoint); pShape->Set_Value(1, xPos); pShape->Set_Value(2, yPos); for(iGrid=0; iGridGet_Count(); iGrid++) { pGrid = pGrids->asGrid(iGrid); pShape->Set_Value(iGrid + 3, pGrid->is_NoData(x, y) ? -99999 : pGrid->asDouble(x, y)); } } } } return( pShapes->Get_Count() > 0 ); } return( false ); } //--------------------------------------------------------- inline bool CGrid_To_Points::is_Contained(double x, double y, CSG_Shapes *pPolygons) { if( pPolygons && pPolygons->Get_Type() == SHAPE_TYPE_Polygon ) { for(int iPolygon=0; iPolygonGet_Count(); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); if( pPolygon->Contains(x, y) ) { return( true ); } } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Values_AddTo_Shapes.h0000744000175000017500000001126112737416202026537 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Values_AddTo_Shapes.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Values_AddTo_Shapes_H #define HEADER_INCLUDED__Grid_Values_AddTo_Shapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Values_AddTo_Shapes : public CSG_Module { public: CGrid_Values_AddTo_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid Values") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: TSG_Grid_Resampling m_Resampling; void Get_Data_Point (CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid); void Get_Data_Line (CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid); void Get_Data_Polygon (CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Values_AddTo_Shapes_H saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Polygon_Clip.cpp0000744000175000017500000002746712737416202025672 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Polygon_Clip.cpp // // // // Copyright (C) 2006 by // // Stefan Liersch // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stliersch@freenet.de // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Polygon_Clip.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define MASK_OFF -1 #define MASK_ON 1 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // constructor //--------------------------------------------------------- CGrid_Polygon_Clip::CGrid_Polygon_Clip(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Clip Grid with Polygon")); Set_Author (_TL("copyrights (c) 2006 Stefan Liersch")); Set_Description (_TW( "Clips the input grid with a polygon shapefile. Select " "polygons from the shapefile prior to module execution " "in case you like to use only a subset from the shapefile " "for clipping." )); //----------------------------------------------------- // Parameters list... Parameters.Add_Grid_List( NULL, "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT, false ); Parameters.Add_Grid_List( NULL, "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL, "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL, "NODATA" , _TL("Exclude No-Data Area"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // This function is executed if the user is pressing the OK button //--------------------------------------------------------- bool CGrid_Polygon_Clip::On_Execute(void) { int x, y, ix, iy, ax, ay, nx, ny; CSG_Parameter_Grid_List *pGrids_in, *pGrids_out; CSG_Grid *pGrid_in, *pGrid_out, Mask; CSG_Shapes *pShapes; //----------------------------------------------------- pGrids_in = Parameters("INPUT" )->asGridList(); pGrids_out = Parameters("OUTPUT" )->asGridList(); pShapes = Parameters("POLYGONS")->asShapes(); m_bNoData = Parameters("NODATA" )->asBool(); //----------------------------------------------------- if( pShapes->Get_Type() == SHAPE_TYPE_Polygon && pShapes->Get_Count() > 0 && Get_System()->Get_Extent().Intersects(pShapes->Get_Extent()) ) { // create temporary grid. // Cells within the shapefile get the value +1 // Cells outside the shapefile get the value -1 Mask.Create(*Get_System(), SG_DATATYPE_Byte); //------------------------------------------------- // Get_Mask assignes +1 values to gridcells within the shapefile // The function has been copied from Module: 'Grid_Statistics_AddTo_Polygon' // Function: Get_ShapeIDs(...) // and check extent of valid values in Mask to // calculate GridSystem parameters pGrid_out if( Get_Mask(pShapes, &Mask) && Get_Extent(ax, nx, ay, ny, &Mask, pGrids_in) ) { for(int iGrid=0; iGridGet_Count(); iGrid++) { pGrid_in = pGrids_in->asGrid(iGrid); pGrid_out = SG_Create_Grid( // creating the output grid GridSystem pGrid_in->Get_Type(), nx, ny, Get_Cellsize(), Get_XMin() + ax * Get_Cellsize(), Get_YMin() + ay * Get_Cellsize() ); pGrid_out ->Set_Name(pGrid_in->Get_Name()); pGrid_out ->Set_NoData_Value(pGrid_in->Get_NoData_Value()); pGrids_out ->Add_Item(pGrid_out); // Assign valid values from input grid to the cells of the // output grid that are within the borders of the shapefile // Assign NoData values to the cells outside the shapefile borders for(y=0, iy=ay; ySet_Value(x, y, pGrid_in->asDouble(ix, iy)); } else { pGrid_out->Set_NoData(x, y); } } } } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// //--------------------------------------------------------- // This function modifies the incoming integer variables!!! //--------------------------------------------------------- bool CGrid_Polygon_Clip::Get_Extent(int &xMin, int &xCount, int &yMin, int &yCount, CSG_Grid *pMask, CSG_Parameter_Grid_List *pGrids) { bool bFound; for(yMin=0, bFound=false; yMin=yMin && !bFound && Process_Get_Okay(true); yMax--) { for(int x=0; x=xMin && !bFound && Process_Get_Okay(true); xMax--) { for(int y=yMin; y 0 && yCount > 0 ); } return( false ); } //--------------------------------------------------------- bool CGrid_Polygon_Clip::is_InGrid(int x, int y, CSG_Grid *pMask, CSG_Parameter_Grid_List *pGrids) { if( pMask->asInt(x, y) == MASK_ON ) { if( !m_bNoData ) { return( true ); } for(int i=0; iGet_Count(); i++) { if( !pGrids->asGrid(i)->is_NoData(x, y) ) { return( true ); } } } return( false ); } /////////////////////////////////////////////////////////// //--------------------------------------------------------- // This function has been copied from Module: 'Grid_Statistics_AddTo_Polygon' // Function: Get_ShapeIDs(...) // copyright by Olaf Conrad // // added support to clip only with selected polygons (Volker Wichmann) //--------------------------------------------------------- bool CGrid_Polygon_Clip::Get_Mask(CSG_Shapes *pShapes, CSG_Grid *pMask) { bool bFill, *bCrossing; bool bOnlySelected = false; int x, y, ix, xStart, xStop, iShape, iPart, iPoint; double yPos; TSG_Point pLeft, pRight, pa, pb, p; TSG_Rect Extent; CSG_Shape *pShape; //----------------------------------------------------- pMask->Assign(MASK_OFF); bCrossing = (bool *)SG_Malloc(pMask->Get_NX() * sizeof(bool)); if (pShapes->Get_Selection_Count() > 0) bOnlySelected = true; //----------------------------------------------------- for(iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { if (bOnlySelected && !pShapes->Get_Shape(iShape)->is_Selected()) continue; pShape = pShapes->Get_Shape(iShape); Extent = pShape->Get_Extent().m_rect; xStart = Get_System()->Get_xWorld_to_Grid(Extent.xMin) - 1; if( xStart < 0 ) xStart = 0; xStop = Get_System()->Get_xWorld_to_Grid(Extent.xMax) + 1; if( xStop >= Get_NX() ) xStop = Get_NX() - 1; pLeft.x = pMask->Get_XMin() - 1.0; pRight.x = pMask->Get_XMax() + 1.0; //------------------------------------------------- for(y=0, yPos=pMask->Get_YMin(); yGet_NY(); y++, yPos+=pMask->Get_Cellsize()) { if( yPos >= Extent.yMin && yPos <= Extent.yMax ) { memset(bCrossing, 0, pMask->Get_NX() * sizeof(bool)); pLeft.y = pRight.y = yPos; //----------------------------------------- for(iPart=0; iPartGet_Part_Count(); iPart++) { pb = pShape->Get_Point(pShape->Get_Point_Count(iPart) - 1, iPart); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { pa = pb; pb = pShape->Get_Point(iPoint, iPart); if( ( (pa.y <= yPos && yPos < pb.y) || (pa.y > yPos && yPos >= pb.y) ) ) { SG_Get_Crossing(p, pa, pb, pLeft, pRight, false); ix = (int)((p.x - pMask->Get_XMin()) / pMask->Get_Cellsize() + 1.0); if( ix < 0) { ix = 0; } else if( ix >= pMask->Get_NX() ) { continue; } bCrossing[ix] = !bCrossing[ix]; } } } //----------------------------------------- for(x=xStart, bFill=false; x<=xStop; x++) { if( bCrossing[x] ) { bFill = !bFill; } if( bFill ) { pMask->Set_Value(x, y, MASK_ON); } } } } } //----------------------------------------------------- SG_Free(bCrossing); return( true ); } saga-2.3.1/src/modules/shapes/shapes_grid/Grid_To_Gradient.cpp0000744000175000017500000002766512737416202025473 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Gradient.cpp // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_To_Gradient.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_To_Gradient::CGrid_To_Gradient(int Method) { m_Method = Method; Set_Author (SG_T("O.Conrad (c) 2006")); //----------------------------------------------------- switch( m_Method ) { case 0: // surface Set_Name (_TL("Gradient Vectors from Surface")); Set_Description (_TW( "Create lines indicating the gradient. " )); Parameters.Add_Grid( NULL , "SURFACE" , _TL("Surface"), _TL(""), PARAMETER_INPUT ); break; case 1: // direction and length Set_Name (_TL("Gradient Vectors from Direction and Length")); Set_Description (_TW( "Create lines indicating the gradient. " )); Parameters.Add_Grid( NULL , "DIR" , _TL("Direction"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "LEN" , _TL("Length"), _TL(""), PARAMETER_INPUT ); break; case 2: // directional components Set_Name (_TL("Gradient Vectors from Directional Components")); Set_Description (_TW( "Create lines indicating the gradient. " )); Parameters.Add_Grid( NULL , "X" , _TL("X Component"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "Y" , _TL("Y Component"), _TL(""), PARAMETER_INPUT ); break; } //----------------------------------------------------- Parameters.Add_Shapes( NULL , "VECTORS" , _TL("Gradient Vectors"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "STEP" , _TL("Step"), _TL(""), PARAMETER_TYPE_Int , 1.0, 1.0, true ); Parameters.Add_Range( NULL , "SIZE" , _TL("Size Range"), _TL("size range as percentage of step"), 25.0, 100.0, 0.0, true ); Parameters.Add_Choice( NULL , "AGGR" , _TL("Aggregation"), _TL("how to request values if step size is more than one cell"), CSG_String::Format(SG_T("%s|%s|"), _TL("nearest neighbour"), _TL("mean value") ), 1 ); Parameters.Add_Choice( NULL , "STYLE" , _TL("Style"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("simple line"), _TL("arrow"), _TL("arrow (centered to cell)") ), 2 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Gradient::On_Execute(void) { int x, y, Step; double sMin, sRange, ex, ey, d; TSG_Point p; TSG_Grid_Resampling Interpolation; CSG_Grid_System System; CSG_Grid EX, EY, D; CSG_Shapes *pVectors; //----------------------------------------------------- pVectors = Parameters("VECTORS") ->asShapes(); Step = Parameters("STEP") ->asInt(); m_Style = Parameters("STYLE") ->asInt(); sMin = Parameters("SIZE") ->asRange()->Get_LoVal() * Step * Get_Cellsize() / 100.0; sRange = Parameters("SIZE") ->asRange()->Get_HiVal() * Step * Get_Cellsize() / 100.0 - sMin; Interpolation = Parameters("AGGR") ->asInt() == 0 ? GRID_RESAMPLING_NearestNeighbour : GRID_RESAMPLING_Mean_Cells; //----------------------------------------------------- if( Step > Get_NX() || Step > Get_NY() ) { Error_Set(_TL("step size should not exceed number of cells in x or y direction")); return( false ); } //----------------------------------------------------- // System.Assign(Step * Get_Cellsize(), Get_XMin(), Get_YMin(), Get_NX() / Step, Get_NY() / Step); System.Assign(Step * Get_Cellsize(), Get_XMin(), Get_YMin(), Get_System()->Get_XMax(), Get_System()->Get_YMax()); EX.Create(System); EY.Create(System); D .Create(System); D .Assign_NoData(); switch( m_Method ) { //----------------------------------------------------- case 0: // surface { CSG_Grid Surface(System), *pSurface = Parameters("SURFACE")->asGrid(); Surface.Assign(pSurface, Interpolation); pVectors->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s]"), pSurface->Get_Name(), _TL("Gradient"))); for(y=0; yasGrid(), _X(*Get_System()); CSG_Grid *pLen = Parameters("LEN")->asGrid(), _Y(*Get_System()); for(y=0; yis_NoData(x, y) && !pLen->is_NoData(x, y) ) { _X.Set_Value(x, y, pLen->asDouble(x, y) * sin(pDir->asDouble(x, y))); _Y.Set_Value(x, y, pLen->asDouble(x, y) * cos(pDir->asDouble(x, y))); } else { _X.Set_NoData(x, y); _Y.Set_NoData(x, y); } } } CSG_Grid X(System); X.Assign(&_X, Interpolation); CSG_Grid Y(System); Y.Assign(&_Y, Interpolation); pVectors->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s|%s]"), _TL("Gradient"), pDir->Get_Name(), pLen->Get_Name())); for(y=0; y 0.0 ) { EX.Set_Value(x, y, X.asDouble(x, y) / d); EY.Set_Value(x, y, Y.asDouble(x, y) / d); D .Set_Value(x, y, d); } } } } break; //----------------------------------------------------- case 2: // directional components { CSG_Grid X(System), *pX = Parameters("X")->asGrid(); X.Assign(pX, Interpolation); CSG_Grid Y(System), *pY = Parameters("Y")->asGrid(); Y.Assign(pY, Interpolation); pVectors->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s|%s]"), _TL("Gradient"), pX->Get_Name(), pY->Get_Name())); for(y=0; y 0.0 ) { EX.Set_Value(x, y, X.asDouble(x, y) / d); EY.Set_Value(x, y, Y.asDouble(x, y) / d); D .Set_Value(x, y, d); } } } } break; } //----------------------------------------------------- pVectors->Add_Field("EX" , SG_DATATYPE_Double); pVectors->Add_Field("EY" , SG_DATATYPE_Double); pVectors->Add_Field("LEN" , SG_DATATYPE_Double); pVectors->Add_Field("DIR" , SG_DATATYPE_Double); if( D.Get_ZRange() > 0.0 ) { sRange = sRange / D.Get_ZRange(); } //----------------------------------------------------- for(y=0, p.y=System.Get_YMin(); yAdd_Shape(); ex = EX.asDouble(x, y); ey = EY.asDouble(x, y); d = D .asDouble(x, y); pVector->Set_Value(0, ex); pVector->Set_Value(1, ey); pVector->Set_Value(2, d); pVector->Set_Value(3, atan2(ex, ey) * M_RAD_TO_DEG); if( (d = sMin + sRange * (d - D.Get_ZMin())) > 0.0 ) { Set_Vector(pVector, p, d * ex, d * ey); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define ADD_TO_VECTOR(I, X, Y) (pVector->Add_Point(Point.x + ((X) * dy + (Y) * dx), Point.y + ((Y) * dy - (X) * dx), I)) //--------------------------------------------------------- inline void CGrid_To_Gradient::Set_Vector(CSG_Shape *pVector, const TSG_Point &Point, double dx, double dy) { switch( m_Style ) { case 0: ADD_TO_VECTOR(0, 0.00, 0.00); ADD_TO_VECTOR(0, 0.00, 1.00); break; case 1: ADD_TO_VECTOR(0, 0.00, 0.00); ADD_TO_VECTOR(0, 0.00, 1.00); ADD_TO_VECTOR(1, 0.20, 0.75); ADD_TO_VECTOR(1, 0.00, 1.00); ADD_TO_VECTOR(1, -0.20, 0.75); break; case 2: ADD_TO_VECTOR(0, 0.00, -0.50); ADD_TO_VECTOR(0, 0.00, 0.50); ADD_TO_VECTOR(1, 0.20, 0.25); ADD_TO_VECTOR(1, 0.00, 0.50); ADD_TO_VECTOR(1, -0.20, 0.25); break; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/grid_rectangle_clip.cpp0000744000175000017500000001702712737416202026276 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_rectangle_clip.cpp // // // // Copyright (C) 2013 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_rectangle_clip.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Rectangle_Clip::CGrid_Rectangle_Clip(void) { //----------------------------------------------------- Set_Name (_TL("Clip Grid with Rectangle")); Set_Author (_TL("V. Wichmann (c) 2013")); Set_Description (_TW( "Clips the input grid with the (rectangular) extent of a shapefile. " "The clipped grid will have the extent of the shapefile.\n" "Select shapes from the shapefile prior to module execution " "in case you like to use only a subset from the shapefile " "for clipping.\n\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "INPUT" , _TL("Input"), _TL("The grid to clip."), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Extent"), _TL("The shapefile to use for clipping."), PARAMETER_INPUT ); Parameters.Add_Choice( NULL , "BORDER" , _TL("Border"), _TL("Set grid extent to grid cells (pixel as area), to grid nodes (pixel as point) or align to grid system."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("grid cells"), _TL("grid nodes"), _TL("align to grid system") ), 0 ); Parameters.Add_Grid_Output( NULL , "OUTPUT" , _TL("Output"), _TL("The clipped grid.") ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Rectangle_Clip::On_Execute(void) { CSG_Grid *pGrid_in, *pGrid_out; CSG_Shapes *pShapes; int iMethod; //----------------------------------------------------- pGrid_in = Parameters("INPUT") ->asGrid(); pShapes = Parameters("SHAPES") ->asShapes(); iMethod = Parameters("BORDER") ->asInt(); //----------------------------------------------------- CSG_Rect Extent; if( pShapes->Get_Selection_Count() > 0 ) { bool bFirst = true; for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { if( pShapes->Get_Shape(iShape)->is_Selected() ) { if( bFirst ) { Extent = pShapes->Get_Shape(iShape)->Get_Extent(); bFirst = false; } else { Extent.Union(pShapes->Get_Shape(iShape)->Get_Extent()); } } } } else Extent = pShapes->Get_Extent(); //----------------------------------------------------- if( iMethod == 0 ) { Extent.Deflate(0.5 * pGrid_in->Get_Cellsize(), 0.5 * pGrid_in->Get_Cellsize(), false); } else if( iMethod == 2 ) { double d, minX, minY; d = Extent.Get_XMin() - pGrid_in->Get_XMin(true); minX = pGrid_in->Get_XMin(true) + floor(d / pGrid_in->Get_Cellsize()) * pGrid_in->Get_Cellsize() + 0.5 * pGrid_in->Get_Cellsize(); d = Extent.Get_YMin() - pGrid_in->Get_YMin(true); minY = pGrid_in->Get_YMin(true) + floor(d / pGrid_in->Get_Cellsize()) * pGrid_in->Get_Cellsize() + 0.5 * pGrid_in->Get_Cellsize(); Extent.Set_BottomLeft(minX, minY); } CSG_Grid_System GridSystem(pGrid_in->Get_Cellsize(), Extent); pGrid_out = SG_Create_Grid(GridSystem, pGrid_in->Get_Type()); pGrid_out->Set_NoData_Value(pGrid_in->Get_NoData_Value()); pGrid_out->Set_Name(CSG_String::Format(SG_T("%s_clip"), pGrid_in->Get_Name())); pGrid_out->Assign_NoData(); //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, pGrid_out->Get_NY()); y++) { #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double xWorld = GridSystem.Get_xGrid_to_World(x); double yWorld = GridSystem.Get_yGrid_to_World(y); int xGrid, yGrid; pGrid_in->Get_System().Get_World_to_Grid(xGrid, yGrid, xWorld, yWorld); if (pGrid_in->is_InGrid(xGrid, yGrid)) pGrid_out->Set_Value(x, y, pGrid_in->asDouble(xGrid, yGrid)); } } //----------------------------------------------------- Parameters("OUTPUT")->Set_Value(pGrid_out); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/Grid_To_Gradient.h0000744000175000017500000001063312737416202025123 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Gradient.h // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_To_Gradient_H #define HEADER_INCLUDED__Grid_To_Gradient_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_To_Gradient : public CSG_Module_Grid { public: CGrid_To_Gradient(int Method); virtual CSG_String Get_MenuPath (void) { return( _TL("Vectorization") ); } protected: virtual bool On_Execute (void); bool Initialize (void); private: int m_Method, m_Style; void Set_Vector (CSG_Shape *pVector, const TSG_Point &Point, double dx, double dy); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_To_Gradient_H saga-2.3.1/src/modules/shapes/shapes_grid/Makefile.in0000664000175000017500000006101512737447617023672 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/shapes/shapes_grid ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libshapes_grid_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libshapes_grid_la_OBJECTS = Grid_Classes_To_Shapes.lo \ grid_extent.lo grid_local_extremes_to_points.lo \ Grid_Polygon_Clip.lo grid_rectangle_clip.lo \ Grid_Statistics_AddTo_Polygon.lo Grid_Statistics_For_Points.lo \ Grid_To_Contour.lo Grid_To_Gradient.lo Grid_To_Points.lo \ Grid_To_Points_Random.lo Grid_Values_AddTo_Points.lo \ Grid_Values_AddTo_Shapes.lo MLB_Interface.lo libshapes_grid_la_OBJECTS = $(am_libshapes_grid_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libshapes_grid_la_SOURCES) DIST_SOURCES = $(libshapes_grid_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id$ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_grid.la libshapes_grid_la_SOURCES = \ Grid_Classes_To_Shapes.cpp\ grid_extent.cpp\ grid_local_extremes_to_points.cpp\ Grid_Polygon_Clip.cpp\ grid_rectangle_clip.cpp\ Grid_Statistics_AddTo_Polygon.cpp\ Grid_Statistics_For_Points.cpp\ Grid_To_Contour.cpp\ Grid_To_Gradient.cpp\ Grid_To_Points.cpp\ Grid_To_Points_Random.cpp\ Grid_Values_AddTo_Points.cpp\ Grid_Values_AddTo_Shapes.cpp\ MLB_Interface.cpp\ Grid_Classes_To_Shapes.h\ grid_extent.h\ grid_local_extremes_to_points.h\ Grid_Polygon_Clip.h\ grid_rectangle_clip.h\ Grid_Statistics_AddTo_Polygon.h\ Grid_Statistics_For_Points.h\ Grid_To_Contour.h\ Grid_To_Gradient.h\ Grid_To_Points.h\ Grid_To_Points_Random.h\ Grid_Values_AddTo_Points.h\ Grid_Values_AddTo_Shapes.h\ MLB_Interface.h libshapes_grid_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/shapes/shapes_grid/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/shapes/shapes_grid/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libshapes_grid.la: $(libshapes_grid_la_OBJECTS) $(libshapes_grid_la_DEPENDENCIES) $(EXTRA_libshapes_grid_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libshapes_grid_la_OBJECTS) $(libshapes_grid_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Classes_To_Shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Polygon_Clip.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Statistics_AddTo_Polygon.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Statistics_For_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_To_Contour.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_To_Gradient.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_To_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_To_Points_Random.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Values_AddTo_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_Values_AddTo_Shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_extent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_local_extremes_to_points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_rectangle_clip.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Values_AddTo_Points.h0000744000175000017500000001035312737416202026571 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Values_AddTo_Points.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Values_AddTo_Points_H #define HEADER_INCLUDED__Grid_Values_AddTo_Points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Values_AddTo_Points : public CSG_Module { public: CGrid_Values_AddTo_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid Values") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Values_AddTo_Points_H saga-2.3.1/src/modules/shapes/shapes_grid/grid_extent.h0000744000175000017500000001040112737416202024264 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_extent.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_extent.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_extent_H #define HEADER_INCLUDED__grid_extent_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Extent : public CSG_Module_Grid { public: CGrid_Extent(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Spatial Extent") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_extent_H saga-2.3.1/src/modules/shapes/shapes_grid/grid_local_extremes_to_points.cpp0000744000175000017500000001521412737416202030423 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_local_extremes_to_points.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_local_extremes_to_points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Local_Extremes_to_Points::CGrid_Local_Extremes_to_Points(void) { Set_Name (_TL("Local Minima and Maxima")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "Extracts local grid value minima and maxima of to vector points." )); Parameters.Add_Grid( NULL, "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL, "MINIMA" , _TL("Minima"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL, "MAXIMA" , _TL("Maxima"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Local_Extremes_to_Points::On_Execute(void) { CSG_Grid *pGrid = Parameters("GRID")->asGrid(); //----------------------------------------------------- CSG_Shapes *pMinima = Parameters("MINIMA")->asShapes(); pMinima->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pGrid->Get_Name(), _TL("Local Minima"))); pMinima->Add_Field(SG_T("GRID_X"), SG_DATATYPE_Int); pMinima->Add_Field(SG_T("GRID_Y"), SG_DATATYPE_Int); pMinima->Add_Field(SG_T("X" ), SG_DATATYPE_Double); pMinima->Add_Field(SG_T("Y" ), SG_DATATYPE_Double); pMinima->Add_Field(SG_T("Z" ), SG_DATATYPE_Double); //----------------------------------------------------- CSG_Shapes *pMaxima = Parameters("MAXIMA")->asShapes(); pMaxima->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pGrid->Get_Name(), _TL("Local Maxima"))); pMaxima->Add_Field(SG_T("GRID_X"), SG_DATATYPE_Int); pMaxima->Add_Field(SG_T("GRID_Y"), SG_DATATYPE_Int); pMaxima->Add_Field(SG_T("X" ), SG_DATATYPE_Double); pMaxima->Add_Field(SG_T("Y" ), SG_DATATYPE_Double); pMaxima->Add_Field(SG_T("Z" ), SG_DATATYPE_Double); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { double z = pGrid->asDouble(x, y); bool bMinimum = true; bool bMaximum = true; for(int i=0; i<8 && (bMinimum || bMaximum); i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( !pGrid->is_InGrid(ix, iy) ) { bMinimum = bMaximum = false; } else { double iz = pGrid->asDouble(ix, iy); if( iz <= z ) { bMinimum = false; } else if( iz >= z ) { bMaximum = false; } } } //----------------------------------------- CSG_Shape *pPoint = bMinimum ? pMinima->Add_Shape() : bMaximum ? pMaxima->Add_Shape() : NULL; if( pPoint ) { TSG_Point p = Get_System()->Get_Grid_to_World(x, y); pPoint->Set_Point(p, 0); pPoint->Set_Value(0, x); pPoint->Set_Value(1, y); pPoint->Set_Value(2, p.x); pPoint->Set_Value(3, p.y); pPoint->Set_Value(4, z); } } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/Grid_To_Points_Random.cpp0000744000175000017500000001240312737416202026472 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Points_Random.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "Grid_To_Points_Random.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_To_Points_Random::CGrid_To_Points_Random() { Set_Name (_TL("Grid Values to Points (randomly)")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Extract randomly points from gridded data." )); Parameters.Add_Grid( NULL, "GRID" , _TL("Grid") , _TL(""), PARAMETER_INPUT); Parameters.Add_Value( NULL, "FREQ" , _TL("Frequency") , _TL("One per x"), PARAMETER_TYPE_Int, 100, 1, true); Parameters.Add_Shapes( NULL, "POINTS" , _TL("Points") , _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point); } //--------------------------------------------------------- CGrid_To_Points_Random::~CGrid_To_Points_Random() {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Points_Random::On_Execute(void) { int x, y, n; double frequency; CSG_Grid *pGrid; CSG_Shape *pShape; CSG_Shapes *pShapes; pGrid = Parameters("GRID")->asGrid(); frequency = 1.0 / Parameters("FREQ")->asDouble(); pShapes = Parameters("POINTS")->asShapes(); pShapes->Create(SHAPE_TYPE_Point, pGrid->Get_Name()); pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("VALUE" , SG_DATATYPE_Double); srand((unsigned)time(NULL)); for(n=0, y=0; yAdd_Shape(); pShape->Add_Point( pGrid->Get_XMin() + x * Get_Cellsize(), pGrid->Get_YMin() + y * Get_Cellsize() ); pShape->Set_Value(0, ++n); pShape->Set_Value(1, pGrid->asDouble(x, y)); } } } return( true ); } saga-2.3.1/src/modules/shapes/shapes_grid/Makefile.am0000744000175000017500000000222112737416202023634 0ustar00oconradoconrad00000000000000# # $Id$ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libshapes_grid.la libshapes_grid_la_SOURCES =\ Grid_Classes_To_Shapes.cpp\ grid_extent.cpp\ grid_local_extremes_to_points.cpp\ Grid_Polygon_Clip.cpp\ grid_rectangle_clip.cpp\ Grid_Statistics_AddTo_Polygon.cpp\ Grid_Statistics_For_Points.cpp\ Grid_To_Contour.cpp\ Grid_To_Gradient.cpp\ Grid_To_Points.cpp\ Grid_To_Points_Random.cpp\ Grid_Values_AddTo_Points.cpp\ Grid_Values_AddTo_Shapes.cpp\ MLB_Interface.cpp\ Grid_Classes_To_Shapes.h\ grid_extent.h\ grid_local_extremes_to_points.h\ Grid_Polygon_Clip.h\ grid_rectangle_clip.h\ Grid_Statistics_AddTo_Polygon.h\ Grid_Statistics_For_Points.h\ Grid_To_Contour.h\ Grid_To_Gradient.h\ Grid_To_Points.h\ Grid_To_Points_Random.h\ Grid_Values_AddTo_Points.h\ Grid_Values_AddTo_Shapes.h\ MLB_Interface.h libshapes_grid_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Polygon_Clip.h0000744000175000017500000001051512737416202025321 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Polygon_Clip.h // // // // Copyright (C) 2006 by // // Stefan Liersch // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stliersch@freenet.de // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Polygon_Clip_H #define HEADER_INCLUDED__Grid_Polygon_Clip_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Polygon_Clip : public CSG_Module_Grid { public: // constructor CGrid_Polygon_Clip(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Spatial Extent") ); } protected: // execute module virtual bool On_Execute (void); private: bool m_bNoData; // estimates the Extent of the new grid bool Get_Extent (int &xMin, int &xCount, int &yMin, int &yCount, CSG_Grid *pMask, CSG_Parameter_Grid_List *pGrids); bool is_InGrid (int x, int y, CSG_Grid *pMask, CSG_Parameter_Grid_List *pGrids); // This function has been copied from Module: 'Grid_Statistics_AddTo_Polygon' // Function: Get_ShapeIDs // copyright by Olaf Conrad bool Get_Mask (CSG_Shapes *pShapes, CSG_Grid *pMask); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Polygon_Clip_H saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Classes_To_Shapes.h0000744000175000017500000001122012737416202026257 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Classes_To_Shapes.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Classes_To_Shapes_H #define HEADER_INCLUDED__Grid_Classes_To_Shapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Classes_To_Shapes : public CSG_Module_Grid { public: CGrid_Classes_To_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Vectorization") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool m_bAllVertices; CSG_Grid m_Classes, m_Edges; CSG_Shapes *m_pPolygons; bool Get_Classes (void); CSG_String Get_Class_Name (double Value, CSG_Table *pLUT); bool Get_Edges (void); bool Get_Edge (int x, int y, int i, int Class); bool Split_Polygons (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Classes_To_Shapes_H saga-2.3.1/src/modules/shapes/shapes_grid/Grid_To_Contour.cpp0000744000175000017500000006231312737416202025354 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_To_Contour.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_To_Contour.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_To_Contour::CGrid_To_Contour(void) { //----------------------------------------------------- Set_Name (_TL("Contour Lines from Grid")); Set_Author ("O.Conrad (c) 2001"); Set_Description (_TW( "Derive contour lines (isolines) from grid. " )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "CONTOUR" , _TL("Contour"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "VERTEX" , _TL("Vertex Type"), _TL("choose vertex type for resulting contours"), CSG_String::Format("%s|%s|", SG_T("x, y"), SG_T("x, y, z") ), 0 ); Parameters.Add_Value( NULL , "SCALE" , _TL("Interpolation Scale"), _TL("set greater one for line smoothing"), PARAMETER_TYPE_Double, 1.0, 0, true ); Parameters.Add_Value( NULL , "LINE_PARTS" , _TL("Split Parts"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "POLY_PARTS" , _TL("Split Polygon Parts"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "ZMIN" , _TL("Minimum Contour Value"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( NULL , "ZMAX" , _TL("Maximum Contour Value"), _TL(""), PARAMETER_TYPE_Double, 10000.0 ); Parameters.Add_Value( NULL , "ZSTEP" , _TL("Equidistance"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_To_Contour::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "GRID") && pParameter->asGrid() != NULL ) { double zStep = SG_Get_Rounded_To_SignificantFigures(pParameter->asGrid()->Get_ZRange() / 10.0, 1); pParameters->Get_Parameter("ZSTEP")->Set_Value(zStep); pParameters->Set_Enabled("ZMAX", zStep > 0.0); if( zStep > 0.0 ) { pParameters->Get_Parameter("ZMIN")->Set_Value(zStep * floor(pParameter->asGrid()->Get_ZMin() / zStep)); pParameters->Get_Parameter("ZMAX")->Set_Value(zStep * ceil (pParameter->asGrid()->Get_ZMax() / zStep)); } else { pParameters->Get_Parameter("ZMIN")->Set_Value(pParameter->asGrid()->Get_ZMin()); pParameters->Get_Parameter("ZMAX")->Set_Value(pParameter->asGrid()->Get_ZMax()); } } return( 0 ); } //--------------------------------------------------------- int CGrid_To_Contour::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "ZSTEP") ) { pParameters->Set_Enabled("ZMAX", pParameter->asDouble() > 0.0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "POLYGONS") ) { pParameters->Set_Enabled("LINE_PARTS", pParameter->asShapes() == NULL); pParameters->Set_Enabled("POLY_PARTS", pParameter->asShapes() != NULL); } return( 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Contour::On_Execute(void) { CSG_Grid Grid; //----------------------------------------------------- m_pGrid = Parameters("GRID" )->asGrid (); m_pContours = Parameters("CONTOUR" )->asShapes(); m_pPolygons = Parameters("POLYGONS" )->asShapes(); m_bParts = Parameters("LINE_PARTS")->asBool () && !m_pPolygons; // only split parts if polygons are not requested double zMin = Parameters("ZMIN" )->asDouble(); double zMax = Parameters("ZMAX" )->asDouble(); double zStep = Parameters("ZSTEP" )->asDouble(); //----------------------------------------------------- CSG_String Name; if( zStep <= 0 ) // just one contour value (zMin) { zStep = 1; zMax = zMin; Name = Name.Format("%s [%s %s]", m_pGrid->Get_Name(), _TL("Contour" ), SG_Get_String(zMin ).c_str()); } else { if( zMin < m_pGrid->Get_ZMin() ) { zMin += zStep * (int)((m_pGrid->Get_ZMin() - zMin) / zStep); } Name = Name.Format("%s [%s %s]", m_pGrid->Get_Name(), _TL("Interval"), SG_Get_String(zStep).c_str()); } if( zMax > m_pGrid->Get_ZMax() ) { zMax = m_pGrid->Get_ZMax(); } //----------------------------------------------------- m_pContours->Create(SHAPE_TYPE_Line, Name, NULL, Parameters("VERTEX")->asInt() == 0 ? SG_VERTEX_TYPE_XY : SG_VERTEX_TYPE_XYZ); m_pContours->Add_Field("ID", SG_DATATYPE_Int); m_pContours->Add_Field("Z" , SG_DATATYPE_Double); if( m_pPolygons ) { m_pPolygons->Create(SHAPE_TYPE_Polygon, m_pContours->Get_Name(), NULL, Parameters("VERTEX")->asInt() == 0 ? SG_VERTEX_TYPE_XY : SG_VERTEX_TYPE_XYZ ); m_pPolygons->Add_Field("ID" , SG_DATATYPE_Int ); m_pPolygons->Add_Field("MIN" , SG_DATATYPE_Double); m_pPolygons->Add_Field("MAX" , SG_DATATYPE_Double); m_pPolygons->Add_Field("RANGE", SG_DATATYPE_String); } //----------------------------------------------------- double Scale = Parameters("SCALE")->asDouble(); if( Scale > 0.0 && Scale != 1.0 ) { if( !Grid.Create(CSG_Grid_System(m_pGrid->Get_Cellsize() / Scale, m_pGrid->Get_Extent()), m_pGrid->Get_Type()) ) { Error_Set(_TL("could allocate memory for scaled grid")); return( false ); } Grid.Assign(m_pGrid, GRID_RESAMPLING_BSpline); m_pGrid = &Grid; } //----------------------------------------------------- m_Edge.Create(SG_DATATYPE_Char, m_pGrid->Get_NX() + 1, m_pGrid->Get_NY() + 1, m_pGrid->Get_Cellsize(), m_pGrid->Get_XMin(), m_pGrid->Get_YMin()); for(double z=zMin; z<=zMax && Set_Progress(z - zMin, zMax - zMin); z+=zStep) { if( z >= m_pGrid->Get_ZMin() && z <= m_pGrid->Get_ZMax() ) { Process_Set_Text(CSG_String::Format("%s: %s", _TL("Contour"), SG_Get_String(z, -2).c_str())); Get_Contour(z); } } //----------------------------------------------------- if( m_pPolygons && m_pContours->Get_Count() > 0 && Set_Progress(0)) { Get_Polygons(NULL, (CSG_Shape_Line *)m_pContours->Get_Shape(0)); for(int i=1; iGet_Count() && Set_Progress(i, m_pContours->Get_Count()); i++) { Get_Polygons((CSG_Shape_Line *)m_pContours->Get_Shape(i - 1), (CSG_Shape_Line *)m_pContours->Get_Shape(i)); } if( Set_Progress(100) ) { Get_Polygons((CSG_Shape_Line *)m_pContours->Get_Shape(m_pContours->Get_Count() - 1), NULL); } if( Parameters("POLY_PARTS")->asBool() ) { Split_Polygon_Parts(m_pPolygons); } } m_Edge.Destroy(); //----------------------------------------------------- return( m_pContours->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define EDGE_ROW 0x01 #define EDGE_COL 0x02 //--------------------------------------------------------- inline bool CGrid_To_Contour::is_Edge(int x, int y) { return( m_pGrid->is_InGrid(x , y ) && (!m_pGrid->is_InGrid(x - 1, y - 1) || !m_pGrid->is_InGrid(x , y - 1) || !m_pGrid->is_InGrid(x + 1, y - 1) || !m_pGrid->is_InGrid(x + 1, y ) || !m_pGrid->is_InGrid(x + 1, y + 1) || !m_pGrid->is_InGrid(x , y + 1) || !m_pGrid->is_InGrid(x - 1, y + 1) || !m_pGrid->is_InGrid(x - 1, y ) ) ); } //--------------------------------------------------------- inline void CGrid_To_Contour::Set_Row(int x, int y, bool bOn) { int Edge = m_Edge.asInt(x, y); m_Edge.Set_Value(x, y, bOn ? (Edge | EDGE_ROW) : (Edge & EDGE_COL)); } inline bool CGrid_To_Contour::Get_Row(int x, int y) { return( (m_Edge.asInt(x, y) & EDGE_ROW) != 0 ); } //--------------------------------------------------------- inline void CGrid_To_Contour::Set_Col(int x, int y, bool bOn) { int Edge = m_Edge.asInt(x, y); m_Edge.Set_Value(x, y, bOn ? (Edge | EDGE_COL) : (Edge & EDGE_ROW)); } inline bool CGrid_To_Contour::Get_Col(int x, int y) { return( (m_Edge.asInt(x, y) & EDGE_COL) != 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Contour::Get_Contour(double z) { int x, y; //----------------------------------------------------- #pragma omp parallel for private(x, y) for(y=0; yGet_NY(); y++) // Find Border Cells { for(x=0; xGet_NX(); x++) { if( !m_pGrid->is_NoData(x, y) ) { if( m_pGrid->asDouble(x, y) >= z ) { if( m_pGrid->is_InGrid(x + 1, y ) && m_pGrid->asDouble(x + 1, y ) < z ) Set_Row(x, y, true); if( m_pGrid->is_InGrid(x , y + 1) && m_pGrid->asDouble(x , y + 1) < z ) Set_Col(x, y, true); } else // if( m_pGrid->asDouble(x, y) < z ) { if( m_pGrid->is_InGrid(x + 1, y ) && m_pGrid->asDouble(x + 1, y ) >= z ) Set_Row(x, y, true); if( m_pGrid->is_InGrid(x , y + 1) && m_pGrid->asDouble(x , y + 1) >= z ) Set_Col(x, y, true); } } } } //----------------------------------------------------- if( m_bParts == false ) { CSG_Shape *pContour = m_pContours->Add_Shape(); pContour->Set_Value(0, m_pContours->Get_Count()); pContour->Set_Value(1, z); } for(y=0; yGet_NY(); y++) // find unclosed contours first so that these start/end at edges and not somewhere else { for(x=0; xGet_NX(); x++) { if( m_Edge.asInt(x, y) && is_Edge(x, y) ) { Get_Contour(z, x, y); } } } for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { while( Get_Contour(z, x, y) ); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Contour::Get_Contour(double z, int x, int y) { //----------------------------------------------------- bool bRow; if( Get_Row(x, y) ) { bRow = true; } else if( Get_Col(x, y) ) { bRow = false; } else { return( false ); } //----------------------------------------------------- int iPart; CSG_Shape *pContour; if( m_bParts == false ) { pContour = m_pContours->Get_Shape(m_pContours->Get_Count() - 1); iPart = pContour->Get_Part_Count(); } else { pContour = m_pContours->Add_Shape(); iPart = 0; pContour->Set_Value(0, m_pContours->Get_Count()); pContour->Set_Value(1, z); } //----------------------------------------------------- for(int Dir=0, x0=x, y0=y, bRow0=bRow?1:0; Dir>=0; ) { int zx = bRow ? x + 1 : x; int zy = bRow ? y : y + 1; double d = m_pGrid->asDouble(x, y); d = (d - z) / (d - m_pGrid->asDouble(zx, zy)); pContour->Add_Point( m_pGrid->Get_XMin() + m_pGrid->Get_Cellsize() * (x + d * (zx - x)), m_pGrid->Get_YMin() + m_pGrid->Get_Cellsize() * (y + d * (zy - y)), iPart ); if( pContour->Get_Vertex_Type() != SG_VERTEX_TYPE_XY ) { pContour->Set_Z(z, pContour->Get_Point_Count(iPart) - 1, iPart); } if( Get_Contour_Cell(Dir, x, y, bRow) || Get_Contour_Cell(Dir, x, y, bRow) ) { if( bRow ) { Set_Row(x , y , false); } else { Set_Col(x , y , false); } } else { if( bRow0 ) { Set_Row(x0, y0, false); } else { Set_Col(x0, y0, false); } Dir = -1; } } //----------------------------------------------------- return( pContour->Get_Point_Count(iPart) > 1 ); } //--------------------------------------------------------- inline bool CGrid_To_Contour::Get_Contour_Cell(int &Dir, int &x, int &y, bool &bRow) { if( bRow ) { switch( Dir ) { case 0: if( Get_Row(x , y + 1) ) { Dir = 5; y++; return( true ); } // Norden case 1: if( Get_Col(x + 1, y ) ) { Dir = 6; bRow = false; x++; return( true ); } // Nord-Ost case 2: // Osten ist nicht... case 3: if( y - 1 >= 0 && Get_Col(x + 1, y - 1) ) { Dir = 0; bRow = false; x++; y--; return( true ); } // Sued-Ost case 4: if( y - 1 >= 0 && Get_Row(x , y - 1) ) { Dir = 1; y--; return( true ); } // Sueden case 5: if( y - 1 >= 0 && Get_Col(x , y - 1) ) { Dir = 2; bRow = false; y--; return( true ); } // Sued-West case 6: // Westen ist nicht... case 7: if( Get_Col(x , y ) ) { Dir = 4; bRow = false; return( true ); } // Nord-West default: Dir = 0; } } else { switch( Dir ) { case 0: // Norden ist nicht... case 1: if( Get_Row(x , y + 1) ) { Dir = 6; bRow = true; y++; return( true ); } // Nord-Ost case 2: if( Get_Col(x + 1, y ) ) { Dir = 7; x++; return( true ); } // Osten case 3: if( Get_Row(x , y ) ) { Dir = 0; bRow = true; return( true ); } // Sued-Ost case 4: // Sueden ist nicht... case 5: if( x - 1 >= 0 && Get_Row(x - 1, y ) ) { Dir = 2; bRow = true; x--; return( true ); } // Sued-West case 6: if( x - 1 >= 0 && Get_Col(x - 1, y ) ) { Dir = 3; x--; return( true ); } // Westen case 7: if( x - 1 >= 0 && Get_Row(x - 1, y + 1) ) { Dir = 5; bRow = true; x--; y++; return( true ); } // Nord-West default: Dir = 0; } } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define EDGE_LINE 1 #define EDGE_NODE_ONE 2 #define EDGE_NODE_TWO 3 //--------------------------------------------------------- bool CGrid_To_Contour::Get_Polygons(CSG_Shape_Line *pContour_Lo, CSG_Shape_Line *pContour_Hi) { int x, y; //----------------------------------------------------- double zMin = pContour_Lo ? pContour_Lo->asDouble(1) : m_pGrid->Get_ZMin(); double zMax = pContour_Hi ? pContour_Hi->asDouble(1) : m_pGrid->Get_ZMax(); #pragma omp parallel for private(x, y) for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { m_Edge.Set_Value(x, y, is_Edge(x, y) && zMin <= m_pGrid->asDouble(x, y) && m_pGrid->asDouble(x, y) <= zMax ? EDGE_LINE : 0); } } //----------------------------------------------------- CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)m_pPolygons->Add_Shape(); pPolygon->Set_Value(0, m_pPolygons->Get_Count()); pPolygon->Set_Value(1, zMin); pPolygon->Set_Value(2, zMax); pPolygon->Set_Value(3, SG_Get_String(zMin) + " - " + SG_Get_String(zMax)); //----------------------------------------------------- CSG_Shapes Segments(SHAPE_TYPE_Line); Segments.Add_Field("x0", SG_DATATYPE_Int); Segments.Add_Field("y0", SG_DATATYPE_Int); Segments.Add_Field("x1", SG_DATATYPE_Int); Segments.Add_Field("y1", SG_DATATYPE_Int); if( pContour_Lo ) { Add_Contour(Segments, pPolygon, pContour_Lo); } if( pContour_Hi ) { Add_Contour(Segments, pPolygon, pContour_Hi); } //----------------------------------------------------- if( Segments.Get_Count() == 0 ) // no edge crossing line { for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { if( m_Edge.asInt(x, y) == EDGE_LINE ) // add outer ring { Add_Edge(Segments, x, y); if( Segments.Get_Count() ) { pPolygon->Add_Part(((CSG_Shape_Polygon *)Segments.Get_Shape(0))->Get_Part(0)); Segments.Del_Shapes(); } } } } return( true ); } //----------------------------------------------------- // { CSG_Grid *pGrid = SG_Create_Grid(m_Edge); pGrid->Set_NoData_Value(0); DataObject_Add(pGrid); } for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { if( m_Edge.asInt(x, y) == EDGE_NODE_ONE ) { Add_Edge(Segments, x, y); } } } // DataObject_Add(SG_Create_Shapes(Segments)); //----------------------------------------------------- while( Segments.Get_Count() > 0 ) { int iPart = pPolygon->Get_Part_Count(); CSG_Shape *pSegment = Segments.Get_Shape(0); int x = pSegment->asInt(2); int y = pSegment->asInt(3); bool bAscending = true; do { Add_Segment(pPolygon, iPart, pSegment, bAscending); } while( (pSegment = Get_Segment(Segments, x, y, bAscending)) != NULL ); if( pPolygon->Get_Point_Count(iPart) < 3 ) { pPolygon->Del_Part(iPart); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGrid_To_Contour::Add_Contour(CSG_Shapes &Segments, CSG_Shape_Polygon *pPolygon, CSG_Shape_Line *pContour) { //----------------------------------------------------- for(int iPart=0; iPartGet_Part_Count(); iPart++) { CSG_Shape_Part *pPart = pContour->Get_Part(iPart); if( !CSG_Point(pPart->Get_Point(0, true)).is_Equal(pPart->Get_Point(0, false)) ) // island { CSG_Shape *pSegment = Segments.Add_Shape(); pSegment->Add_Part(pPart); int x, y; m_Edge.Get_System().Get_World_to_Grid(x, y, pPart->Get_Point(0, true)); m_Edge.Set_Value(x, y, m_Edge.asInt(x, y) == EDGE_NODE_ONE ? EDGE_NODE_TWO : EDGE_NODE_ONE); pSegment->Set_Value(0, x); pSegment->Set_Value(1, y); m_Edge.Get_System().Get_World_to_Grid(x, y, pPart->Get_Point(0, false)); m_Edge.Set_Value(x, y, m_Edge.asInt(x, y) == EDGE_NODE_ONE ? EDGE_NODE_TWO : EDGE_NODE_ONE); pSegment->Set_Value(2, x); pSegment->Set_Value(3, y); } else if( pPart->Get_Count() >= 3 ) { pPolygon->Add_Part(pPart); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGrid_To_Contour::Add_Edge(CSG_Shapes &Segments, int x, int y) { int i; //----------------------------------------------------- CSG_Shape *pSegment = NULL; for(i=0; i<8 && !pSegment; i+=2) { int ix = CSG_Grid_System::Get_xTo(i, x); int iy = CSG_Grid_System::Get_yTo(i, y); if( m_Edge.is_InGrid(ix, iy) && m_Edge.asInt(ix, iy) == EDGE_LINE ) { pSegment = Segments.Add_Shape(); pSegment->Set_Value(0, x); pSegment->Set_Value(1, y); x = ix; y = iy; } } if( !pSegment ) { for(i=0; i<8 && !pSegment; i+=2) { int ix = CSG_Grid_System::Get_xTo(i, x); int iy = CSG_Grid_System::Get_yTo(i, y); if( m_Edge.is_InGrid(ix, iy) && m_Edge.asInt(ix, iy) == EDGE_NODE_ONE ) { pSegment = Segments.Add_Shape(); pSegment->Set_Value(0, x); pSegment->Set_Value(1, y); pSegment->Set_Value(2, ix); pSegment->Set_Value(3, iy); } } return( pSegment != NULL ); } //----------------------------------------------------- int iLast = -1; for(bool bNext=true; bNext; ) { bNext = false; m_Edge.Set_Value(x, y, 0); for(i=0; i<8 && !bNext; i+=2) { int ix = CSG_Grid_System::Get_xTo(i, x); int iy = CSG_Grid_System::Get_yTo(i, y); if( m_Edge.is_InGrid(ix, iy) && m_Edge.asInt(ix, iy) == EDGE_LINE ) { bNext = true; if( i != iLast ) { iLast = i; pSegment->Add_Point(m_Edge.Get_System().Get_Grid_to_World(x, y)); } x = ix; y = iy; } } } //----------------------------------------------------- pSegment->Add_Point(m_Edge.Get_System().Get_Grid_to_World(x, y)); for(int i=0; i<8; i+=2) { int ix = CSG_Grid_System::Get_xTo(i, x); int iy = CSG_Grid_System::Get_yTo(i, y); if( m_Edge.is_InGrid(ix, iy) && m_Edge.asInt(ix, iy) != 0 ) { pSegment->Set_Value(2, ix); pSegment->Set_Value(3, iy); return( true ); } } pSegment->Set_Value(2, x); pSegment->Set_Value(3, y); return( false ); } //--------------------------------------------------------- CSG_Shape * CGrid_To_Contour::Get_Segment(const CSG_Shapes &Segments, int &x, int &y, bool &bAscending) { for(int i=0; iGet_Point_Count(0); i++) { pPolygon->Add_Point(pSegment->Get_Point(i, 0, bAscending), iPart); } ((CSG_Shapes *)pSegment->Get_Table())->Del_Shape(pSegment); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_To_Contour::Split_Polygon_Parts(CSG_Shapes *pPolygons) { CSG_Shapes Polygons(*pPolygons); pPolygons->Del_Shapes(); //----------------------------------------------------- for(int iPolygon=0; iPolygonGet_Part_Count() && Process_Get_Okay(); iPart++) { if( !pPolygon->is_Lake(iPart) ) { CSG_Shape_Polygon *pPart = (CSG_Shape_Polygon *)pPolygons->Add_Shape(pPolygon, SHAPE_COPY_ATTR); pPart->Add_Part(pPolygon->Get_Part(iPart)); for(int jPart=0; jPartGet_Part_Count(); jPart++) { if( pPolygon->is_Lake(jPart) && pPart->Contains(pPolygon->Get_Point(0, jPart)) ) { pPart->Add_Part(pPolygon->Get_Part(jPart)); } } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Values_AddTo_Shapes.cpp0000744000175000017500000002622412737416202027077 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Values_AddTo_Shapes.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Values_AddTo_Shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Values_AddTo_Shapes::CGrid_Values_AddTo_Shapes(void) { //----------------------------------------------------- Set_Name (_TL("Add Grid Values to Shapes")); Set_Author (SG_T("O.Conrad (c) 2003")); Set_Description (_TW( "Spatial Join: Retrieves information from the selected grids at the positions " "of the shapes of the selected shapes layer and adds it to the resulting shapes layer. " "For points this is similar to 'Add Grid Values to Points' module. " "For lines and polygons average values will be calculated from interfering grid cells. " "For polygons the 'Grid Statistics for Polygons' module offers more advanced options. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT, false ); Parameters.Add_Shapes( NULL , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "RESAMPLING" , _TL("Resampling"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 3 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_Values_AddTo_Shapes::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "SHAPES") ) { pParameters->Set_Enabled("RESAMPLING", pParameter->asShapes() && ( pParameter->asShapes()->Get_Type() == SHAPE_TYPE_Point || pParameter->asShapes()->Get_Type() == SHAPE_TYPE_Points || pParameter->asShapes()->Get_Type() == SHAPE_TYPE_Line )); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Values_AddTo_Shapes::On_Execute(void) { CSG_Parameter_Grid_List *pGrids; CSG_Shapes *pShapes; //----------------------------------------------------- pShapes = Parameters("RESULT")->asShapes(); pGrids = Parameters("GRIDS" )->asGridList(); //----------------------------------------------------- if( pGrids->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- if( pShapes == NULL ) { pShapes = Parameters("SHAPES")->asShapes(); } else if( pShapes != Parameters("SHAPES")->asShapes() ) { pShapes->Create(*Parameters("SHAPES")->asShapes()); } //----------------------------------------------------- switch( Parameters("RESAMPLING")->asInt() ) { default: m_Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: m_Resampling = GRID_RESAMPLING_Bilinear; break; case 2: m_Resampling = GRID_RESAMPLING_BicubicSpline; break; case 3: m_Resampling = GRID_RESAMPLING_BSpline; break; } //----------------------------------------------------- for(int iGrid=0; iGridGet_Count(); iGrid++) { CSG_Grid *pGrid = pGrids->asGrid(iGrid); int Field = pShapes->Get_Field_Count(); pShapes->Add_Field(pGrid->Get_Name(), SG_DATATYPE_Double); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Simple_Statistics Statistics; CSG_Shape *pShape = pShapes->Get_Shape(iShape); if( pShape->Get_Extent().Intersects(pGrid->Get_Extent()) ) { switch( pShapes->Get_Type() ) { case SHAPE_TYPE_Point: default: case SHAPE_TYPE_Points: Get_Data_Point (Statistics, pShape, pGrid); break; case SHAPE_TYPE_Line: Get_Data_Line (Statistics, pShape, pGrid); break; case SHAPE_TYPE_Polygon: Get_Data_Polygon(Statistics, pShape, pGrid); break; } } if( Statistics.Get_Count() > 0 ) { pShape->Set_Value(Field, Statistics.Get_Mean()); } else { pShape->Set_NoData(Field); } } } //----------------------------------------------------- if( pShapes == Parameters("SHAPES")->asShapes() ) { DataObject_Update(pShapes); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CGrid_Values_AddTo_Shapes::Get_Data_Point(CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { double Value; if( pGrid->Get_Value(pShape->Get_Point(iPoint, iPart), Value, m_Resampling) ) { Statistics += Value; } } } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CGrid_Values_AddTo_Shapes::Get_Data_Line(CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid) { double dStep = pGrid->Get_Cellsize(); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pShape->Get_Point_Count(iPart) > 0 ) { double Value; TSG_Point B, A = pShape->Get_Point(0, iPart); if( pGrid->Get_Value(A, Value, m_Resampling) ) { Statistics += Value; } for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { B = A; A = pShape->Get_Point(iPoint, iPart); //----------------------------------------- double Distance = SG_Get_Distance(A, B); if( Distance > 0.0 ) { double dx = (B.x - A.x) * dStep / Distance; double dy = (B.y - A.y) * dStep / Distance; TSG_Point C = A; for(double d=0.0; dGet_Value(C, Value, m_Resampling) ) { Statistics += Value; } } } } } } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CGrid_Values_AddTo_Shapes::Get_Data_Polygon(CSG_Simple_Statistics &Statistics, CSG_Shape *pShape, CSG_Grid *pGrid) { int xMin = pGrid->Get_System().Get_xWorld_to_Grid(pShape->Get_Extent().Get_XMin()); int xMax = pGrid->Get_System().Get_xWorld_to_Grid(pShape->Get_Extent().Get_XMax()); int yMin = pGrid->Get_System().Get_yWorld_to_Grid(pShape->Get_Extent().Get_YMin()); int yMax = pGrid->Get_System().Get_yWorld_to_Grid(pShape->Get_Extent().Get_YMax()); if( xMin < 0 ) xMin = 0; else if( xMin >= pGrid->Get_NX() ) xMin = pGrid->Get_NX() - 1; if( xMax < 0 ) xMax = 0; else if( xMax >= pGrid->Get_NX() ) xMax = pGrid->Get_NX() - 1; if( yMin < 0 ) yMin = 0; else if( yMin >= pGrid->Get_NY() ) yMin = pGrid->Get_NY() - 1; if( yMax < 0 ) yMax = 0; else if( yMax >= pGrid->Get_NY() ) yMax = pGrid->Get_NY() - 1; //----------------------------------------------------- for(int y=yMin; y<=yMax; y++) { double p_y = pGrid->Get_System().Get_yGrid_to_World(y); for(int x=xMin; x<=xMax; x++) { double p_x = pGrid->Get_System().Get_xGrid_to_World(x); if( !pGrid->is_NoData(x, y) && ((CSG_Shape_Polygon *)pShape)->Contains(p_x, p_y) ) { Statistics += pGrid->asDouble(x, y); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/MLB_Interface.h0000744000175000017500000000763112737416202024355 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__shapes_grid_H #define HEADER_INCLUDED__shapes_grid_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef shapes_grid_EXPORTS #define shapes_grid_EXPORT _SAGA_DLL_EXPORT #else #define shapes_grid_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__shapes_grid_H saga-2.3.1/src/modules/shapes/shapes_grid/grid_local_extremes_to_points.h0000744000175000017500000001014712737416202030070 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // grid_local_extremes_to_points.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_local_extremes_to_points_H #define HEADER_INCLUDED__grid_local_extremes_to_points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Local_Extremes_to_Points : public CSG_Module_Grid { public: CGrid_Local_Extremes_to_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid Values") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_local_extremes_to_points_H saga-2.3.1/src/modules/shapes/shapes_grid/Grid_Values_AddTo_Points.cpp0000744000175000017500000001573312737416202027133 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // Grid_Values_AddTo_Points.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_Values_AddTo_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Values_AddTo_Points::CGrid_Values_AddTo_Points(void) { //----------------------------------------------------- Set_Name (_TL("Add Grid Values to Points")); Set_Author (SG_T("O.Conrad (c) 2003")); Set_Description (_TW( "Spatial Join: Retrieves information from the selected grids at the positions " "of the points of the selected points layer and adds it to the resulting layer." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Points"), _TL(""), PARAMETER_INPUT , SHAPE_TYPE_Point ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT , false ); Parameters.Add_Shapes( NULL , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "RESAMPLING" , _TL("Resampling"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 3 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Values_AddTo_Points::On_Execute(void) { int iShape, iGrid, iField, Offset; double Value; CSG_Shapes *pShapes; CSG_Parameter_Grid_List *pGrids; //----------------------------------------------------- pShapes = Parameters("RESULT")->asShapes(); pGrids = Parameters("GRIDS" )->asGridList(); //----------------------------------------------------- if( pGrids->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- if( pShapes == NULL ) { pShapes = Parameters("SHAPES")->asShapes(); } else if( pShapes != Parameters("SHAPES")->asShapes() ) { pShapes->Create(*Parameters("SHAPES")->asShapes()); } Offset = pShapes->Get_Field_Count(); //----------------------------------------------------- for(iGrid=0; iGridGet_Count(); iGrid++) { pShapes->Add_Field(pGrids->asGrid(iGrid)->Get_Name(), SG_DATATYPE_Double); } //----------------------------------------------------- TSG_Grid_Resampling Resampling; switch( Parameters("RESAMPLING")->asInt() ) { default: Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: Resampling = GRID_RESAMPLING_Bilinear; break; case 2: Resampling = GRID_RESAMPLING_BicubicSpline; break; case 3: Resampling = GRID_RESAMPLING_BSpline; break; } //----------------------------------------------------- for(iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(iGrid=0, iField=Offset; iGridGet_Count(); iGrid++, iField++) { CSG_Grid *pGrid = pGrids->asGrid(iGrid); if( pGrid->Get_Value(pShape->Get_Point(0), Value, Resampling) ) { pShape->Set_Value(iField, Value); } else { pShape->Set_NoData(iField); } } } //----------------------------------------------------- if( pShapes == Parameters("SHAPES")->asShapes() ) { DataObject_Update(pShapes); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/shapes/shapes_grid/MLB_Interface.cpp0000744000175000017500000001330212737416202024700 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Shapes // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Grid Tools") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V.Wichmann (c) 2002-13") ); case MLB_INFO_Description: return( _TL("Tools related to gridded and vector data (conversions, combinations, etc.).") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Grid") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Grid_Values_AddTo_Points.h" #include "Grid_Values_AddTo_Shapes.h" #include "Grid_Statistics_AddTo_Polygon.h" #include "Grid_Statistics_For_Points.h" #include "Grid_To_Points.h" #include "Grid_To_Points_Random.h" #include "Grid_To_Contour.h" #include "Grid_Classes_To_Shapes.h" #include "Grid_Polygon_Clip.h" #include "Grid_To_Gradient.h" #include "grid_local_extremes_to_points.h" #include "grid_extent.h" #include "grid_rectangle_clip.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CGrid_Values_AddTo_Points ); case 1: return( new CGrid_Values_AddTo_Shapes ); case 2: return( new CGrid_Statistics_AddTo_Polygon ); case 8: return( new CGrid_Statistics_For_Points ); case 3: return( new CGrid_To_Points ); case 4: return( new CGrid_To_Points_Random ); case 5: return( new CGrid_To_Contour ); case 6: return( new CGrid_Classes_To_Shapes ); case 7: return( new CGrid_Polygon_Clip ); case 9: return( new CGrid_Local_Extremes_to_Points ); case 10: return( new CGrid_Extent ); case 11: return( new CGrid_Rectangle_Clip ); case 15: return( new CGrid_To_Gradient(0) ); case 16: return( new CGrid_To_Gradient(1) ); case 17: return( new CGrid_To_Gradient(2) ); case 20: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/docs/0000775000175000017500000000000012737740003016760 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/docs/docs_pdf/0000775000175000017500000000000012737740003020541 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/docs/docs_pdf/Profile_Cross_Sections.h0000744000175000017500000000637112737416156025351 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Profile_Cross_Sections.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* CrossSections.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ //--------------------------------------------------------- #include "doc_pdf.h" #include /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CProfile_Cross_Sections_PDF : public CSG_Doc_PDF { public: CProfile_Cross_Sections_PDF(); ~CProfile_Cross_Sections_PDF(); void AddCrossSections(TSG_Point **,double*,TSG_Point *,int,int,int); void AddLongitudinalProfile(TSG_Point *, double*, int); void AddVolumesTable(TSG_Point *,TSG_Point **,double*,TSG_Point *,int,int,int); private: char *m_pPath; int m_iCanvasHeight; int m_iTableWidth; int m_iOffsetY; CSG_String m_sName; void AddCrossSection(TSG_Point *,TSG_Point *,int,int); void DrawGuitar(TSG_Point *,double*, int); void AddGuitarValue(double,double,double,double,int); void AdjustSections(TSG_Point *,TSG_Point *,std::vector&,std::vector&,double,int&,int&); void Intersect_Lines(double,double,double,double,double,double,double,double,double&,double&); void CalculateAreas(TSG_Point*,TSG_Point*,double,int,int,double&,double&); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CProfile_Cross_Sections : public CSG_Module_Grid { public: CProfile_Cross_Sections(void); virtual ~CProfile_Cross_Sections(void); protected: bool On_Execute(void); private: CProfile_Cross_Sections_PDF m_DocEngine; CSG_Shapes *m_pSections; double *m_pHeight; TSG_Point *m_pProfile; void CreatePDFDocs(); void AddLongitudinalProfiles(); void AddCrossSections(); double CalculatePointLineDist(double,double,double,double,double,double); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/docs/docs_pdf/Shapes_Summary.cpp0000744000175000017500000003745012737416156024226 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Summary.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Summarize.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Shapes_Summary.h" #define VERY_LARGE_NUMBER 9999999999. CSG_String sParam[] = {"[Sum]", "[Mean]", "[Variance]", "[Minimum]", "[Maximum]"}; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PDF_PAGE_WIDTH_A4 596 #define PDF_PAGE_HEIGHT_A4 842 #define PDF_PAGE_WIDTH_A3 PDF_PAGE_HEIGHT_A4 #define PDF_PAGE_HEIGHT_A3 (sqrt(2.) * PDF_PAGE_HEIGHT_A4) #define OFFSET_X 50 #define OFFSET_Y 50 #define LINE_SPACEMENT 12 #define SUMMARY_LAYOUT_HEADER 50 #define MAX_SUMMARY_LAYOUT_HEIGHT (PDF_PAGE_WIDTH_A3 - 2 * OFFSET_Y - LINE_SPACEMENT) #define MAX_SUMMARY_LAYOUT_WIDTH MAX_SUMMARY_LAYOUT_HEIGHT #define SUMMARY_LAYOUT_SEPARATION 30 #define MAX_SUMMARY_TABLE_WIDTH (PDF_PAGE_HEIGHT_A3 - 2 * OFFSET_X - MAX_SUMMARY_LAYOUT_WIDTH - SUMMARY_LAYOUT_SEPARATION) #define MAX_ROWS_IN_SUMMARY_LAYOUT (MAX_SUMMARY_LAYOUT_HEIGHT / TABLE_CELL_HEIGHT) #define SUMMARY_STATISTICS_GRAPH_HEIGHT 120 #define SUMMARY_STATISTICS_GRAPH_WIDTH (PDF_PAGE_WIDTH_A4 - 2 * OFFSET_X) #define SUMMARY_STATISTICS_GRAPH_SEPARATION 120 #define GRATICULE_SEPARATION 20 #define SUMMARY_TABLE_CELL_HEIGHT 13.0 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef min #define min(a,b) (((a) < (b)) ? (a) : (b)) #endif CShapes_Summary_PDF::CShapes_Summary_PDF(){ }//constructor CShapes_Summary_PDF::~CShapes_Summary_PDF(){} void CShapes_Summary_PDF::AddClassSummaryPage(CSG_Shapes *pShapes, CSG_Table *pTable, int iClass, CSG_String sTitle){ int i; double fPaperHeight; double fRealWidth, fRealHeight; double fX, fY; CSG_Table *pClassTable; CSG_Table_Record *pRecord; CSG_Rect CanvasExtent, TableExtent; TSG_Rect Extent; Add_Page(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE); Add_Outline_Item(sTitle.c_str()); fPaperHeight = Get_Size_Page().Get_YRange(); Draw_Text(PDF_PAGE_HEIGHT_A3 - OFFSET_X, fPaperHeight - OFFSET_Y, sTitle, 25, PDF_STYLE_TEXT_ALIGN_H_RIGHT, 0.0, SG_GET_RGB(0, 0, 0)); Draw_Line(OFFSET_X, fPaperHeight - OFFSET_Y - 5, PDF_PAGE_HEIGHT_A3 - OFFSET_X, fPaperHeight - OFFSET_Y - 5, 4 ); Extent = pShapes->Get_Extent(); fRealWidth = Extent.xMax - Extent.xMin; fRealHeight = Extent.yMax - Extent.yMin; CanvasExtent.Assign(OFFSET_X, OFFSET_Y, OFFSET_X + MAX_SUMMARY_LAYOUT_WIDTH, OFFSET_Y + MAX_SUMMARY_LAYOUT_HEIGHT); _Fit_Rectangle(CanvasExtent, fRealWidth / fRealHeight, true); CanvasExtent.Deflate(GRATICULE_SEPARATION, false); Draw_Shapes(CanvasExtent, pShapes); CanvasExtent.Inflate(GRATICULE_SEPARATION, false); /*CanvasExtent.xMin = OFFSET_X + (MAX_SUMMARY_LAYOUT_WIDTH - fWidth) / 2. - GRATICULE_SEPARATION; CanvasExtent.xMax = CanvasExtent.xMin + fWidth + 2 * GRATICULE_SEPARATION; CanvasExtent.yMin = OFFSET_Y + (MAX_SUMMARY_LAYOUT_HEIGHT - fHeight) / 2. - GRATICULE_SEPARATION; CanvasExtent.yMax = CanvasExtent.yMin + fHeight + 2* GRATICULE_SEPARATION;*/ Draw_Graticule(CanvasExtent, Extent); pClassTable = SG_Create_Table(); pClassTable->Add_Field(_TL("Field"), SG_DATATYPE_String ); pClassTable->Add_Field(_TL("Value"), SG_DATATYPE_Double); for (i = 0; i < pTable->Get_Field_Count(); i++){ pRecord = pClassTable->Add_Record(); pRecord->Set_Value(0, pTable->Get_Field_Name(i)); pRecord->Set_Value(1, pTable->Get_Record(iClass)->asDouble(i)); } fY = fPaperHeight - OFFSET_Y - SUMMARY_LAYOUT_HEADER; fX = PDF_PAGE_HEIGHT_A3 - OFFSET_X - MAX_SUMMARY_TABLE_WIDTH; TableExtent.Assign(fX, fY, fX + MAX_SUMMARY_TABLE_WIDTH, OFFSET_Y); Draw_Table(TableExtent, pClassTable, SUMMARY_TABLE_CELL_HEIGHT, 0.0); }//method void CShapes_Summary_PDF::AddSummaryStatisticsPage(CSG_Table* pTable){ int i,j; double fX, fY; double fPaperHeight; CSG_Points Data; CSG_String *pNames; CSG_Rect r; fPaperHeight = Get_Size_Page().Get_YRange(); pNames = new CSG_String [pTable->Get_Record_Count()]; for (i = 0; i < pTable->Get_Record_Count(); i++){ pNames[i] = pTable->Get_Record(i)->asString(0); }//for for (i = 1; i < pTable->Get_Field_Count(); i++){ if ((i-1)%3 == 0){ Add_Page(); }//if Data.Clear(); for (j = 0; j < pTable->Get_Record_Count(); j++){ Data.Add(0.0, pTable->Get_Record(j)->asDouble(i)); }//for fY = OFFSET_Y + ((i-1)%3) * (SUMMARY_STATISTICS_GRAPH_HEIGHT + SUMMARY_STATISTICS_GRAPH_SEPARATION); fY = fPaperHeight - fY; fX = OFFSET_X; Draw_Text(fX, fY + 10, pTable->Get_Field_Name(i), 14); r.Assign(fX, fY - 25 - SUMMARY_STATISTICS_GRAPH_HEIGHT, fX + SUMMARY_STATISTICS_GRAPH_WIDTH, fY - 25 ); AddBarGraphStatistics(Data, pNames, r); }//for*/ }//method void CShapes_Summary_PDF::AddBarGraphStatistics(CSG_Points &Data, CSG_String *pNames, const CSG_Rect &r){ int i; int iMag; int iNumLines; double fMinLine = 0; double fWidth; double fMax, fMin; double fStep; double fX, fY; double fPaperHeight; double fAngle; CSG_String sValue; CSG_Points Points; fPaperHeight = Get_Size_Page().Get_YRange(); fMin = fMax = Data[0].y; for (i = 0; i < Data.Get_Count(); i++){ if (Data[i].y > fMax){ fMax = Data[i].y; } if (Data[i].y < fMin){ fMin = Data[i].y; } fMin = M_GET_MIN(0, fMin); } if (fMin != fMax){ iMag = (int) (log(fMax - fMin) / log(10.0)); fStep = (pow(10.0, (double) iMag)); if (fStep == 0){ fStep = 1.; } fMinLine= (long)(((long)(fMin/fStep)) *fStep); iNumLines = (int) ((fMax - fMin) / fStep); while (iNumLines < 8){ fStep = fStep / 2.0; iNumLines = (int) ((fMax - fMin) / fStep); } iNumLines = (int) ((fMax - fMinLine) / fStep); } else{ fStep = fMin = 0; iNumLines = 1; fMinLine = fMax; } for (i = 0; i < iNumLines; i++) { fY = r.Get_YMin() + ((fMinLine + fStep * i - fMin) / (fMax - fMin)) * r.Get_YRange(); if (fY <= r.Get_YMax() && fY >= r.Get_YMin()) { Draw_Line(r.Get_XMin(), fY, r.Get_XMax(), fY); } } fWidth = (double) r.Get_XRange() / (double) (Data.Get_Count()); for (i = 0; i < Data.Get_Count(); i++) { fX = r.Get_XMin() + i * fWidth; fY = r.Get_YMin(); //fY = fPaperHeight - fY; Draw_Rectangle(fX, fY, fX + fWidth, fY + r.Get_YRange() * ((Data[i].y - fMin) / (fMax - fMin)), PDF_STYLE_POLYGON_FILLSTROKE, 0xaa0000); } fAngle = 3.14159/ 180 * 60; for (i = 0; i < Data.Get_Count(); i++) { fX = r.Get_XMin() + i * fWidth + fWidth / 2.; Draw_Text(fX - 5, fY - 5, pNames[i], 9, PDF_STYLE_TEXT_ALIGN_V_TOP|PDF_STYLE_TEXT_ALIGN_H_RIGHT, fAngle); Draw_Line(fX, fY, fX, fY - 5, 1); } Draw_Line(r.Get_XMin(), r.Get_YMin(), r.Get_XMin(), r.Get_YMax(), 4); Draw_Line(r.Get_XMin(), r.Get_YMin(), r.Get_XMax(), r.Get_YMin(), 4); }//method /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Summary::CShapes_Summary(void){ CSG_Parameter *pNode; CSG_String sName; Parameters.Set_Name(_TL("Shapes Summary Report")); Parameters.Set_Description(_TW("(c) 2004 by Victor Olaya. summary.")); pNode = Parameters.Add_Shapes(NULL, "SHAPES", _TL("Shapes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Table_Field(pNode, "FIELD", _TL("Field"), _TL("")); Parameters.Add_Table(NULL, "TABLE", _TL("Summary Table"), _TL(""), PARAMETER_OUTPUT); pNode = Parameters.Add_Node(NULL, "PDFNODE", _TL("PDF Docs"), _TL("")); Parameters.Add_Value(pNode, "PDF", _TL("Create PDF Docs"), _TL("Create PDF Docs"), PARAMETER_TYPE_Bool, true); Parameters.Add_FilePath(pNode, "OUTPUTPATH", _TL("Folder"), _TL("Folder"), _TL(""), _TL(""), true, true); m_pExtraParameters = Add_Parameters("EXTRA", _TL("Field for Summary"), _TL("")); }//constructor CShapes_Summary::~CShapes_Summary(void) {} bool CShapes_Summary::On_Execute(void){ int i,j; CSG_Table *pShapesTable; CSG_Parameter **pExtraParameter; CSG_String sName, sFilePath; m_iField = Parameters("FIELD")->asInt(); m_pShapes = Parameters("SHAPES")->asShapes(); m_pTable = Parameters("TABLE")->asTable(); pShapesTable = m_pShapes; m_bIncludeParam = new bool [pShapesTable->Get_Field_Count() * 5]; pExtraParameter = new CSG_Parameter* [pShapesTable->Get_Field_Count() * 5]; for (i = 0; i < pShapesTable->Get_Field_Count(); i++){ for (j = 0; j < 5; j++){ if( SG_Data_Type_is_Numeric(pShapesTable->Get_Field_Type(i)) ) { //is numeric field sName = pShapesTable->Get_Field_Name(i); sName.Append(sParam[j]); pExtraParameter[i * 5 + j] = m_pExtraParameters->Add_Value(NULL, SG_Get_String(i * 5 + j,0).c_str(), sName.c_str(), _TL(""), PARAMETER_TYPE_Bool, false); m_bIncludeParam[i * 5 + j] = true; }//if else{ m_bIncludeParam[i * 5 + j] = false; }//else }//for }//for if(Dlg_Parameters("EXTRA")){ for (i = 0; i < pShapesTable->Get_Field_Count() * 5; i++){ sName = SG_Get_String(i,0); if (m_bIncludeParam[i]){ m_bIncludeParam[i] = Get_Parameters("EXTRA")->Get_Parameter(sName.c_str())->asBool(); }//if }//for Summarize(); if (Parameters("PDF")->asBool()){ if (Parameters("OUTPUTPATH")->asString()){ sName = _TL("Summary_"); sName.Append(m_pShapes->Get_Name()); m_DocEngine.Open(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE, sName); CreatePDFDocs(); sFilePath = SG_File_Make_Path(Parameters("OUTPUTPATH")->asString(), sName, SG_T("pdf")); if (m_DocEngine.Save(sFilePath)){ if (!m_DocEngine.Close()){ Message_Add(_TL("\n\n ** Error : Could not close PDF engine ** \n\n")); } }//if else{ Message_Add(_TL("\n\n ** Error : Could not save PDF file ** \n\n")); }//else }//if }//if m_pExtraParameters->Destroy(); delete [] m_bIncludeParam; return true; }//if m_pExtraParameters->Destroy(); delete [] m_bIncludeParam; return false; }//method void CShapes_Summary::CreatePDFDocs(){ CSG_Shapes *pShapes; CSG_Shape *pShape; CSG_Table *pShapesTable; int i,j; m_DocEngine.Add_Page_Title (_TL("Summary"), PDF_TITLE_01, PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE); pShapesTable = m_pShapes; pShapes = new CSG_Shapes(); for (i = 0; i < (int)m_ClassesID.size(); i++){ Set_Progress(i,(int)m_ClassesID.size()); pShapes->Create(m_pShapes->Get_Type()); for (j = 0; j < m_pShapes->Get_Count(); j++){ if (m_pClasses[j] == i){ pShape = pShapes->Add_Shape(); pShape->Assign(m_pShapes->Get_Shape(j)); }//if }//for m_DocEngine.AddClassSummaryPage(pShapes, m_pTable, i, m_ClassesID[i]); }//for if (m_pTable->Get_Record_Count() > 1){ m_DocEngine.Add_Page_Title (_TL("Statistics"), PDF_TITLE_01, PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_PORTRAIT); m_DocEngine.AddSummaryStatisticsPage(m_pTable); }//if delete pShapes; }//method void CShapes_Summary::Summarize(){ int i,j; CSG_Table *pShapesTable; CSG_Table_Record *pRecord; CSG_String sName; float *pSum; float *pMin; float *pMax; float *pVar; float fValue; float fMean; int iLastField = -1; int iField; int iParam; m_ClassesID.clear(); pShapesTable = m_pShapes; m_pClasses = new int[pShapesTable->Get_Record_Count()]; for (i = 0; i < pShapesTable->Get_Record_Count(); i++){ pRecord = pShapesTable->Get_Record(i); sName = pRecord->asString(m_iField); for (j = 0; j < (int)m_ClassesID.size(); j++){ if (!m_ClassesID[j].CmpNoCase(sName)){ m_pClasses[i] = j; break; }//if }//for if (j == m_ClassesID.size()){ m_pClasses[i] = j; m_ClassesID.push_back(sName); }//if }//for m_pTable->Create((CSG_Table*)NULL); m_pTable->Set_Name(_TL("Summary Table")); m_pTable->Add_Field(_TL("Class"), SG_DATATYPE_String); m_pTable->Add_Field(_TL("Count"), SG_DATATYPE_Int); m_pCount = new int[m_ClassesID.size()]; pSum = new float[m_ClassesID.size()]; pMax = new float[m_ClassesID.size()]; pMin = new float[m_ClassesID.size()]; pVar = new float[m_ClassesID.size()]; for (i = 0; i < (int)m_ClassesID.size(); i++){ m_pCount[i] = 0; }//for for (i = 0; i < pShapesTable->Get_Record_Count(); i++){ m_pCount[m_pClasses[i]]++; }//for for (i = 0; i < (int)m_ClassesID.size(); i++){ pRecord = m_pTable->Add_Record(); sName = m_ClassesID[i]; pRecord->Set_Value(0,sName.c_str()); pRecord->Set_Value(1,m_pCount[i]); }//for for (i = 0; i < pShapesTable->Get_Field_Count() * 5; i++){ if (m_bIncludeParam[i]){ iField = (int) (i / 5); iParam = i % 5; sName = pShapesTable->Get_Field_Name(iField); sName.Append(sParam[iParam]); m_pTable->Add_Field(sName.c_str(), SG_DATATYPE_Double); if (iField != iLastField){ for (j = 0; j < (int)m_ClassesID.size(); j++){ pSum[j] = 0; pMax[j] = -(float)VERY_LARGE_NUMBER; pMin[j] = (float)VERY_LARGE_NUMBER; pVar[j] = 0; }//for for (j = 0; j < pShapesTable->Get_Record_Count(); j++){ pRecord = pShapesTable->Get_Record(j); fValue = pRecord->asFloat(iField); pSum[m_pClasses[j]] += fValue; pVar[m_pClasses[j]] += (fValue * fValue); if (fValue > pMax[m_pClasses[j]]){ pMax[m_pClasses[j]] = fValue; }//if if (fValue < pMin[m_pClasses[j]]){ pMin[m_pClasses[j]] = fValue; }//if }//for }//if iField = m_pTable->Get_Field_Count() - 1; for (j = 0; j < (int)m_ClassesID.size(); j++){ pRecord = m_pTable->Get_Record(j); switch (iParam){ case 0: //sum pRecord->Set_Value(iField, pSum[j]); break; case 1: //average pRecord->Set_Value(iField, pSum[j] / (float) m_pCount[j]); break; case 2: //variance fMean = pSum[j] / (float) m_pCount[j]; pRecord->Set_Value(iField, pVar[j] / (float) m_pCount[j] - fMean * fMean); break; case 3: //min pRecord->Set_Value(iField, pMin[j]); break; case 4: //max pRecord->Set_Value(iField, pMax[j]); break; default: break; }//switch }//for }//if }//for }//method /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/docs/docs_pdf/doc_pdf.h0000744000175000017500000003217512737416156022330 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_pdf.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_pdf // // // //-------------------------------------------------------// // // // doc_pdf.h // // // // Copyright (C) 2005 by // // Victor Olaya, Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. // // // // This library is free software; you can redistribute // // it and/or modify it under the terms of the GNU Lesser // // General Public License as published by the Free // // Software Foundation, version 2.1 of the License. // // // // This library is distributed in the hope that it will // // be useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU Lesser General Public // // License for more details. // // // // You should have received a copy of the GNU Lesser // // General Public License along with this program; if // // not, write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__doc_pdf_H #define HEADER_INCLUDED__doc_pdf_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PDF_TABLE_CELL_HEIGHT_DEFAULT 20.0 #define PDF_TABLE_HEADER_HEIGHT 40.0 //--------------------------------------------------------- #define PDF_PAGE_ORIENTATION_PREVIOUS -1 #define PDF_PAGE_ORIENTATION_PORTRAIT 0 #define PDF_PAGE_ORIENTATION_LANDSCAPE 1 //--------------------------------------------------------- #define PDF_STYLE_POINT_CIRCLE 0x00000001 #define PDF_STYLE_POINT_SQUARE 0x00000002 #define PDF_STYLE_LINE_END_BUTT 0x00000004 #define PDF_STYLE_LINE_END_ROUND 0x00000008 #define PDF_STYLE_LINE_END_SQUARE 0x00000010 #define PDF_STYLE_LINE_JOIN_MITER 0x00000020 #define PDF_STYLE_LINE_JOIN_ROUND 0x00000040 #define PDF_STYLE_LINE_JOIN_BEVEL 0x00000080 #define PDF_STYLE_POLYGON_STROKE 0x00000100 #define PDF_STYLE_POLYGON_FILL 0x00000200 #define PDF_STYLE_POLYGON_FILLSTROKE (PDF_STYLE_POLYGON_STROKE|PDF_STYLE_POLYGON_FILL) //--------------------------------------------------------- #define PDF_STYLE_TEXT_ALIGN_H_LEFT 0x00000001 #define PDF_STYLE_TEXT_ALIGN_H_CENTER 0x00000002 #define PDF_STYLE_TEXT_ALIGN_H_RIGHT 0x00000004 #define PDF_STYLE_TEXT_ALIGN_V_TOP 0x00000008 #define PDF_STYLE_TEXT_ALIGN_V_CENTER 0x00000010 #define PDF_STYLE_TEXT_ALIGN_V_BOTTOM 0x00000020 #define PDF_STYLE_TEXT_UNDERLINE 0x00000040 #define PDF_STYLE_TEXT_STROKE 0x00000080 //---------------------------------------------------------- #define PDF_GRAPH_TYPE_BARS 1 #define PDF_GRAPH_TYPE_LINES 2 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- typedef enum ESG_PDF_Font_Type { PDF_FONT_DEFAULT = 0, PDF_FONT_Helvetica = 0, PDF_FONT_Helvetica_Bold, PDF_FONT_Helvetica_Oblique, PDF_FONT_Helvetica_BoldOblique, PDF_FONT_Times_Roman, PDF_FONT_Times_Bold, PDF_FONT_Times_Italic, PDF_FONT_Times_BoldItalic, PDF_FONT_Courier, PDF_FONT_Courier_Bold, PDF_FONT_Courier_Oblique, PDF_FONT_Courier_BoldOblique, PDF_FONT_Symbol, PDF_FONT_ZapfDingbats } TSG_PDF_Font_Type; //--------------------------------------------------------- typedef enum ESG_PDF_Page_Size { PDF_PAGE_SIZE_A4 = 1, PDF_PAGE_SIZE_A3, PDF_PAGE_SIZE_PREVIOUS } TSG_PDF_Page_Size; //--------------------------------------------------------- typedef enum ESG_PDF_Title_Level { PDF_TITLE = 0, PDF_TITLE_01, PDF_TITLE_02, PDF_TITLE_NONE } TSG_PDF_Title_Level; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class docs_pdf_EXPORT CSG_Doc_PDF { public: CSG_Doc_PDF(void); CSG_Doc_PDF(TSG_PDF_Page_Size Size, int Orientation = PDF_PAGE_ORIENTATION_PORTRAIT, const SG_Char *Title = NULL); virtual ~CSG_Doc_PDF(void); static const SG_Char * Get_Version (void); bool Open (TSG_PDF_Page_Size Size = PDF_PAGE_SIZE_A4, int Orientation = PDF_PAGE_ORIENTATION_PORTRAIT, const SG_Char *Title = NULL); bool Open (const SG_Char *Title); bool Close (void); bool Save (const SG_Char *FileName); bool Is_Open (void) { return( m_pPDF != NULL ); } bool Is_Ready_To_Draw (void) { return( m_pPDF != NULL ); } static double Get_Page_To_Meter (void); bool Add_Page (void); bool Add_Page (TSG_PDF_Page_Size Size, int Orientation = PDF_PAGE_ORIENTATION_PORTRAIT); bool Add_Page (double Width, double Height); bool Add_Page_Title (const SG_Char *Title, TSG_PDF_Title_Level Level = PDF_TITLE, TSG_PDF_Page_Size Size = PDF_PAGE_SIZE_PREVIOUS, int Orientation = PDF_PAGE_ORIENTATION_PREVIOUS); bool Add_Outline_Item (const SG_Char *Title); bool Set_Size_Page (TSG_PDF_Page_Size Size, int Orientation = PDF_PAGE_ORIENTATION_PORTRAIT); bool Set_Size_Page (double Width, double Height); const CSG_Rect & Get_Size_Page (void) { return( m_Size_Paper ); } const CSG_Rect & Get_Margins (void) { return( m_Size_Margins ); } void Layout_Set_Box_Space (double Space, bool bPercent); bool Layout_Add_Box (double xMin_Percent, double yMin_Percent, double xMax_Percent, double yMax_Percent, const CSG_String &ID = ""); bool Layout_Add_Box (const CSG_Rect &Box_Percent, const CSG_String &ID = ""); const CSG_Rect & Layout_Get_Box (int iBox) { return( iBox >= 0 && iBox < m_Boxes.Get_Count() ? m_Boxes[iBox] : m_Size_Margins ); } const CSG_Rect & Layout_Get_Box (const CSG_String &ID = ""); bool Draw_Point (double x, double y, double Width, int Style = PDF_STYLE_POINT_SQUARE|PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_WHITE, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0); bool Draw_Line (double xa, double ya, double xb, double yb , int Width = 0, int Color = SG_COLOR_BLACK, int Style = 0); bool Draw_Line (CSG_Points &Points , int Width = 0, int Color = SG_COLOR_BLACK, int Style = 0); bool Draw_Rectangle (double xa, double ya, double xb, double yb , int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_WHITE, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0); bool Draw_Rectangle (const CSG_Rect &r , int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_WHITE, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0); bool Draw_Polygon (CSG_Points &Points , int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0); bool Draw_Text (double x, double y, const SG_Char *Text, int Size, int Style = PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP, double Angle = 0.0, int Color = SG_COLOR_BLACK, TSG_PDF_Font_Type Font = PDF_FONT_DEFAULT); bool Draw_Text (double x, double y, CSG_Strings &Text, int Size, int Style = PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP, double Angle = 0.0, int Color = SG_COLOR_BLACK, TSG_PDF_Font_Type Font = PDF_FONT_DEFAULT); bool Draw_Image (double x, double y, double dx, double dy , const SG_Char *FileName); bool Draw_Image (const CSG_Rect &r , const SG_Char *FileName); bool Draw_Graticule (const CSG_Rect &r, const CSG_Rect &rWorld, int Size = 10); void Draw_Curve (CSG_Points &Data, const CSG_Rect &r, int iGraphType); bool Draw_Table (const CSG_Rect &r, CSG_Table *pTable , double CellHeight = 0.0, double HeaderHeightRel = 1.5); bool Draw_Table (const CSG_Rect &r, CSG_Table *pTable, int nColumns , double CellHeight = 0.0, double HeaderHeightRel = 1.5); bool Draw_Shape (const CSG_Rect &r, CSG_Shape *pShape , int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0, CSG_Rect *prWorld = NULL); bool Draw_Shapes (const CSG_Rect &r, CSG_Shapes *pShapes, int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0, CSG_Rect *prWorld = NULL); bool Draw_Grid (const CSG_Rect &r, CSG_Grid *pGrid, const CSG_Colors &Colors, double zMin = 0.0, double zMax = 0.0, int Style = 0, CSG_Rect *prWorld = NULL); protected: bool _Fit_Rectangle (double &x, double &y, double &dx, double &dy, double XToY_Ratio, bool bShrink); bool _Fit_Rectangle (CSG_Rect &r, double XToY_Ratio, bool bShrink); bool _Add_Outline_Item (const SG_Char *Title, struct _HPDF_Dict_Rec *pPage, TSG_PDF_Title_Level Level = PDF_TITLE); bool _Draw_Ruler (const CSG_Rect &r, double zMin, double zMax, bool bHorizontal, bool bAscendent, bool bTickAtTop); bool _Draw_Text (double x, double y, const SG_Char *Text, int Size, int Style, double Angle, int Color, TSG_PDF_Font_Type Font); bool _Draw_Table (CSG_Rect r, CSG_Table *pTable, int iRecord, int nRecords, double CellHeight, double HeaderHeightRel); bool _Draw_Shape (CSG_Rect r, CSG_Shape *pShape, double xMin, double yMin, double World2PDF, int Style = PDF_STYLE_POLYGON_FILLSTROKE, int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, int Line_Width = 0, int Point_Width = 5); TSG_PDF_Title_Level _Get_Lowest_Outline_Level (void); private: bool m_Boxes_Space_bPercent; int m_nPages; double m_Boxes_Space; CSG_Rect m_Size_Paper, m_Size_Margins; CSG_Rects m_Boxes_Percent, m_Boxes; CSG_Strings m_Boxes_ID; struct _HPDF_Doc_Rec *m_pPDF; struct _HPDF_Dict_Rec *m_pPage; struct _HPDF_Dict_Rec *m_pOutline_Last_Level_0, *m_pOutline_Last_Level_1, *m_pOutline_Last_Level_2; struct _HPDF_Dict_Rec * _Get_Font (TSG_PDF_Font_Type Font); void _Layout_Set_Boxes (void); void _Layout_Set_Box (int iBox); bool _Set_Style_FillStroke (int Style, int Fill_Color, int Line_Color, int Line_Width); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__doc_pdf_H saga-2.3.1/src/modules/docs/docs_pdf/doc_pdf.cpp0000744000175000017500000014420512737416156022661 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_pdf.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_pdf // // // //-------------------------------------------------------// // // // doc_pdf.cpp // // // // Copyright (C) 2005 by // // Victor Olaya, Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. // // // // This library is free software; you can redistribute // // it and/or modify it under the terms of the GNU Lesser // // General Public License as published by the Free // // Software Foundation, version 2.1 of the License. // // // // This library is distributed in the hope that it will // // be useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU Lesser General Public // // License for more details. // // // // You should have received a copy of the GNU Lesser // // General Public License along with this program; if // // not, write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef _SAGA_DONOTUSE_HARU /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "doc_pdf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PDF_PAGE_WIDTH_A4 595.276 #define PDF_PAGE_HEIGHT_A4 841.89 #define PDF_PAGE_HEIGHT_A4_M 0.297 #define PDF_PAGE_WIDTH_A3 PDF_PAGE_HEIGHT_A4 #define PDF_PAGE_HEIGHT_A3 (PDF_PAGE_HEIGHT_A4 * sqrt(2.0)) #define PDF_METER_TO_POINT (PDF_PAGE_HEIGHT_A4 / PDF_PAGE_HEIGHT_A4_M) #define PDF_POINT_TO_METER (PDF_PAGE_HEIGHT_A4_M / PDF_PAGE_HEIGHT_A4) //--------------------------------------------------------- #define PDF_GET_R(c) (float)(SG_GET_R(c) / 255.0) #define PDF_GET_G(c) (float)(SG_GET_G(c) / 255.0) #define PDF_GET_B(c) (float)(SG_GET_B(c) / 255.0) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Doc_PDF::CSG_Doc_PDF(void) { m_pPDF = NULL; Layout_Set_Box_Space(5, false); Open(); } //--------------------------------------------------------- CSG_Doc_PDF::CSG_Doc_PDF(TSG_PDF_Page_Size Size, int Orientation, const SG_Char *Title) { m_pPDF = NULL; Layout_Set_Box_Space(5, false); Open(Size, Orientation, Title); } //--------------------------------------------------------- CSG_Doc_PDF::~CSG_Doc_PDF(void) { Close(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const SG_Char * CSG_Doc_PDF::Get_Version(void) { static CSG_String s = CSG_String::Format(SG_T("Haru Free PDF Library, Version %s"), HPDF_VERSION_TEXT); return( s ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Open(const SG_Char *Title) { return( Open(PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_PORTRAIT, Title) ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Open(TSG_PDF_Page_Size Size, int Orientation, const SG_Char *Title) { if( Close() ) { m_pPDF = HPDF_New(NULL, NULL); m_pOutline_Last_Level_0 = NULL; m_pOutline_Last_Level_1 = NULL; m_pOutline_Last_Level_2 = NULL; Set_Size_Page(Size, Orientation); if( Title && *Title ) { Add_Page_Title(Title); } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Close(void) { if( m_pPDF ) { try { HPDF_Free(m_pPDF); } catch(...) { return( false ); } } m_pPDF = NULL; m_pPage = NULL; m_nPages = 0; return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Save(const SG_Char *FileName) { if( m_pPDF && m_nPages > 0 && SG_Dir_Create(SG_File_Get_Path(FileName)) ) { try { return( HPDF_SaveToFile(m_pPDF, CSG_String(FileName)) == HPDF_OK ); } catch(...) {} } SG_UI_Msg_Add_Error(_TL("[ERR] Could not save PDF file.")); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CSG_Doc_PDF::Get_Page_To_Meter(void) { return( PDF_POINT_TO_METER ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- struct _HPDF_Dict_Rec * CSG_Doc_PDF::_Get_Font(TSG_PDF_Font_Type Font) { switch( Font ) { default: case PDF_FONT_Helvetica: return( HPDF_GetFont(m_pPDF, "Helvetica" , NULL) ); case PDF_FONT_Helvetica_Bold: return( HPDF_GetFont(m_pPDF, "Helvetica-Bold" , NULL) ); case PDF_FONT_Helvetica_Oblique: return( HPDF_GetFont(m_pPDF, "Helvetica-Oblique" , NULL) ); case PDF_FONT_Helvetica_BoldOblique: return( HPDF_GetFont(m_pPDF, "Helvetica-BoldOblique", NULL) ); case PDF_FONT_Times_Roman: return( HPDF_GetFont(m_pPDF, "Times-Roman" , NULL) ); case PDF_FONT_Times_Bold: return( HPDF_GetFont(m_pPDF, "Times-Bold" , NULL) ); case PDF_FONT_Times_Italic: return( HPDF_GetFont(m_pPDF, "Times-Italic" , NULL) ); case PDF_FONT_Times_BoldItalic: return( HPDF_GetFont(m_pPDF, "Times-BoldItalic" , NULL) ); case PDF_FONT_Courier: return( HPDF_GetFont(m_pPDF, "Courier" , NULL) ); case PDF_FONT_Courier_Bold: return( HPDF_GetFont(m_pPDF, "Courier-Bold" , NULL) ); case PDF_FONT_Courier_Oblique: return( HPDF_GetFont(m_pPDF, "Courier-Oblique" , NULL) ); case PDF_FONT_Courier_BoldOblique: return( HPDF_GetFont(m_pPDF, "Courier-BoldOblique" , NULL) ); case PDF_FONT_Symbol: return( HPDF_GetFont(m_pPDF, "Symbol" , NULL) ); case PDF_FONT_ZapfDingbats: return( HPDF_GetFont(m_pPDF, "ZapfDingbats" , NULL) ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Layout_Add_Box(double xMin_Percent, double yMin_Percent, double xMax_Percent, double yMax_Percent, const CSG_String &ID) { if( m_Boxes_Percent.Add(xMin_Percent, yMin_Percent, xMax_Percent, yMax_Percent) ) { m_Boxes.Add(); m_Boxes_ID.Add(ID); _Layout_Set_Box(m_Boxes.Get_Count() - 1); return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Layout_Add_Box(const CSG_Rect &Box_Percent, const CSG_String &ID) { return( Layout_Add_Box(Box_Percent.Get_XMin(), Box_Percent.Get_YMin(), Box_Percent.Get_XMax(), Box_Percent.Get_YMax(), ID) ); } //--------------------------------------------------------- const CSG_Rect & CSG_Doc_PDF::Layout_Get_Box(const CSG_String &ID) { for(int i=0; i= 0 && iBox < m_Boxes.Get_Count() && iBox < m_Boxes_Percent.Get_Count() ) { m_Boxes[iBox].Assign( m_Size_Margins.Get_XMin() + 0.01 * m_Boxes_Percent[iBox].Get_XMin() * m_Size_Margins.Get_XRange(), m_Size_Margins.Get_YMax() - 0.01 * m_Boxes_Percent[iBox].Get_YMax() * m_Size_Margins.Get_YRange(), m_Size_Margins.Get_XMin() + 0.01 * m_Boxes_Percent[iBox].Get_XMax() * m_Size_Margins.Get_XRange(), m_Size_Margins.Get_YMax() - 0.01 * m_Boxes_Percent[iBox].Get_YMin() * m_Size_Margins.Get_YRange() ); m_Boxes[iBox].Deflate(m_Boxes_Space, m_Boxes_Space_bPercent); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::_Fit_Rectangle(double &x, double &y, double &dx, double &dy, double XToY_Ratio, bool bShrink) { if( XToY_Ratio != 0.0 && dx != 0.0 && dy != 0.0 ) { if( XToY_Ratio > dx / dy ) { if( bShrink ) { XToY_Ratio = dx / XToY_Ratio; y += (dy - XToY_Ratio) / 2.0; dy = XToY_Ratio; } else { XToY_Ratio = dy * XToY_Ratio; x -= (dx - XToY_Ratio) / 2.0; dx = XToY_Ratio; } } else { if( bShrink ) { XToY_Ratio = dy * XToY_Ratio; x += (dx - XToY_Ratio) / 2.0; dx = XToY_Ratio; } else { XToY_Ratio = dx / XToY_Ratio; y -= (dy - XToY_Ratio) / 2.0; dy = XToY_Ratio; } } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::_Fit_Rectangle(CSG_Rect &r, double XToY_Ratio, bool bShrink) { double x, y, dx, dy; x = r.Get_XMin(); y = r.Get_YMin(); dx = r.Get_XRange(); dy = r.Get_YRange(); if( _Fit_Rectangle(x, y, dx, dy, XToY_Ratio, bShrink) ) { r.Assign(x, y, x + dx, y + dy); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::_Add_Outline_Item(const SG_Char *Title, struct _HPDF_Dict_Rec *pPage, TSG_PDF_Title_Level Level) { if( m_pPDF && pPage ) { HPDF_Outline pOutlineItem = NULL; switch( Level ) { case PDF_TITLE: pOutlineItem = m_pOutline_Last_Level_0 = HPDF_CreateOutline(m_pPDF, NULL, CSG_String(Title), NULL); break; case PDF_TITLE_01: if( m_pOutline_Last_Level_0 ) { pOutlineItem = m_pOutline_Last_Level_1 = HPDF_CreateOutline(m_pPDF, m_pOutline_Last_Level_0, CSG_String(Title), NULL); } break; case PDF_TITLE_02: if( m_pOutline_Last_Level_1 ) { pOutlineItem = m_pOutline_Last_Level_2 = HPDF_CreateOutline(m_pPDF, m_pOutline_Last_Level_1, CSG_String(Title), NULL); } break; case PDF_TITLE_NONE: if( m_pOutline_Last_Level_2 ) { pOutlineItem = HPDF_CreateOutline(m_pPDF, m_pOutline_Last_Level_2, CSG_String(Title), NULL); } break; } if( pOutlineItem ) { if( pPage ) { struct _HPDF_Array_Rec *pDestination = HPDF_Page_CreateDestination(pPage); HPDF_Destination_SetFit (pDestination); HPDF_Outline_SetDestination (pOutlineItem, pDestination); } return( true ); } } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Add_Outline_Item(const SG_Char *Title) { return( _Add_Outline_Item(Title, m_pPage, _Get_Lowest_Outline_Level()) ); } //--------------------------------------------------------- TSG_PDF_Title_Level CSG_Doc_PDF::_Get_Lowest_Outline_Level(void) { if( m_pOutline_Last_Level_2 ) { return( PDF_TITLE_NONE ); } else if( m_pOutline_Last_Level_1 ) { return( PDF_TITLE_02 ); } else if( m_pOutline_Last_Level_0 ) { return( PDF_TITLE_01 ); } return( PDF_TITLE ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Add_Page(void) { return( Add_Page(m_Size_Paper.Get_XRange(), m_Size_Paper.Get_YRange()) ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Add_Page(TSG_PDF_Page_Size Size, int Orientation) { if( Add_Page() ) { return( Set_Size_Page(Size, Orientation) ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Add_Page(double Width, double Height) { if( m_pPDF ) { m_nPages++; m_pPage = HPDF_AddPage(m_pPDF); Set_Size_Page(Width, Height); HPDF_Page_SetRGBStroke (m_pPage, 0.0, 0.0, 0.0); HPDF_Page_SetRGBFill (m_pPage, 1.0, 1.0, 1.0); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Set_Size_Page(TSG_PDF_Page_Size Size, int Orientation) { double Width, Height; switch( Size ) { case PDF_PAGE_SIZE_A4: default: Width = PDF_PAGE_WIDTH_A4; Height = PDF_PAGE_HEIGHT_A4; break; case PDF_PAGE_SIZE_A3: Width = PDF_PAGE_WIDTH_A3; Height = PDF_PAGE_HEIGHT_A3; break; } //----------------------------------------------------- if( Orientation == PDF_PAGE_ORIENTATION_LANDSCAPE ) { double a; a = Width; Width = Height; Height = a; } return( Set_Size_Page(Width, Height) ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Set_Size_Page(double Width, double Height) { if( Width > 0.0 && Height > 0.0 ) { m_Size_Paper.Assign(0.0, 0.0, Width, Height); m_Size_Margins = m_Size_Paper; m_Size_Margins.Deflate(10.0, false); _Layout_Set_Boxes(); if( m_pPage ) { HPDF_Page_SetWidth (m_pPage, (float)m_Size_Paper.Get_XRange()); HPDF_Page_SetHeight (m_pPage, (float)m_Size_Paper.Get_YRange()); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Add_Page_Title(const SG_Char *Title, TSG_PDF_Title_Level Level, TSG_PDF_Page_Size Size, int Orientation) { bool bLine, bDestination, bPage; int FontSize; //----------------------------------------------------- if( Add_Page() ) { if( m_nPages % 2 - 1 ) { Add_Page(); } if( Size != PDF_PAGE_SIZE_PREVIOUS || Orientation != PDF_PAGE_ORIENTATION_PREVIOUS ) { Set_Size_Page(Size, Orientation); } //------------------------------------------------- switch( Level ) { case PDF_TITLE: FontSize = 26; bLine = true; bDestination = true; bPage = true; break; case PDF_TITLE_01: FontSize = 22; bLine = true; bDestination = false; bPage = true; break; case PDF_TITLE_02: FontSize = 20; bLine = false; bDestination = false; bPage = false; break; } _Add_Outline_Item(Title, m_pPage, Level); //------------------------------------------------- Draw_Text(Get_Margins().Get_XCenter(), Get_Margins().Get_YCenter(), Title, FontSize, PDF_STYLE_TEXT_ALIGN_H_CENTER, 0.0, SG_GET_RGB(0, 0, 0)); //------------------------------------------------- if( bLine ) { double y = Get_Margins().Get_YCenter() - 25.0; Draw_Line(Get_Margins().Get_XMin(), y, Get_Margins().Get_XMax(), y, 5, SG_GET_RGB(0, 0, 0), PDF_STYLE_LINE_END_ROUND); } if( bPage ) { Add_Page(); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::_Set_Style_FillStroke(int Style, int Fill_Color, int Line_Color, int Line_Width) { if( Is_Ready_To_Draw() ) { if( Style & PDF_STYLE_POLYGON_STROKE ) { if( Style & PDF_STYLE_LINE_END_ROUND ) { HPDF_Page_SetLineCap(m_pPage, HPDF_ROUND_END); } else if( Style & PDF_STYLE_LINE_END_SQUARE ) { HPDF_Page_SetLineCap(m_pPage, HPDF_PROJECTING_SCUARE_END); } else // if( Style & PDF_STYLE_LINE_END_BUTT ) { HPDF_Page_SetLineCap(m_pPage, HPDF_BUTT_END); } if( Style & PDF_STYLE_LINE_JOIN_ROUND ) { HPDF_Page_SetLineJoin(m_pPage, HPDF_ROUND_JOIN); } else if( Style & PDF_STYLE_LINE_JOIN_BEVEL ) { HPDF_Page_SetLineJoin(m_pPage, HPDF_BEVEL_JOIN); } else // if( Style & PDF_STYLE_LINE_JOIN_MITER ) { HPDF_Page_SetLineJoin(m_pPage, HPDF_MITER_JOIN); } HPDF_Page_SetRGBStroke (m_pPage, PDF_GET_R(Line_Color), PDF_GET_G(Line_Color), PDF_GET_B(Line_Color)); HPDF_Page_SetLineWidth (m_pPage, (float)Line_Width); } //------------------------------------------------- if( Style & PDF_STYLE_POLYGON_FILL ) { HPDF_Page_SetRGBFill(m_pPage, PDF_GET_R(Fill_Color), PDF_GET_G(Fill_Color), PDF_GET_B(Fill_Color)); } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Point(double x, double y, double Width, int Style, int Fill_Color, int Line_Color, int Line_Width) { if( Is_Ready_To_Draw() ) { Width /= 2.0; //------------------------------------------------- // if( Style & PDF_STYLE_POINT_CIRCLE ) { } // else // if( Style & PDF_STYLE_POINT_SQUARE ) { return( Draw_Rectangle(x - Width, y - Width, x + Width, y + Width, Style, Fill_Color, Line_Color, Line_Width) ); } } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Line(double xa, double ya, double xb, double yb, int Width, int Color, int Style) { CSG_Points Points; Points.Add(xa, ya); Points.Add(xb, yb); return( Draw_Line(Points, Width, Color, Style) ); } bool CSG_Doc_PDF::Draw_Line(CSG_Points &Points, int Width, int Color, int Style) { if( Points.Get_Count() > 1 && _Set_Style_FillStroke(Style|PDF_STYLE_POLYGON_STROKE, 0, Color, Width) ) { HPDF_Page_MoveTo(m_pPage, (float)Points[0].x, (float)Points[0].y); for(int i=1; i 2 && _Set_Style_FillStroke(Style, Fill_Color, Line_Color, Line_Width) ) { HPDF_Page_MoveTo(m_pPage, (float)Points[0].x, (float)Points[0].y); for(int i=1; i 0 ) { for(int i=0; i= 0 ) { Strings.Add(String.Left(n)); String.Remove(0, n + 1); } if( Strings.Get_Count() > 0 ) { if( String.Length() > 0 ) { Strings.Add(String); } return( Draw_Text(x, y, Strings, Size, Style, Angle, Color, Font) ); } return( _Draw_Text(x, y, Text, Size, Style, Angle, Color, Font) ); } //--------------------------------------------------------- bool CSG_Doc_PDF::_Draw_Text(double x, double y, const SG_Char *Text, int Size, int Style, double Angle, int Color, TSG_PDF_Font_Type Font) { float Width, Height; if( m_pPage && Text && *Text != '\0' ) { double ax, ay, bx, by; HPDF_Page_SetFontAndSize(m_pPage, _Get_Font(Font), (float)Size); HPDF_Page_SetTextRenderingMode(m_pPage, HPDF_FILL_THEN_STROKE); HPDF_Page_SetLineWidth (m_pPage, 0); HPDF_Page_SetRGBStroke (m_pPage, PDF_GET_R(Color), PDF_GET_G(Color), PDF_GET_B(Color)); HPDF_Page_SetRGBFill (m_pPage, PDF_GET_R(Color), PDF_GET_G(Color), PDF_GET_B(Color)); Width = HPDF_Page_TextWidth(m_pPage, CSG_String(Text)) * (float)cos(Angle); Height = HPDF_Page_TextWidth(m_pPage, CSG_String(Text)) * (float)sin(Angle) + Size; //------------------------------------------------- if( Style & PDF_STYLE_TEXT_ALIGN_H_CENTER ) { ax = x - HPDF_Page_TextWidth(m_pPage, CSG_String(Text)) / 2.0; } else if( Style & PDF_STYLE_TEXT_ALIGN_H_RIGHT ) { ax = x - HPDF_Page_TextWidth(m_pPage, CSG_String(Text)); } else { ax = x; } bx = ax + HPDF_Page_TextWidth(m_pPage, CSG_String(Text)); if( Style & PDF_STYLE_TEXT_ALIGN_V_CENTER ) { ay = y - Size / 2.0; } else if( Style & PDF_STYLE_TEXT_ALIGN_V_TOP ) { ay = y - Size; } else { ay = y; } by = ay; //------------------------------------------------- HPDF_Page_BeginText(m_pPage); if( Angle != 0.0 ) { double dSin, dCos, dx, dy; dSin = sin(-Angle); dCos = cos(-Angle), dx = ax - x, dy = ay - y; ax = x + dCos * dx + dSin * dy; ay = y - dSin * dx + dCos * dy; dx = bx - x, dy = by - y; bx = x + dCos * dx + dSin * dy; by = y - dSin * dx + dCos * dy; dSin = sin(Angle); dCos = cos(Angle), HPDF_Page_SetTextMatrix(m_pPage, (float)dCos, (float)dSin, -(float)dSin, (float)dCos, (float)ax, (float)ay); } else { HPDF_Page_MoveTextPos(m_pPage, (float)ax, (float)ay); } HPDF_Page_ShowText(m_pPage, CSG_String(Text)); HPDF_Page_EndText(m_pPage); //------------------------------------------------- if( Style & PDF_STYLE_TEXT_UNDERLINE ) { double dx, dy; dy = 0.2 * Size * (ax - bx) / SG_Get_Distance(ax, ay, bx, by); dx = -0.2 * Size * (ay - by) / SG_Get_Distance(ax, ay, bx, by); Draw_Line(ax + dx, ay + dy, bx + dx, by + dy, (int)(0.1 * Size), Color); } if( Style & PDF_STYLE_TEXT_STROKE ) { double dx, dy; dy = -0.4 * Size * (ax - bx) / SG_Get_Distance(ax, ay, bx, by); dx = 0.4 * Size * (ay - by) / SG_Get_Distance(ax, ay, bx, by); Draw_Line(ax + dx, ay + dy, bx + dx, by + dy, (int)(0.1 * Size), Color); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Image(double x, double y, double dx, double dy, const SG_Char *FileName) { bool bKeepRatio = true; double nx, ny; HPDF_Image pImage = NULL; //----------------------------------------------------- if( m_pPage && SG_File_Exists(FileName) && dx > 0.0 && dy > 0.0 ) { if( SG_File_Cmp_Extension(FileName, SG_T("png")) ) { try { pImage = HPDF_LoadPngImageFromFile (m_pPDF, CSG_String(FileName)); } catch(...) {} } else if( SG_File_Cmp_Extension(FileName, SG_T("jpg")) ) { try { pImage = HPDF_LoadJpegImageFromFile(m_pPDF, CSG_String(FileName)); } catch(...) {} } } //----------------------------------------------------- if( pImage && (nx = HPDF_Image_GetWidth(pImage)) > 0 && (ny = HPDF_Image_GetHeight(pImage)) > 0 ) { if( bKeepRatio ) { _Fit_Rectangle(x, y, dx, dy, nx / ny, true); } HPDF_Page_DrawImage(m_pPage, pImage, (float)x, (float)y, (float)dx, (float)dy); return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Image(const CSG_Rect &r, const SG_Char *FileName) { return( Draw_Image(r.Get_XMin(), r.Get_YMin(), r.Get_XRange(), r.Get_YRange(), FileName) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Graticule(const CSG_Rect &r, const CSG_Rect &rWorld, int Size) { if( Is_Ready_To_Draw() ) { CSG_Rect rRuler, rFrame(r); rFrame.Inflate(Size, false); Draw_Rectangle(rFrame, PDF_STYLE_POLYGON_STROKE); Draw_Rectangle(r , PDF_STYLE_POLYGON_STROKE); rRuler.Assign(r.Get_XMin(), r.Get_YMax(), r.Get_XMax(), rFrame.Get_YMax()); _Draw_Ruler(rRuler, rWorld.Get_XMin(), rWorld.Get_XMax() , true , true , false); rRuler.Assign(r.Get_XMin(), r.Get_YMin(), r.Get_XMax(), rFrame.Get_YMin()); _Draw_Ruler(rRuler, 0.0 , rWorld.Get_XRange(), true , true , true); rRuler.Assign(r.Get_XMin(), r.Get_YMin(), rFrame.Get_XMin(), r.Get_YMax()); _Draw_Ruler(rRuler, rWorld.Get_YMin(), rWorld.Get_YMax() , false, false, false); rRuler.Assign(r.Get_XMax(), r.Get_YMin(), rFrame.Get_XMax(), r.Get_YMax()); _Draw_Ruler(rRuler, 0.0 , rWorld.Get_YRange(), false, false, true); return( true ); } return( false ); } //--------------------------------------------------------- #define RULER_TEXT_SPACE 4 //--------------------------------------------------------- bool CSG_Doc_PDF::_Draw_Ruler(const CSG_Rect &r, double zMin, double zMax, bool bHorizontal, bool bAscendent, bool bTickAtTop) { int Decimals, FontSize; double xOff, yOff, Width, Height, Height_Tick, z, dz, zToDC, zDC, zPos, tPos; CSG_String s; //----------------------------------------------------- Width = bHorizontal ? r.Get_XRange() : r.Get_YRange(); Height = bHorizontal ? r.Get_YRange() : r.Get_XRange(); if( Is_Ready_To_Draw() && zMin < zMax && Width > 0 && Height > 0 ) { xOff = r.Get_XMin(); yOff = r.Get_YMax(); FontSize = (int)(0.45 * (double)Height); HPDF_Page_SetFontAndSize(m_pPage, _Get_Font(PDF_FONT_DEFAULT), (float)FontSize); Height_Tick = (int)(0.3 * (double)Height); //------------------------------------------------- zToDC = (double)Width / (zMax - zMin); dz = pow(10.0, floor(log10(zMax - zMin)) - 1.0); Decimals = dz >= 1.0 ? 0 : (int)fabs(log10(dz)); s.Printf(SG_T("%.*f"), Decimals, zMax); zDC = HPDF_Page_TextWidth(m_pPage, CSG_String(s)); while( zToDC * dz < zDC + RULER_TEXT_SPACE ) { dz *= 2; } //------------------------------------------------- z = dz * floor(zMin / dz); if( z < zMin ) z += dz; for(; z<=zMax; z+=dz) { s.Printf(SG_T("%.*f"), Decimals, z); zDC = bAscendent ? zToDC * (z - zMin) : Width - zToDC * (z - zMin); if( bHorizontal ) { zPos = xOff + zDC; if( bTickAtTop ) { tPos = yOff; Draw_Line(zPos, tPos - Height_Tick, zPos, yOff); Draw_Text(zPos, tPos - Height_Tick, s, FontSize, PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_TOP, 0.0); } else { tPos = yOff - Height; Draw_Line(zPos, tPos + Height_Tick, zPos, tPos); Draw_Text(zPos, tPos + Height_Tick, s, FontSize, PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_BOTTOM, 0.0); } } else { zPos = yOff - zDC; if( bTickAtTop ) { tPos = xOff; Draw_Line(tPos + Height_Tick, zPos, tPos, zPos); Draw_Text(tPos + Height_Tick, zPos, s, FontSize, PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_TOP, M_DEG_TO_RAD * 90.0); } else { tPos = xOff + Height; Draw_Line(tPos - Height_Tick, zPos, tPos, zPos); Draw_Text(tPos - Height_Tick, zPos, s, FontSize, PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_BOTTOM, M_DEG_TO_RAD * 90.0); } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::_Draw_Table(CSG_Rect r, CSG_Table *pTable, int iRecord, int nRecords, double CellHeight, double HeaderHeightRel) { int iField, dyFont, dyFont_Hdr; double xPos, yPos, dxPos, dyPos, dyPos_Hdr, xSpace, ySpace, ySpace_Hdr; bool bAddHeader; CSG_Table_Record *pRecord; if( pTable && pTable->is_Valid() && iRecord < pTable->Get_Record_Count() ) { // Draw_Text(r.Get_XMin(), r.Get_YMax(), pTable->Get_Name(), 16); // the table's name should not be drawn here... dxPos = r.Get_XRange() / pTable->Get_Field_Count(); if( HeaderHeightRel < 1.0 ) HeaderHeightRel = 1.0; dyPos = CellHeight > 0.0 ? CellHeight : r.Get_YRange() / (nRecords + HeaderHeightRel); dyPos_Hdr = dyPos * HeaderHeightRel; dyFont = (int)(0.75 * dyPos); dyFont_Hdr = (int)(0.75 * dyPos_Hdr); ySpace = 0.1 * dyPos; ySpace_Hdr = 0.1 * dyPos_Hdr; xSpace = ySpace; nRecords += iRecord; if( nRecords > pTable->Get_Record_Count() ) { nRecords = pTable->Get_Record_Count(); } //------------------------------------------------- for(yPos=r.Get_YMax(), bAddHeader=true; iRecordGet_Field_Count(); iField++, xPos+=dxPos) { Draw_Rectangle(xPos, yPos, xPos + dxPos, yPos - dyPos_Hdr, PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_GREY_LIGHT, SG_COLOR_BLACK, 0); Draw_Text(xPos + xSpace, yPos - ySpace_Hdr, pTable->Get_Field_Name(iField), dyFont_Hdr, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP); } yPos -= dyPos_Hdr; bAddHeader = false; } //--------------------------------------------- pRecord = pTable->Get_Record(iRecord); for(iField=0, xPos=r.Get_XMin(); iFieldGet_Field_Count(); iField++, xPos+=dxPos) { Draw_Rectangle(xPos, yPos, xPos + dxPos, yPos - dyPos, PDF_STYLE_POLYGON_STROKE, SG_COLOR_WHITE, SG_COLOR_BLACK, 0); Draw_Text(xPos + xSpace, yPos - ySpace, pRecord->asString(iField), dyFont, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP); } } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Table(const CSG_Rect &r, CSG_Table *pTable, double CellHeight, double HeaderHeightRel) { if( pTable && pTable->is_Valid() ) { return( _Draw_Table(r, pTable, 0, pTable->Get_Record_Count(), CellHeight, HeaderHeightRel) ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Table(const CSG_Rect &r, CSG_Table *pTable, int nColumns, double CellHeight, double HeaderHeightRel) { if( pTable && pTable->is_Valid() && nColumns > 1 ) { int nRecords; double dx, dxSpace; CSG_Rect rColumn(r), rTable(r); dxSpace = 4; rTable.Inflate(dxSpace, 0.0, false); dx = rTable.Get_XRange() / (double)nColumns; nRecords = pTable->Get_Record_Count() / nColumns; for(int i=0, iRecord=0; iis_Valid() ) { int iPart, iPoint; TSG_Point Point; CSG_Points Points; for(iPart=0; iPartGet_Part_Count(); iPart++) { Points.Clear(); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Point = pShape->Get_Point(iPoint, iPart); Point.x = r.Get_XMin() + World2PDF * (Point.x - xMin); Point.y = r.Get_YMin() + World2PDF * (Point.y - yMin); Points.Add(Point.x, Point.y); } switch( pShape->Get_Type() ) { case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: for(iPoint=0; iPointis_Lake(iPart) ) { Draw_Polygon(Points, PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_WHITE, Line_Color, Line_Width); } else { Draw_Polygon(Points, Style, Fill_Color, Line_Color, Line_Width); } break; } } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Shape(const CSG_Rect &r, CSG_Shape *pShape, int Style, int Fill_Color, int Line_Color, int Line_Width, CSG_Rect *prWorld) { double World2PDF; CSG_Rect rWorld, rFit; if( pShape && pShape->is_Valid() && r.Get_XRange() > 0.0 && r.Get_YRange() > 0.0 ) { rWorld = prWorld ? *prWorld : pShape->Get_Extent(); if( rWorld.Get_XRange() > 0.0 && rWorld.Get_YRange() > 0.0 ) { _Fit_Rectangle(rFit = r, rWorld.Get_XRange() / rWorld.Get_YRange(), true); World2PDF = rFit.Get_XRange() / rWorld.Get_XRange(); _Draw_Shape(rFit, pShape, rWorld.Get_XMin(), rWorld.Get_YMin(), World2PDF, Style, Fill_Color, Line_Color, Line_Width, Line_Width); return( true ); } } return( false ); } //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Shapes(const CSG_Rect &r, CSG_Shapes *pShapes, int Style, int Fill_Color, int Line_Color, int Line_Width, CSG_Rect *prWorld) { double World2PDF; CSG_Rect rWorld, rFit; if( pShapes && pShapes->is_Valid() && r.Get_XRange() > 0.0 && r.Get_YRange() > 0.0 ) { rWorld = prWorld ? *prWorld : pShapes->Get_Extent(); if( rWorld.Get_XRange() > 0.0 && rWorld.Get_YRange() > 0.0 ) { _Fit_Rectangle(rFit = r, rWorld.Get_XRange() / rWorld.Get_YRange(), true); World2PDF = rFit.Get_XRange() / rWorld.Get_XRange(); for(int iShape=0; iShapeGet_Count(); iShape++) { _Draw_Shape(rFit, pShapes->Get_Shape(iShape), rWorld.Get_XMin(), rWorld.Get_YMin(), World2PDF, Style, Fill_Color, Line_Color, Line_Width, Line_Width); } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Doc_PDF::Draw_Grid(const CSG_Rect &r, CSG_Grid *pGrid, const CSG_Colors &Colors, double zMin, double zMax, int Style, CSG_Rect *prWorld) { double x, y, z, d, xFit, yFit, dFit; CSG_Rect rWorld, rFit; if( Is_Ready_To_Draw() && pGrid && pGrid->is_Valid() && pGrid->Get_ZRange() > 0.0 ) { rWorld = prWorld ? *prWorld : pGrid->Get_Extent(); if( rWorld.Get_XRange() > 0.0 && rWorld.Get_YRange() > 0.0 ) { _Fit_Rectangle(rFit = r, rWorld.Get_XRange() / rWorld.Get_YRange(), true); dFit = 1.0; d = dFit * (rWorld.Get_XRange() / rFit.Get_XRange()); if( zMin >= zMax ) { zMin = pGrid->Get_ZMin(); zMax = pGrid->Get_ZMax(); } zMax = Colors.Get_Count() / (zMax - zMin); for(y=rWorld.Get_YMin(), yFit=rFit.Get_YMin(); yFitGet_Extent().Get_YMax(); y++, yFit+=dFit, y+=d) { for(x=rWorld.Get_XMin(), xFit=rFit.Get_XMin(); xFitGet_Extent().Get_XMax(); x++, xFit+=dFit, x+=d) { if( pGrid->Get_Value(x, y, z) ) { Draw_Point(xFit, yFit, dFit, PDF_STYLE_POINT_SQUARE|PDF_STYLE_POLYGON_FILL, Colors.Get_Color((int)(zMax * (z - zMin)))); } } } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSG_Doc_PDF::Draw_Curve(CSG_Points &Data, const CSG_Rect &r, int iGraphType) { /* int i; int iMag; int iNumLines; int iNumData; float fMinLine = 0; float fWidth; float fMax, fMin; float fStep; float fX, fY; float fMaxX, fMinX; float fOffsetX; CSG_String sValue; CSG_Points Points; fMin = fMax = Data[0].y; for (i = 0; i < Data.Get_Count(); i++) { if (Data[i].y > fMax) { fMax = Data[i].y; } if (Data[i].y < fMin) { fMin = Data[i].y; } if (iGraphType == PDF_GRAPH_TYPE_BARS){ fMin = M_GET_MIN(0, fMin); } } if (fMin != fMax){ iMag = (int) (log(fMax - fMin) / log(10.0)); fStep = (float) ((int) pow(10.0, (double) iMag)); if (fStep == 0) { fStep = 1.; } if (fMin < 0) { iMag = (int) (log(fabs(fMin)) / log(10.0)); fMinLine = -(int) pow(10.0, (double) iMag); } else { fMinLine=(int)(((int)(fMin/fStep)) *fStep); } iNumLines = (int) ((fMax - fMin) / fStep); while (iNumLines < 8) { fStep = fStep / 2.0; iNumLines = (int) ((fMax - fMin) / fStep); } iNumLines = (int) ((fMax - fMinLine) / fStep); } else{ if (fMin > 0) { fStep = fMin = 0; iNumLines = 1; fMinLine = fMax; } else if (fMin < 0) { fStep = 0; fMin = fMin - 1; fMinLine = fMax; } else { return; } } for (i = 0; i < iNumLines; i++) { fY = r.Get_YMax() - ((fMinLine + fStep * i - fMin) / (fMax - fMin)) * r.Get_YRange(); if (fY <= r.Get_YMax() && fY >= r.Get_YMin()) { fY = HPDF_Page_Height() - fY; } } if (iGraphType == PDF_GRAPH_TYPE_BARS) { fWidth = (float) r.Get_XRange() / (float) (Data.Get_Count()); for (i = 0; i < Data.Get_Count(); i++) { fX = r.Get_XMin() + i * fWidth; fY = r.Get_YMax(); fY = HPDF_Page_Height() - fY; Draw_Rectangle(fX, fY, fX + fWidth, fY - r.Get_YRange() * ((Data[i].y - fMin) / (fMax - fMin)), PDF_STYLE_POLYGON_FILLSTROKE, 0x660000); } } else { fWidth = (float) r.Get_XRange() / (float) (Data.Get_Count() - 1); fY = r.Get_YMin() + r.Get_YRange() - r.Get_YRange() * ((Data[0].y - fMin) / (fMax - fMin)); fY = HPDF_Page_Height() - fY; Points.Add(r.Get_XMin(), fY); for (i = 1; i < Data.Get_Count(); i++) { fY = r.Get_YMin() + r.Get_YRange() - r.Get_YRange() * ((Data[i].y - fMin) / (fMax - fMin)); fY = HPDF_Page_Height() - fY; Points.Add(r.Get_XMin() + i * fWidth, fY); } Draw_Line(Points, 3, 0x660000); } fMaxX = Data[Data.Get_Count() - 1].x; fMinX = Data[0].x; if (fMaxX != fMinX) { iMag = (int) (log(fMaxX - fMinX) / log(10.0)); fStep = (float) pow(10.0, (double) iMag); iNumData = (int) ((fMaxX-fMinX) / fStep); while (iNumData < 3) { fStep = fStep / 2.0; iNumData = (int) ((fMaxX-fMinX) / fStep); } fMinLine = (int)(((int)(fMinX/fStep)) * fStep); while (fMinLine= r.Get_XMin() && fX < r.Get_XMin() + r.Get_XRange()){ if (fabs(fStep * (float)i +fMinLine) > 100000) { sValue = SG_Get_String(fStep * (float)i +fMinLine); } else { sValue = SG_Get_String(fStep * (float)i + fMinLine, 2, true); } Draw_Text(fX, fY, sValue, 9, PDF_STYLE_TEXT_ALIGN_H_RIGHT); Draw_Line(fX, fY, fX, fY - 10, 1); } } } Draw_Line(r.Get_XMin(), HPDF_Page_Height() - r.Get_YMin(), r.Get_XMin(), HPDF_Page_Height() - r.Get_YMax(), 4); Draw_Line(r.Get_XMin(), HPDF_Page_Height() - r.Get_YMax(), r.Get_XMax(), HPDF_Page_Height() - r.Get_YMax(), 4); */ } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #else // #ifndef _SAGA_DONOTUSE_HARU #include "doc_pdf.h" //--------------------------------------------------------- const SG_Char * CSG_Doc_PDF::Get_Version(void) { return( NULL ); } CSG_Doc_PDF::CSG_Doc_PDF(void) { m_pPDF = NULL; } CSG_Doc_PDF::CSG_Doc_PDF(TSG_PDF_Page_Size Size, int Orientation, const SG_Char *Title) { m_pPDF = NULL; } CSG_Doc_PDF::~CSG_Doc_PDF(void) {} void CSG_Doc_PDF::Layout_Set_Box_Space(double Space, bool bPercent) {} void CSG_Doc_PDF::_Layout_Set_Boxes(void) {} void CSG_Doc_PDF::_Layout_Set_Box(int iBox) {} double CSG_Doc_PDF::Get_Page_To_Meter(void) { return( 1.0 ); } struct _HPDF_Dict_Rec * CSG_Doc_PDF::_Get_Font(TSG_PDF_Font_Type Font) { return( NULL ); } const CSG_Rect & CSG_Doc_PDF::Layout_Get_Box(const SG_Char *ID) { return( m_Size_Margins ); } TSG_PDF_Title_Level CSG_Doc_PDF::_Get_Lowest_Outline_Level(void) { return( PDF_TITLE_NONE ); } bool CSG_Doc_PDF::Open(const SG_Char *Title) { return( false ); } bool CSG_Doc_PDF::Open(TSG_PDF_Page_Size Size, int Orientation, const SG_Char *Title) { return( false ); } bool CSG_Doc_PDF::Close(void) { return( false ); } bool CSG_Doc_PDF::Save(const SG_Char *FileName) { return( false ); } bool CSG_Doc_PDF::Layout_Add_Box(double xMin_Percent, double yMin_Percent, double xMax_Percent, double yMax_Percent, const SG_Char *ID) { return( false ); } bool CSG_Doc_PDF::Layout_Add_Box(const CSG_Rect &Box_Percent, const SG_Char *ID) { return( false ); } bool CSG_Doc_PDF::_Fit_Rectangle(double &x, double &y, double &dx, double &dy, double XToY_Ratio, bool bShrink) { return( false ); } bool CSG_Doc_PDF::_Fit_Rectangle(CSG_Rect &r, double XToY_Ratio, bool bShrink) { return( false ); } bool CSG_Doc_PDF::_Add_Outline_Item(const SG_Char *Title, struct _HPDF_Dict_Rec *pPage, TSG_PDF_Title_Level Level) { return( false ); } bool CSG_Doc_PDF::Add_Outline_Item(const SG_Char *Title) { return( false ); } bool CSG_Doc_PDF::Add_Page(void) { return( false ); } bool CSG_Doc_PDF::Add_Page(TSG_PDF_Page_Size Size, int Orientation) { return( false ); } bool CSG_Doc_PDF::Add_Page(double Width, double Height) { return( false ); } bool CSG_Doc_PDF::Set_Size_Page(TSG_PDF_Page_Size Size, int Orientation) { return( false ); } bool CSG_Doc_PDF::Set_Size_Page(double Width, double Height) { return( false ); } bool CSG_Doc_PDF::Add_Page_Title(const SG_Char *Title, TSG_PDF_Title_Level Level, TSG_PDF_Page_Size Size, int Orientation) { return( false ); } bool CSG_Doc_PDF::_Set_Style_FillStroke(int Style, int Fill_Color, int Line_Color, int Line_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Point(double x, double y, double Width, int Style, int Fill_Color, int Line_Color, int Line_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Line(double xa, double ya, double xb, double yb, int Width, int Color, int Style) { return( false ); } bool CSG_Doc_PDF::Draw_Line(CSG_Points &Points, int Width, int Color, int Style) { return( false ); } bool CSG_Doc_PDF::Draw_Rectangle(double xa, double ya, double xb, double yb, int Style, int Fill_Color, int Line_Color, int Line_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Rectangle(const CSG_Rect &r, int Style, int Fill_Color, int Line_Color, int Line_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Polygon(CSG_Points &Points, int Style, int Fill_Color, int Line_Color, int Line_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Text(double x, double y, CSG_Strings &Text, int Size, int Style, double Angle, int Color, TSG_PDF_Font_Type Font) { return( false ); } bool CSG_Doc_PDF::Draw_Text(double x, double y, const SG_Char *Text, int Size, int Style, double Angle, int Color, TSG_PDF_Font_Type Font) { return( false ); } bool CSG_Doc_PDF::_Draw_Text(double x, double y, const SG_Char *Text, int Size, int Style, double Angle, int Color, TSG_PDF_Font_Type Font) { return( false ); } bool CSG_Doc_PDF::Draw_Image(double x, double y, double dx, double dy, const SG_Char *FileName) { return( false ); } bool CSG_Doc_PDF::Draw_Image(const CSG_Rect &r, const SG_Char *FileName) { return( false ); } bool CSG_Doc_PDF::Draw_Graticule(const CSG_Rect &r, const CSG_Rect &rWorld, int Size) { return( false ); } bool CSG_Doc_PDF::_Draw_Ruler(const CSG_Rect &r, double zMin, double zMax, bool bHorizontal, bool bAscendent, bool bTickAtTop) { return( false ); } bool CSG_Doc_PDF::_Draw_Table(CSG_Rect r, CSG_Table *pTable, int iRecord, int nRecords, double CellHeight, double HeaderHeightRel) { return( false ); } bool CSG_Doc_PDF::Draw_Table(const CSG_Rect &r, CSG_Table *pTable, double CellHeight, double HeaderHeightRel) { return( false ); } bool CSG_Doc_PDF::Draw_Table(const CSG_Rect &r, CSG_Table *pTable, int nColumns, double CellHeight, double HeaderHeightRel) { return( false ); } bool CSG_Doc_PDF::_Draw_Shape(CSG_Rect r, CSG_Shape *pShape, double xMin, double yMin, double World2PDF, int Style, int Fill_Color, int Line_Color, int Line_Width, int Point_Width) { return( false ); } bool CSG_Doc_PDF::Draw_Shape(const CSG_Rect &r, CSG_Shape *pShape, int Style, int Fill_Color, int Line_Color, int Line_Width, CSG_Rect *prWorld) { return( false ); } bool CSG_Doc_PDF::Draw_Shapes(const CSG_Rect &r, CSG_Shapes *pShapes, int Style, int Fill_Color, int Line_Color, int Line_Width, CSG_Rect *prWorld) { return( false ); } bool CSG_Doc_PDF::Draw_Grid(const CSG_Rect &r, CSG_Grid *pGrid, const CSG_Colors &Colors, double zMin, double zMax, int Style, CSG_Rect *prWorld) { return( false ); } void CSG_Doc_PDF::Draw_Curve(CSG_Points &Data, const CSG_Rect &r, int iGraphType) {} #endif // #else // #ifndef _SAGA_DONOTUSE_HARU /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/docs/docs_pdf/Profile_Cross_Sections.cpp0000744000175000017500000012736512737416156025713 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Profile_Cross_Sections.cpp 1230 2011-11-22 11:12:10Z oconrad $ *********************************************************/ /******************************************************************************* CrossSections.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Profile_Cross_Sections.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define OFFSET_X 100 #define OFFSET_Y 50 #define TABLE_WIDTH 450 #define TABLE_LANDSCAPE_WIDTH 680 #define TABLE_OFFSET_X 70 #define TABLE_CELLPAD 10 #define SECTIONS_PER_PAGE 3 #define CROSS_SECTION_HEIGHT 200 #define CROSS_SECTION_WIDTH 400 #define PROFILE_HEIGHT 320 #define PROFILE_WIDTH 1000 #define GUITAR_LEYEND_WIDTH 50 #define GUITAR_LEYEND_HEIGHT 230 #define GUITAR_WIDTH PROFILE_WIDTH #define GUITAR_HEIGHT GUITAR_LEYEND_HEIGHT #define SEPARATION 35 #define VOLUMES_TABLE_COLUMNS 7 #define VOLUMES_TABLE_COLUMN_WIDTH ((596 - 2 * OFFSET_X) / VOLUMES_TABLE_COLUMNS) #define VOLUMES_TABLE_ROW_HEIGHT 20 #define VOLUMES_TABLE_HEADER_SEPARATION 35 #define VOLUMES_TABLE_MAX_ROWS 30 #define SLOPE_RATIO (1. / 3.) #define LONG_SEGMENT 5000. /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //Compute the dot product AB ? BC double dot(double *A, double *B, double *C){ double AB[2],BC[2]; AB[0] = B[0]-A[0]; AB[1] = B[1]-A[1]; BC[0] = C[0]-B[0]; BC[1] = C[1]-B[1]; double dot = AB[0] * BC[0] + AB[1] * BC[1]; return dot; } //--------------------------------------------------------- //Compute the cross product AB x AC double cross(double *A, double *B, double *C){ double AB[2],AC[2]; AB[0] = B[0]-A[0]; AB[1] = B[1]-A[1]; AC[0] = C[0]-A[0]; AC[1] = C[1]-A[1]; double cross = AB[0] * AC[1] - AB[1] * AC[0]; return cross; } //--------------------------------------------------------- //Compute the distance from A to B double distance(double *A, double *B){ double d1 = A[0] - B[0]; double d2 = A[1] - B[1]; return sqrt(d1*d1+d2*d2); } //--------------------------------------------------------- //Compute the distance from AB to C double linePointDist(double *A, double *B, double *C){ double dist = cross(A,B,C) / distance(A,B); return fabs(dist); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SLOPE_TRANSITION 1 #define DITCH_WIDTH 1 CProfile_Cross_Sections_PDF::CProfile_Cross_Sections_PDF(){} CProfile_Cross_Sections_PDF::~CProfile_Cross_Sections_PDF(){} void CProfile_Cross_Sections_PDF::AddCrossSections(TSG_Point ** pCrossSections, double *pHeight, TSG_Point * pRoadSection, int iSections, int iCrossSectionPoints, int iRoadPoints){ int i,j; std::vector ModifiedRoadSection; std::vector ModifiedCrossSection; TSG_Point *pModifiedRoadSection; TSG_Point *pModifiedCrossSection; int iCrossSectionPointsB; int iRoadPointsB; Add_Page_Title (_TL("Cross Sections"), PDF_TITLE_01, PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_PORTRAIT); for (i = 0; i < iSections; i++){ m_iOffsetY = OFFSET_Y + (int)(CROSS_SECTION_HEIGHT * 1.1 * (i % SECTIONS_PER_PAGE)); if (m_iOffsetY == OFFSET_Y){ Add_Page(); }//if iCrossSectionPointsB = iCrossSectionPoints; iRoadPointsB = iRoadPoints; AdjustSections(pCrossSections[i], pRoadSection, ModifiedCrossSection, ModifiedRoadSection, pHeight[i], iCrossSectionPointsB, iRoadPointsB); pModifiedCrossSection = new TSG_Point [iCrossSectionPointsB]; pModifiedRoadSection = new TSG_Point [iRoadPointsB]; for (j = 0; j < iCrossSectionPointsB; j++){ pModifiedCrossSection[j] = ModifiedCrossSection[j]; }//for for (j = 0; j < iRoadPointsB; j++){ pModifiedRoadSection[j] = ModifiedRoadSection[j]; }//for AddCrossSection(pModifiedCrossSection, pModifiedRoadSection, iCrossSectionPointsB, iRoadPointsB); delete [] pModifiedRoadSection; delete [] pModifiedCrossSection; }//for }//method void CProfile_Cross_Sections_PDF::AddCrossSection(TSG_Point * pCrossSection, TSG_Point * pRoadSection, int iCrossSectionPoints, int iRoadPoints){ int i; int iMag; int iNumLines; int iFirstPoint, iLastPoint; double fMinLine = 0; double fMaxY, fMinY; double fMaxX, fMinX; double fStep; double fX, fY; double fOffsetX; double fDifX, fDifY; double fRatio; double fHeight; CSG_String sValue; CSG_Points Points; iFirstPoint = 0; iLastPoint = iCrossSectionPoints - 1; for (i = 1; i < iCrossSectionPoints; i++) { if (pCrossSection[i].x > pRoadSection[0].x){ iFirstPoint = i - 1; break; }//if }//for for (i = 1; i < iCrossSectionPoints; i++) { if (pCrossSection[i].x > pRoadSection[iRoadPoints - 1].x){ iLastPoint = i; break; }//if }//for fMinX = pCrossSection[iFirstPoint].x; fMaxX = pCrossSection[iLastPoint].x; fDifX = fMaxX - fMinX; fMaxY = pCrossSection[0].y; fMinY = pCrossSection[0].y; for (i = iFirstPoint ; i < iLastPoint + 1; i++) { if (pCrossSection[i].y > fMaxY) { fMaxY = pCrossSection[i].y; }// if if (pCrossSection[i].y < fMinY) { fMinY = pCrossSection[i].y; }// if }//for for (i = 0; i < iRoadPoints; i++) { if (pRoadSection[i].y > fMaxY) { fMaxY = pRoadSection[i].y; }// if if (pRoadSection[i].y < fMinY) { fMinY = pRoadSection[i].y; }// if }//for fDifY = fMaxY - fMinY; fRatio = (fDifX / fDifY) / (CROSS_SECTION_WIDTH / CROSS_SECTION_HEIGHT); if (fRatio > 1){ fMaxY = fMaxY + fDifY / 2. * (fRatio - 1.); fMinY = fMinY - fDifY / 2. * (fRatio - 1.); }//if else{ fMaxX = fMaxX + fDifX / 2. * (1. / fRatio - 1.); fMinX = fMinX - fDifX / 2. * (1. / fRatio - 1.); }//else fMaxX = fMaxX + fDifX * .05; fMinX = fMinX - fDifX * .05; fMaxY = fMaxY + fDifY * .05; fMinY = fMinY - fDifY * .05; iMag = (int) (log(fMaxY - fMinY) / log(10.0)); fStep = (double) ((int) pow(10.0, (double) iMag)); if (fStep == 0){ fStep = 1.; }//if if (fMinY < 0) { iMag = (int) (log(fabs(fMinY)) / log(10.0)); fMinLine = -(int) pow(10.0, (double) iMag); }// if else { fMinLine=(int)(((int)(fMinY/fStep)) *fStep); }//else iNumLines = (int) ((fMaxY - fMinY) / fStep); while (iNumLines < 8) { fStep = fStep / 2.0; iNumLines = (int) ((fMaxY - fMinY) / fStep); }// while iNumLines = (int) ((fMaxY - fMinLine) / fStep); fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); //horizontal lines for (i = 0; i < iNumLines; i++) { fY = m_iOffsetY + CROSS_SECTION_HEIGHT - ((fMinLine + fStep * i - fMinY) / (fMaxY - fMinY)) * CROSS_SECTION_HEIGHT; if (fY <= m_iOffsetY + CROSS_SECTION_HEIGHT && fY >= m_iOffsetY) { fY = fHeight - fY; sValue = SG_Get_String(fMinLine + fStep * (double) i); Draw_Text(OFFSET_X - 10, fY, SG_Get_String(fMinLine + fStep * (double) i).c_str(), 9, PDF_STYLE_TEXT_ALIGN_H_RIGHT); Draw_Line(OFFSET_X, fY, OFFSET_X - 5, fY, 0); }// if }// for iMag = (int) (log(fMaxX - fMinX) / log(10.0)); fStep = (double) pow(10.0, (double) iMag); iNumLines = (int) ((fMaxX-fMinX) / fStep); while (iNumLines < 3) { fStep = fStep / 2.0; iNumLines = (int) ((fMaxX-fMinX) / fStep); }// while fMinLine = (int)(((int)(fMinX/fStep)) * fStep); while (fMinLine= OFFSET_X && fX < OFFSET_X + CROSS_SECTION_WIDTH){ if (fabs(fStep * (double)i+fMinLine) > 100000) { sValue = SG_Get_String(fStep * (double)i+fMinLine); }// if else { sValue = SG_Get_String(fStep * (double)i+fMinLine, 2, true); }// else Draw_Line (fX, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT, fX, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT - 10); Draw_Text(fX, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT - 15, SG_Get_String(fMinLine + fStep * (double) i).c_str(), 9, PDF_STYLE_TEXT_ALIGN_H_CENTER | PDF_STYLE_TEXT_ALIGN_V_TOP ); }//if }// for //axis Draw_Line (OFFSET_X, fHeight - m_iOffsetY, OFFSET_X, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT, 2); Draw_Line (OFFSET_X, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT, OFFSET_X + CROSS_SECTION_WIDTH, fHeight - m_iOffsetY - CROSS_SECTION_HEIGHT, 2); //cross sections fY = m_iOffsetY + CROSS_SECTION_HEIGHT - CROSS_SECTION_HEIGHT * ((pCrossSection[iFirstPoint].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_X + CROSS_SECTION_WIDTH * ((pCrossSection[iFirstPoint].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX,fY); for (i = iFirstPoint + 1; i < iLastPoint + 1; i++) { fY = m_iOffsetY + CROSS_SECTION_HEIGHT - CROSS_SECTION_HEIGHT * ((pCrossSection[i].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_X + CROSS_SECTION_WIDTH * ((pCrossSection[i].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX,fY); if (pCrossSection[i].x > fMaxX){ break; }//if }// for Draw_Line(Points, 2, 0x00bb00); fY = m_iOffsetY + CROSS_SECTION_HEIGHT - CROSS_SECTION_HEIGHT * ((pRoadSection[0].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_X + CROSS_SECTION_WIDTH * ((pRoadSection[0].x - fMinX) / (fMaxX - fMinX)); Points.Clear(); Points.Add(fX,fY); for (i = 1; i < iRoadPoints; i++) { fY = m_iOffsetY + CROSS_SECTION_HEIGHT - CROSS_SECTION_HEIGHT * ((pRoadSection[i].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_X + CROSS_SECTION_WIDTH * ((pRoadSection[i].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX,fY); }// for Draw_Line(Points, 0, 0x0000bb); }//method void CProfile_Cross_Sections_PDF::AddVolumesTable(TSG_Point * pProfile, TSG_Point ** pCrossSections, double *pHeight, TSG_Point * pRoadSection, int iSections, int iCrossSectionPoints, int iRoadPoints){ int i,j; int iRow; int iRowsWritten = 0; double fDist; double fX,fY; double fXBox, fYBox; double fIn, fOut; double fInPrev, fOutPrev; double fVolume; double fHeight; CSG_String sHeader[] = {_TL("Section"),_TL("Dist."),_TL("Area +"),_TL("Area -"),_TL("Partial D."),_TL("Vol. +"), _TL("Vol. -")}; Add_Page_Title(_TL("Volumes"), PDF_TITLE_01); fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); for (i = 0; i < iSections; i++){ iRow = iRowsWritten % VOLUMES_TABLE_MAX_ROWS; if (iRow == 0){ Add_Page(); Draw_Rectangle(OFFSET_X, fHeight - OFFSET_Y, OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * VOLUMES_TABLE_COLUMNS, fHeight - OFFSET_Y - VOLUMES_TABLE_ROW_HEIGHT); fY = OFFSET_Y + VOLUMES_TABLE_ROW_HEIGHT * .6; fY = fHeight - fY; for (j = 0; j < VOLUMES_TABLE_COLUMNS; j++){ fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * j + VOLUMES_TABLE_COLUMN_WIDTH / 2.; Draw_Text(fX, fY, sHeader[j].c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * (j + 1); Draw_Line(fX, fHeight - OFFSET_Y, fX, fHeight - (OFFSET_Y + VOLUMES_TABLE_ROW_HEIGHT), 0); }//for if (i){ i--; }//if }//if for (j = 0; j < 4; j++){ fYBox = OFFSET_Y + VOLUMES_TABLE_HEADER_SEPARATION + VOLUMES_TABLE_ROW_HEIGHT * iRow; fYBox = fHeight - fYBox; fXBox = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * j; Draw_Rectangle(fXBox, fYBox, fXBox + VOLUMES_TABLE_COLUMN_WIDTH, fYBox - VOLUMES_TABLE_ROW_HEIGHT); }//for fDist = pProfile[i].x; fY = OFFSET_Y + VOLUMES_TABLE_HEADER_SEPARATION + VOLUMES_TABLE_ROW_HEIGHT * (iRow + .6); fY = fHeight - fY; fX = OFFSET_X + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(i,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fDist,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); CalculateAreas(pCrossSections[i], pRoadSection, pHeight[i], iCrossSectionPoints, iRoadPoints,fIn, fOut); fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * 2 + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fIn,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * 3 + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fOut,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); if (iRow > 0){ for (j = 4; j < 7; j++){ fYBox = OFFSET_Y + VOLUMES_TABLE_HEADER_SEPARATION + VOLUMES_TABLE_ROW_HEIGHT * (iRow - .5); fYBox = fHeight - fYBox; fXBox = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * j; Draw_Rectangle(fXBox, fYBox, fXBox + VOLUMES_TABLE_COLUMN_WIDTH, fYBox - VOLUMES_TABLE_ROW_HEIGHT); }//for fY = OFFSET_Y + VOLUMES_TABLE_HEADER_SEPARATION + VOLUMES_TABLE_ROW_HEIGHT * (iRow + .1) ; fY = fHeight - fY; fDist = (pProfile[i].x - pProfile[i-1].x); fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * 4 + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fDist,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); fVolume = (pProfile[i].x - pProfile[i-1].x) * (fIn + fInPrev) / 2.; fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * 5 + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fVolume,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); fVolume = (pProfile[i].x - pProfile[i-1].x) * (fOut + fOutPrev) / 2.; fX = OFFSET_X + VOLUMES_TABLE_COLUMN_WIDTH * 6 + (VOLUMES_TABLE_COLUMN_WIDTH) / 2.; Draw_Text(fX, fY, SG_Get_String(fVolume,0).c_str(), 10, PDF_STYLE_TEXT_ALIGN_H_CENTER); }//if fInPrev = fIn; fOutPrev = fOut; iRowsWritten++; }//for }//Method void CProfile_Cross_Sections_PDF::AdjustSections(TSG_Point * pCrossSection, TSG_Point * pRoadSection, std::vector &ModifiedCrossSection, std::vector &ModifiedRoadSection, double fHeight, int &iCrossSectionPoints, int &iRoadPoints){ bool bDitchAdded; int i,j; int iSgn; int iRoadPointsToAdd = 0; int iCrossSectionPointsToAdd = 0; double fX, fY; TSG_Point P; ModifiedCrossSection.clear(); ModifiedRoadSection.clear(); //left half for (i = 0 ; i < iCrossSectionPoints - 1; i++){ if (pCrossSection[i].x < pRoadSection[0].x && pCrossSection[i+1].x >= pRoadSection[0].x){ break; }//if }//for if (i == iCrossSectionPoints - 1){ if (pRoadSection[0].y + fHeight < pCrossSection[0].y){ P.x = pRoadSection[0].x - 2* DITCH_WIDTH * SLOPE_TRANSITION - DITCH_WIDTH - fabs(pCrossSection[0].y - pRoadSection[0].y - fHeight) / SLOPE_RATIO; P.y = pCrossSection[0].y - fHeight; ModifiedRoadSection.push_back(P); P.y = pCrossSection[0].y; ModifiedCrossSection.push_back(P); iCrossSectionPointsToAdd++; iRoadPointsToAdd++; P.x = pRoadSection[0].x - 2* DITCH_WIDTH * SLOPE_TRANSITION - DITCH_WIDTH; P.y = pRoadSection[0].y; ModifiedRoadSection.push_back(P); iRoadPointsToAdd++; P.x = pRoadSection[0].x - DITCH_WIDTH * SLOPE_TRANSITION - DITCH_WIDTH; P.y = pRoadSection[0].y - DITCH_WIDTH / SLOPE_TRANSITION; ModifiedRoadSection.push_back(P); iRoadPointsToAdd++; P.x = pRoadSection[0].x - DITCH_WIDTH * SLOPE_TRANSITION; ModifiedRoadSection.push_back(P); iRoadPointsToAdd++; }//if P.x = pRoadSection[0].x - fabs(pCrossSection[0].y - pRoadSection[0].y - fHeight) / SLOPE_RATIO; P.y = pCrossSection[0].y - fHeight; ModifiedRoadSection.push_back(P); P.y = pCrossSection[0].y; ModifiedCrossSection.push_back(P); iCrossSectionPointsToAdd++; iRoadPointsToAdd++; }//if else{ bDitchAdded = false; for (j = 0; j < 4; j++){ //4 dummy points ModifiedRoadSection.push_back(pRoadSection[0]); }//for for (j = i ; j >= 0; j--){ if (ModifiedRoadSection[1].y + fHeight > pCrossSection[j+1].y){ iSgn = -1; }//if else{ iSgn = 1; }//else Intersect_Lines(ModifiedRoadSection[1].x, ModifiedRoadSection[1].y + fHeight, ModifiedRoadSection[1].x - LONG_SEGMENT / SLOPE_RATIO, ModifiedRoadSection[1].y + LONG_SEGMENT * iSgn + fHeight, pCrossSection[j].x, pCrossSection[j].y, pCrossSection[j+1].x, pCrossSection[j+1].y, fX,fY); if (pCrossSection[j].x < fX && pCrossSection[j+1].x >= fX){ if (iSgn == 1){ if(!bDitchAdded){ ModifiedRoadSection[1].x = pRoadSection[0].x - 2* DITCH_WIDTH * SLOPE_TRANSITION - DITCH_WIDTH; ModifiedRoadSection[1].y = pRoadSection[0].y; iRoadPointsToAdd++; ModifiedRoadSection[2].x = pRoadSection[0].x - DITCH_WIDTH * SLOPE_TRANSITION - DITCH_WIDTH; ModifiedRoadSection[2].y = pRoadSection[0].y - DITCH_WIDTH / SLOPE_TRANSITION; iRoadPointsToAdd++; ModifiedRoadSection[3].x = pRoadSection[0].x - DITCH_WIDTH * SLOPE_TRANSITION; ModifiedRoadSection[3].y = pRoadSection[0].y - DITCH_WIDTH / SLOPE_TRANSITION; iRoadPointsToAdd++; j = i + 1; bDitchAdded = true; }//if else{ ModifiedRoadSection[0].x = fX; ModifiedRoadSection[0].y = fY - fHeight; iRoadPointsToAdd++; break; }//else }//if else{ ModifiedRoadSection[0].x = fX; ModifiedRoadSection[0].y = fY - fHeight; iRoadPointsToAdd++; break; }//else }//if }//for if (j < 0){ ModifiedRoadSection[0].x = pRoadSection[0].x - fabs(pCrossSection[0].y - pRoadSection[0].y - fHeight) / SLOPE_RATIO; ModifiedRoadSection[0].y = pCrossSection[0].y - fHeight; P.x = ModifiedRoadSection[0].x; P.y = pCrossSection[0].y; ModifiedCrossSection.push_back(P); iCrossSectionPointsToAdd++; iRoadPointsToAdd++; }//if*/ }//else //add the central points for (i = 0; i < iCrossSectionPoints; i++){ ModifiedCrossSection.push_back(pCrossSection[i]); }//for ModifiedRoadSection.resize(iRoadPoints + iRoadPointsToAdd); for (i = 0; i < iRoadPoints; i++){ ModifiedRoadSection[i + iRoadPointsToAdd].x = pRoadSection[i].x; ModifiedRoadSection[i + iRoadPointsToAdd].y = pRoadSection[i].y; }//for for (i = 0; i < iRoadPoints + iRoadPointsToAdd; i++){ ModifiedRoadSection[i].x = ModifiedRoadSection[i].x; ModifiedRoadSection[i].y = ModifiedRoadSection[i].y + fHeight; }//for iRoadPoints += iRoadPointsToAdd; iCrossSectionPoints += iCrossSectionPointsToAdd; // right half for (i = 0 ; i < iCrossSectionPoints - 1; i++){ if (ModifiedCrossSection[i].x < ModifiedRoadSection[iRoadPoints-1].x && ModifiedCrossSection[i+1].x >= ModifiedRoadSection[iRoadPoints-1].x){ break; }//if }//for if (i == iCrossSectionPoints - 1){ if (ModifiedRoadSection[iRoadPoints-1].y + fHeight < ModifiedCrossSection[iCrossSectionPoints-1].y){ P.x = ModifiedRoadSection[iRoadPoints-1].x + DITCH_WIDTH * SLOPE_TRANSITION; P.y = ModifiedRoadSection[iRoadPoints-1].y - DITCH_WIDTH / SLOPE_TRANSITION; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-2].x + DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-3].x + 2* DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; P.y = ModifiedRoadSection[iRoadPoints-3].y; ModifiedRoadSection.push_back(P); iRoadPoints++; }//if P.x = ModifiedRoadSection[iRoadPoints-1].x + fabs(ModifiedCrossSection[iCrossSectionPoints-1].y - ModifiedRoadSection[iRoadPoints-1].y) / SLOPE_RATIO; P.y = ModifiedCrossSection[iCrossSectionPoints-1].y ; ModifiedRoadSection.push_back(P); ModifiedCrossSection.push_back(P); iCrossSectionPoints++; iRoadPoints++; }//if else{ bDitchAdded = false; for (j = i ; j < iCrossSectionPoints - 1; j++){ if (ModifiedRoadSection[iRoadPoints-1].y > ModifiedCrossSection[j].y){ iSgn = -1; }//if else{ iSgn = 1; }//else if (iSgn == 1 && !bDitchAdded){ P.x = ModifiedRoadSection[iRoadPoints-1].x + DITCH_WIDTH * SLOPE_TRANSITION; P.y = ModifiedRoadSection[iRoadPoints-1].y - DITCH_WIDTH / SLOPE_TRANSITION; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-2].x + DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-3].x + 2* DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; P.y = ModifiedRoadSection[iRoadPoints-3].y; ModifiedRoadSection.push_back(P); iRoadPoints++; if (ModifiedRoadSection[iRoadPoints-1].y > ModifiedCrossSection[j].y){ iSgn = -1; }//if else{ iSgn = 1; }//else bDitchAdded = true; }//if Intersect_Lines(ModifiedRoadSection[iRoadPoints-1].x, ModifiedRoadSection[iRoadPoints-1].y, ModifiedRoadSection[iRoadPoints-1].x + LONG_SEGMENT / SLOPE_RATIO, ModifiedRoadSection[iRoadPoints-1].y + LONG_SEGMENT * iSgn, ModifiedCrossSection[j].x, ModifiedCrossSection[j].y, ModifiedCrossSection[j+1].x, ModifiedCrossSection[j+1].y, fX,fY); if (ModifiedCrossSection[j].x < fX && ModifiedCrossSection[j+1].x >= fX){ P.x = fX; P.y = fY; ModifiedRoadSection.push_back(P); iRoadPoints++; break; }//if }//for if (j == iCrossSectionPoints - 1){ if (ModifiedRoadSection[iRoadPoints-1].y + fHeight < ModifiedCrossSection[iCrossSectionPoints-1].y && !bDitchAdded){ P.x = ModifiedRoadSection[iRoadPoints-1].x + DITCH_WIDTH * SLOPE_TRANSITION; P.y = ModifiedRoadSection[iRoadPoints-1].y - DITCH_WIDTH / SLOPE_TRANSITION; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-2].x + DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; ModifiedRoadSection.push_back(P); iRoadPoints++; P.x = ModifiedRoadSection[iRoadPoints-3].x + 2* DITCH_WIDTH * SLOPE_TRANSITION + DITCH_WIDTH; P.y = ModifiedRoadSection[iRoadPoints-3].y; ModifiedRoadSection.push_back(P); iRoadPoints++; }//if P.x = ModifiedRoadSection[iRoadPoints-1].x + fabs(ModifiedCrossSection[iCrossSectionPoints-1].y - ModifiedRoadSection[iRoadPoints-1].y) / SLOPE_RATIO; P.y = ModifiedCrossSection[iCrossSectionPoints-1].y ; ModifiedRoadSection.push_back(P); ModifiedCrossSection.push_back(P); iCrossSectionPoints++; iRoadPoints++; }//if*/ }//else }//method void CProfile_Cross_Sections_PDF::Intersect_Lines(double x0,double y0,double x1,double y1, double x2,double y2,double x3,double y3, double &xi,double &yi){ double a1,b1,c1, a2,b2,c2, det_inv, m1,m2; if ((x1-x0)!=0) m1 = (y1-y0)/(x1-x0); else m1 = (double)1e+10; if ((x3-x2)!=0) m2 = (y3-y2)/(x3-x2); else m2 = (double)1e+10; a1 = m1; a2 = m2; b1 = -1; b2 = -1; c1 = (y0-m1*x0); c2 = (y2-m2*x2); det_inv = 1/(a1*b2 - a2*b1); xi=((b1*c2 - b2*c1)*det_inv); yi=((a2*c1 - a1*c2)*det_inv); } //method void CProfile_Cross_Sections_PDF::CalculateAreas(TSG_Point * pCrossSection, TSG_Point * pRoadSection, double fHeight, int iCrossSectionPoints, int iRoadPoints, double &fPositiveArea, double &fNegativeArea){ int i; CSG_Shapes *pRoadShapes, *pCrossSectionShapes, *pResultShapes; CSG_Shape *pRoadShape, *pCrossSectionShape, *pResultShape; pResultShapes = new CSG_Shapes; pResultShapes->Create(SHAPE_TYPE_Polygon); pResultShape = pResultShapes->Add_Shape(); pRoadShapes = new CSG_Shapes; pRoadShapes->Create(SHAPE_TYPE_Polygon); pRoadShape = pRoadShapes->Add_Shape(); pCrossSectionShapes = new CSG_Shapes; pCrossSectionShapes->Create(SHAPE_TYPE_Polygon); pCrossSectionShape = pCrossSectionShapes->Add_Shape(); for (i = 0; i < iRoadPoints; i++){ pRoadShape->Add_Point(pRoadSection[i].x, pRoadSection[i].y + fHeight); }//for pRoadShape->Add_Point(pRoadSection[iRoadPoints-1].x + LONG_SEGMENT / SLOPE_RATIO, pRoadSection[iRoadPoints-1].y + fHeight + LONG_SEGMENT); pRoadShape->Add_Point(pRoadSection[0].x - LONG_SEGMENT / SLOPE_RATIO, pRoadSection[0].y + fHeight + LONG_SEGMENT); for (i = 0; i < iCrossSectionPoints; i++){ pCrossSectionShape->Add_Point(pCrossSection[i].x, pCrossSection[i].y); }//for pCrossSectionShape->Add_Point(pCrossSection[iCrossSectionPoints-1].x + LONG_SEGMENT / SLOPE_RATIO, pCrossSection[iCrossSectionPoints-1].y - LONG_SEGMENT); pCrossSectionShape->Add_Point(pCrossSection[0].x - LONG_SEGMENT / SLOPE_RATIO, pCrossSection[0].y - LONG_SEGMENT); if (SG_Polygon_Intersection(pCrossSectionShape, pRoadShape, pResultShape)){ fNegativeArea = ((CSG_Shape_Polygon*)pResultShape)->Get_Area(); }//if else{ fNegativeArea = 0; }//else pCrossSectionShape->Del_Parts(); pRoadShape->Del_Parts(); pResultShape->Del_Parts(); for (i = 0; i < iRoadPoints; i++){ pRoadShape->Add_Point(pRoadSection[i].x, pRoadSection[i].y + fHeight); }//for pRoadShape->Add_Point(pRoadSection[iRoadPoints-1].x + LONG_SEGMENT / SLOPE_RATIO, pRoadSection[iRoadPoints-1].y + fHeight - LONG_SEGMENT); pRoadShape->Add_Point(pRoadSection[0].x - LONG_SEGMENT / SLOPE_RATIO, pRoadSection[0].y + fHeight - LONG_SEGMENT); for (i = 0; i < iCrossSectionPoints; i++){ pCrossSectionShape->Add_Point(pCrossSection[i].x, pCrossSection[i].y); }//for pCrossSectionShape->Add_Point(pCrossSection[iCrossSectionPoints-1].x + LONG_SEGMENT / SLOPE_RATIO, pCrossSection[iCrossSectionPoints-1].y + LONG_SEGMENT); pCrossSectionShape->Add_Point(pCrossSection[0].x - LONG_SEGMENT / SLOPE_RATIO, pCrossSection[0].y + LONG_SEGMENT); if (SG_Polygon_Intersection(pCrossSectionShape, pRoadShape, pResultShape)){ fPositiveArea = ((CSG_Shape_Polygon*)pResultShape)->Get_Area(); }//if else{ fPositiveArea = 0; }//else delete pRoadShapes; delete pCrossSectionShapes; delete pResultShapes; }//method void CProfile_Cross_Sections_PDF::AddLongitudinalProfile(TSG_Point * pProfile, double *pHeight, int iNumPoints){ int i; int iMag; int iNumLines; double fMinLine = 0; double fMaxY, fMinY; double fMaxX, fMinX; double fStep; double fX, fY; double fOffsetX; CSG_String sValue; CSG_Points Points; double fHeight; Add_Page_Title(_TL("Longitudinal Profile"), PDF_TITLE_01); Add_Page(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE); fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); m_iOffsetY = 50; fMaxY = pProfile[0].y; fMinY = pProfile[0].y; for (i = 0; i < iNumPoints; i++) { if (pProfile[i].y > fMaxY) { fMaxY = pProfile[i].y; }// if if (pProfile[i].y < fMinY) { fMinY = pProfile[i].y; }// if if (pHeight[i] > fMaxY) { fMaxY = pHeight[i]; }// if if (pHeight[i] < fMinY) { fMinY = pHeight[i]; }// if }//for iMag = (int) (log(fMaxY - fMinY) / log(10.0)); fStep = (double) ((int) pow(10.0, (double) iMag)); if (fStep == 0){ fStep = 1.; }//if if (fMinY < 0) { iMag = (int) (log(fabs(fMinY)) / log(10.0)); fMinLine = -(int) pow(10.0, (double) iMag); }// if else { fMinLine=(int)(((int)(fMinY/fStep)) *fStep); }//else iNumLines = (int) ((fMaxY - fMinY) / fStep); while (iNumLines < 8) { fStep = fStep / 2.0; iNumLines = (int) ((fMaxY - fMinY) / fStep); }// while iNumLines = (int) ((fMaxY - fMinLine) / fStep); fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); for (i = 0; i < iNumLines; i++) { fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION; fY = m_iOffsetY + PROFILE_HEIGHT - ((fMinLine + fStep * i - fMinY) / (fMaxY - fMinY)) * PROFILE_HEIGHT; if (fY <= m_iOffsetY + PROFILE_HEIGHT && fY >= m_iOffsetY) { fY = fHeight - fY; sValue = SG_Get_String(fMinLine + fStep * (double) i); Draw_Text(fX - 10, fY, SG_Get_String(fMinLine + fStep * (double) i).c_str(), 9, PDF_STYLE_TEXT_ALIGN_H_RIGHT); Draw_Line(fX, fY, fX - 5, fY, 0); }// if }// for fMinX = pProfile[0].x; fMaxX = pProfile[iNumPoints - 1].x; iMag = (int) (log(fMaxX - fMinX) / log(10.0)); fStep = (double) pow(10.0, (double) iMag); iNumLines = (int) ((fMaxX-fMinX) / fStep); while (iNumLines < 3) { fStep = fStep / 2.0; iNumLines = (int) ((fMaxX-fMinX) / fStep); }// while fMinLine = (int)(((int)(fMinX/fStep)) * fStep); while (fMinLine=OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION && fX < OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH){ if (fabs(fStep * (double)i+fMinLine) > 100000) { sValue = SG_Get_String(fStep * (double)i+fMinLine); }// if else { sValue = SG_Get_String(fStep * (double)i+fMinLine, 2, true); }// else Draw_Text(fX, fHeight - m_iOffsetY - PROFILE_HEIGHT - 15, SG_Get_String(fMinLine + fStep * (double) i).c_str(), 9, PDF_STYLE_TEXT_ALIGN_H_CENTER | PDF_STYLE_TEXT_ALIGN_V_TOP); Draw_Line(fX, fHeight - m_iOffsetY - PROFILE_HEIGHT, fX, fHeight - m_iOffsetY - PROFILE_HEIGHT - 10, 0); }//if }// for Draw_Line(OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION, fHeight - m_iOffsetY, OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION, fHeight - m_iOffsetY - PROFILE_HEIGHT, 2); Draw_Line(OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION, fHeight - m_iOffsetY - PROFILE_HEIGHT, OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH, fHeight - m_iOffsetY - PROFILE_HEIGHT, 2); fY = m_iOffsetY + PROFILE_HEIGHT - PROFILE_HEIGHT * ((pProfile[0].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH * ((pProfile[0].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX, fY); for (i = 1; i < iNumPoints; i++) { fY = m_iOffsetY + PROFILE_HEIGHT - PROFILE_HEIGHT * ((pProfile[i].y - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH * ((pProfile[i].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX, fY); }// for Draw_Line(Points, 2, 0x00bb00); Points.Clear(); fY = m_iOffsetY + PROFILE_HEIGHT - PROFILE_HEIGHT * ((pHeight[0] - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH * ((pProfile[0].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX,fY); for (i = 1; i < iNumPoints; i++) { fY = m_iOffsetY + PROFILE_HEIGHT - PROFILE_HEIGHT * ((pHeight[i] - fMinY) / (fMaxY - fMinY)); fY = fHeight - fY; fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH * ((pProfile[i].x - fMinX) / (fMaxX - fMinX)); Points.Add(fX, fY); }// for Draw_Line(Points, 2, 0x0000bb); DrawGuitar(pProfile, pHeight, iNumPoints); }//method void CProfile_Cross_Sections_PDF::DrawGuitar(TSG_Point *pProfile, double *pHeight, int iNumPoints){ int i; double fY; double fMinX, fMaxX; double fDif; CSG_String sValue; CSG_String sField [] = {"Distancia","Dist. Parcial.", "Elevacion del terreno", "Elevación de la calzada", " ", " "}; double fHeight; fMinX = pProfile[0].x; fMaxX = pProfile[iNumPoints - 1].x; fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); for (i = 0; i < 7; i++){ fY = m_iOffsetY + PROFILE_HEIGHT + SEPARATION + GUITAR_LEYEND_HEIGHT / 6 * i; fY = fHeight - fY; Draw_Line(OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION, fY, OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + GUITAR_WIDTH, fY, 0, 0x880000); if (i){ Draw_Text(OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION - 10, fY + GUITAR_LEYEND_HEIGHT / 13, sField[i-1].c_str(), 9, PDF_STYLE_TEXT_ALIGN_V_CENTER | PDF_STYLE_TEXT_ALIGN_H_RIGHT); }//if }//for AddGuitarValue(0, 0, fMinX, fMaxX, 1); for (i = 0; i < iNumPoints; i++) { AddGuitarValue(pProfile[i].x, pProfile[i].x / 1000, fMinX, fMaxX, 0); if (i){ AddGuitarValue(pProfile[i].x, pProfile[i].x / 1000 - pProfile[i-1].x / 1000, fMinX, fMaxX, 1); }//if fDif = pProfile[i].y - pHeight[i]; AddGuitarValue(pProfile[i].x, pProfile[i].y, fMinX, fMaxX, 2); AddGuitarValue(pProfile[i].x, pHeight[i], fMinX, fMaxX, 3); if (fDif > 0){ AddGuitarValue(pProfile[i].x, fDif, fMinX, fMaxX, 4); }//if else{ AddGuitarValue(pProfile[i].x, fDif, fMinX, fMaxX, 5); }//else }// for }//method void CProfile_Cross_Sections_PDF::AddGuitarValue(double fXValue, double fValue, double fMinX, double fMaxX, int iLine){ double fX,fY; double fHeight; fHeight = Get_Size_Page().Get_YMax() - Get_Size_Page().Get_YMin(); fX = OFFSET_Y + GUITAR_LEYEND_WIDTH + SEPARATION + PROFILE_WIDTH * ((fXValue - fMinX) / (fMaxX - fMinX)); fY = m_iOffsetY + PROFILE_HEIGHT + SEPARATION + GUITAR_LEYEND_HEIGHT / 6 * (iLine + 1); fY = fHeight - fY; Draw_Line(fX, fY, fX, fY + 3, 0, 0x880000); fY += 3; fX += 3; Draw_Text(fX, fY, SG_Get_String(fValue, 2).c_str(), 8, 0, 3.14159/2.); fY = m_iOffsetY + PROFILE_HEIGHT + SEPARATION + GUITAR_LEYEND_HEIGHT / 6 * iLine; fY = fHeight - fY; fX -= 3; Draw_Line(fX, fY, fX, fY - 3, 0, 0x880000); }//method /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CProfile_Cross_Sections::CProfile_Cross_Sections(void){ CSG_Parameter *pNode; Parameters.Set_Name(_TL("Terrain Path Cross Sections")); Parameters.Set_Description(_TW("(c) 2004 Victor Olaya. Cross Sections")); Parameters.Add_Grid(NULL, "DEM", _TL("DEM"), _TL("Digital Terrain Model"), PARAMETER_INPUT); Parameters.Add_Shapes(NULL, "LINES", _TL("Path"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line); Parameters.Add_Shapes(NULL, "SECTIONS", _TL("Cross Sections"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "NUMPOINTS", _TL("Number of points"), _TL("Number of points on each side of the section"), PARAMETER_TYPE_Int, 10, 1, true); Parameters.Add_Value(NULL, "INTERVAL", _TL("Interval"), _TL("Interval between points (in grid units)."), PARAMETER_TYPE_Double, 10); Parameters.Add_Value(NULL, "STEP", _TL("n"), _TL("Draw a section each n points"), PARAMETER_TYPE_Int, 2); pNode = Parameters.Add_Node(NULL, "PDFNODE", _TL("PDF Documents"), _TL("")); Parameters.Add_Value(pNode, "PDF", _TL("Create PDF Documents"), _TL(""), PARAMETER_TYPE_Bool, true); Parameters.Add_FilePath(pNode, "OUTPUTPATH", _TL("Folder for PDF Files"), _TL(""), _TL(""), _TL(""), true, true); Parameters.Add_Value(pNode, "WIDTH", _TL("Road Width"), _TL(""), PARAMETER_TYPE_Double, 5.); Parameters.Add_Value(pNode, "SLOPE", _TL("Side Slope"), _TL(""), PARAMETER_TYPE_Double, .5); Parameters.Add_Value(pNode, "THRESHOLD", _TL("Height Threshold"), _TL("Height threshold for optimal profile calculation"), PARAMETER_TYPE_Double, .5); }//constructor CProfile_Cross_Sections::~CProfile_Cross_Sections(void){} bool CProfile_Cross_Sections::On_Execute(void){ CSG_Shapes *pLines; CSG_Shape *pShape, *pSection; CSG_Grid *pDEM; TSG_Point Point, Point2; double fInterval; double fStepX, fStepY; int iNumPoints; int i,j,k; int iPoint; int iField = 0; int iStep; double dX, dY; double dX2, dY2; double dDistance; double dHeight; bool bCopy; m_pSections = Parameters("SECTIONS")->asShapes(); pLines = Parameters("LINES")->asShapes(); pDEM = Parameters("DEM")->asGrid(); fInterval = (double) Parameters("INTERVAL")->asDouble(); iNumPoints = Parameters("NUMPOINTS")->asInt(); iStep = Parameters("STEP")->asInt(); if(pLines == m_pSections){ bCopy = true; m_pSections = SG_Create_Shapes(); }//if else{ bCopy = false; }//else m_pSections->Create(SHAPE_TYPE_Line, _TL("Cross Sections")); for (i = iNumPoints; i > 0; i--){ m_pSections->Add_Field(CSG_String::Format(SG_T("-%s"), SG_Get_String(fInterval * i, 2).c_str()), SG_DATATYPE_Double); }//for m_pSections->Add_Field("0", SG_DATATYPE_Double); for (i = 1; i < iNumPoints +1; i++){ m_pSections->Add_Field(SG_Get_String(fInterval * i).c_str(), SG_DATATYPE_Double); }//for for(i=0; iGet_Count() && Set_Progress(i, pLines->Get_Count()); i++){ pShape = pLines->Get_Shape(i); for(j=0; jGet_Part_Count(); j++){ for(k=0; kGet_Point_Count(j)-1; k+=iStep){ Point = pShape->Get_Point(k,j); Point2 = pShape->Get_Point(k+1,j); dDistance = sqrt(pow(Point2.x - Point.x,2) + pow(Point2.y - Point.y,2)); dX = (Point.x + Point2.x) / 2.; dY = (Point.y + Point2.y) / 2.; fStepX = (Point2.y - Point.y) / dDistance * fInterval; fStepY = -(Point2.x - Point.x) / dDistance * fInterval; pSection = m_pSections->Add_Shape(); pSection->Add_Point(dX + iNumPoints * fStepX, dY + iNumPoints * fStepY); pSection->Add_Point(dX - iNumPoints * fStepX, dY - iNumPoints * fStepY); iField = 0; for (iPoint = iNumPoints; iPoint > 0; iPoint--){ dX2 = dX - iPoint * fStepX; dY2 = dY - iPoint * fStepY; dHeight = pDEM->Get_Value(dX2, dY2); pSection->Set_Value(iField, dHeight); iField++; }//for dHeight = pDEM->Get_Value(dX, dY); pSection->Set_Value(iField, dHeight); iField++; for (iPoint = 1; iPoint < iNumPoints +1; iPoint++){ dX2 = dX + iPoint * fStepX; dY2 = dY + iPoint * fStepY; dHeight = pDEM->Get_Value(dX2, dY2); pSection->Set_Value(iField, dHeight); iField++; }//for*/ }//for }//for }//for if (Parameters("PDF")->asBool()){ CreatePDFDocs(); }//if if(bCopy){ pLines->Assign(m_pSections); delete(m_pSections); }//if return true; }// method void CProfile_Cross_Sections::CreatePDFDocs(){ CSG_String sFilePath; if (Parameters("OUTPUTPATH")->asString()){ m_DocEngine.Open(_TL("SECTIONS")); sFilePath = SG_File_Make_Path(Parameters("OUTPUTPATH")->asString(), _TL("Sections"), _TL("pdf")); }//if else{ Message_Add(_TL("\n** Error : Invalid parameters **\n")); return; }//else AddLongitudinalProfiles(); AddCrossSections(); if (m_DocEngine.Save(sFilePath)){ if (!m_DocEngine.Close()){ Message_Add(_TL("\n\n ** Error : Could not close PDF engine ** \n\n")); } }//if else{ Message_Add(_TL("\n\n ** Error : Could not save PDF file ** \n\n")); }//else }//method void CProfile_Cross_Sections::AddLongitudinalProfiles(){ int i,j,k; int iIndex = 0; int iNumPoints = Parameters("NUMPOINTS")->asInt(); int iStep = Parameters("STEP")->asInt(); int iFirstPoint = 0; int iLastPoint; int iSections; double fX1, fY1, fX2, fY2; double fDistance, fDistanceSum = 0; double fDist; double fThreshold = (double)Parameters("THRESHOLD")->asDouble(); bool bValid; CSG_Shape *pShape; CSG_Table *pTable; TSG_Point Point, Point2; CSG_Shapes* pLines = Parameters("LINES")->asShapes(); pTable = m_pSections; iSections = pTable->Get_Record_Count(); m_pProfile = new TSG_Point[iSections]; for(i=0; iGet_Count() && Set_Progress(i, pLines->Get_Count()); i++){ pShape = pLines->Get_Shape(i); for(j=0; jGet_Part_Count(); j++){ Point = pShape->Get_Point(0,j); for(k=0; kGet_Point_Count(j)-1; k+=iStep){ Point2 = pShape->Get_Point(k,j); fDistance = sqrt(pow(Point2.x - Point.x,2) + pow(Point2.y - Point.y,2)); m_pProfile[iIndex].x = fDistanceSum + fDistance / 2.; m_pProfile[iIndex].y = pTable->Get_Record(iIndex)->asFloat(iNumPoints); fDistanceSum += fDistance; iIndex++; Point.x = Point2.x; Point.y = Point2.y; }//for }//for }//for*/ m_pHeight = new double[iSections]; for (i = 0; i < iSections; i++){ m_pHeight[i] = 1500; } iLastPoint = iSections - 1; while(iFirstPoint != iSections - 1){ fX1 = m_pProfile[iFirstPoint].x; fY1 = m_pProfile[iFirstPoint].y; fX2 = m_pProfile[iLastPoint].x; fY2 = m_pProfile[iLastPoint].y; bValid = true; for (i = iFirstPoint; i < iLastPoint; i++){ fDist = CalculatePointLineDist(fX1,fY1,fX2,fY2, m_pProfile[i].x, m_pProfile[i].y); if (fDist > fThreshold){ iLastPoint--; bValid = false; break; }//if }//for if (bValid){ for (j = iFirstPoint; j < iLastPoint + 1; j++){ m_pHeight[j] = m_pProfile[iFirstPoint].y + (m_pProfile[j].x - m_pProfile[iFirstPoint].x) / (m_pProfile[iLastPoint].x - m_pProfile[iFirstPoint].x) * (m_pProfile[iLastPoint].y - m_pProfile[iFirstPoint].y); }//for iFirstPoint = iLastPoint; iLastPoint = iSections - 1; }//if }//while m_DocEngine.AddLongitudinalProfile(m_pProfile, m_pHeight, iSections); }//method double CProfile_Cross_Sections::CalculatePointLineDist(double fX1, double fY1, double fX2, double fY2, double fPX, double fPY){ double *pA, *pB, *pC; pA = new double[2]; pA[0] = fX1; pA[1] = fY1; pB = new double[2]; pB[0] = fX2; pB[1] = fY2; pC = new double[2]; pC[0] = fPX; pC[1] = fPY; return linePointDist(pA, pB, pC); }//method void CProfile_Cross_Sections::AddCrossSections(){ int i,j; int iRoadPoints; int iNumPoints = Parameters("NUMPOINTS")->asInt(); double fInterval = (double) Parameters("INTERVAL")->asDouble(); CSG_Table *pTable; TSG_Point *pRoadSection; TSG_Point **pCrossSections; double dWidth = Parameters("WIDTH")->asDouble(); pRoadSection = new TSG_Point [2]; pRoadSection[0].x = -dWidth / 2.; pRoadSection[0].y = 0; pRoadSection[1].x = dWidth / 2.; pRoadSection[1].y = 0; pTable = m_pSections; pCrossSections = new TSG_Point *[pTable->Get_Record_Count()]; for (i = 0; i < pTable->Get_Record_Count(); i++){ pCrossSections[i] = new TSG_Point [pTable->Get_Field_Count()]; for (j = 0; j < pTable->Get_Field_Count(); j++){ pCrossSections[i][j].x = -fInterval * iNumPoints + fInterval * j; pCrossSections[i][j].y = pTable->Get_Record(i)->asFloat(j); }//for }//for iRoadPoints = 2; m_DocEngine.AddCrossSections(pCrossSections, m_pHeight, pRoadSection, pTable->Get_Record_Count(), pTable->Get_Field_Count(), iRoadPoints); m_DocEngine.AddVolumesTable(m_pProfile, pCrossSections, m_pHeight, pRoadSection, pTable->Get_Record_Count(), pTable->Get_Field_Count(), iRoadPoints); }//method /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/docs/docs_pdf/Makefile.in0000664000175000017500000005715412737447615022637 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/docs/docs_pdf ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) @HAVE_HARU_TRUE@libdocs_pdf_la_DEPENDENCIES = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am__libdocs_pdf_la_SOURCES_DIST = doc_pdf.cpp MLB_Interface.cpp \ Profile_Cross_Sections.cpp Shapes_Report.cpp \ Shapes_Summary.cpp doc_pdf.h MLB_Interface.h \ Profile_Cross_Sections.h Shapes_Report.h Shapes_Summary.h @HAVE_HARU_TRUE@am_libdocs_pdf_la_OBJECTS = doc_pdf.lo \ @HAVE_HARU_TRUE@ MLB_Interface.lo Profile_Cross_Sections.lo \ @HAVE_HARU_TRUE@ Shapes_Report.lo Shapes_Summary.lo libdocs_pdf_la_OBJECTS = $(am_libdocs_pdf_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = @HAVE_HARU_TRUE@am_libdocs_pdf_la_rpath = -rpath $(pkglibdir) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdocs_pdf_la_SOURCES) DIST_SOURCES = $(am__libdocs_pdf_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @HAVE_HARU_TRUE@DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE @HAVE_HARU_TRUE@CXX_INCS = -I$(top_srcdir)/src/saga_core @HAVE_HARU_TRUE@AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(DISABLELIBHARU) $(GOMPFLAGS) @HAVE_HARU_TRUE@AM_LDFLAGS = -fPIC -shared -avoid-version $(HARU_LIB) @HAVE_HARU_TRUE@pkglib_LTLIBRARIES = libdocs_pdf.la @HAVE_HARU_TRUE@libdocs_pdf_la_SOURCES = \ @HAVE_HARU_TRUE@doc_pdf.cpp\ @HAVE_HARU_TRUE@MLB_Interface.cpp\ @HAVE_HARU_TRUE@Profile_Cross_Sections.cpp\ @HAVE_HARU_TRUE@Shapes_Report.cpp\ @HAVE_HARU_TRUE@Shapes_Summary.cpp\ @HAVE_HARU_TRUE@doc_pdf.h\ @HAVE_HARU_TRUE@MLB_Interface.h\ @HAVE_HARU_TRUE@Profile_Cross_Sections.h\ @HAVE_HARU_TRUE@Shapes_Report.h\ @HAVE_HARU_TRUE@Shapes_Summary.h @HAVE_HARU_TRUE@libdocs_pdf_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/docs/docs_pdf/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/docs/docs_pdf/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libdocs_pdf.la: $(libdocs_pdf_la_OBJECTS) $(libdocs_pdf_la_DEPENDENCIES) $(EXTRA_libdocs_pdf_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) $(am_libdocs_pdf_la_rpath) $(libdocs_pdf_la_OBJECTS) $(libdocs_pdf_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Profile_Cross_Sections.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Shapes_Report.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Shapes_Summary.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/doc_pdf.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/docs/docs_pdf/Shapes_Report.cpp0000744000175000017500000005225512737416156024044 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Report.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Report.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad, Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_pdf.h" #include "Shapes_Report.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Report::CShapes_Report(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Shapes Report")); Set_Author (SG_T("(c) 2005 by O.Conrad, V.Olaya")); Set_Description (_TW( "" )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "SUBTITLE" , _TL("Subtitle"), _TL("") ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("PDF File"), _TL(""), _TL("PDF Files (*.pdf)|*.pdf|All Files|*.*"), _TL(""), true, false ); Parameters.Add_Choice( NULL , "PAPER_SIZE" , _TL("Paper Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("A4 Portrait"), _TL("A4 Landscape"), _TL("A3 Portrait"), _TL("A3 Landscape") ) ); Parameters.Add_Value( pNode , "COLOR_LINE" , _TL("Line Color"), _TL(""), PARAMETER_TYPE_Color, SG_COLOR_BLACK ); Parameters.Add_Value( pNode , "COLOR_FILL" , _TL("Fill Color"), _TL(""), PARAMETER_TYPE_Color, SG_COLOR_GREEN ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_LAYOUT" , _TL("Layout"), _TL("")); Parameters.Add_Choice( pNode , "LAYOUT_MODE" , _TL("Layout"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("horizontal"), _TL("vertical") ), 1 ); Parameters.Add_Value( pNode , "LAYOUT_BREAK", _TL("Map/Table Size Ratio [%]"), _TL(""), PARAMETER_TYPE_Double, 50.0, 0.0, true, 100.0, true ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_TABLE" , _TL("Attribute Table"), _TL("")); Parameters.Add_Value( pNode , "COLUMNS" , _TL("Columns"), _TL("Number of atttribute table columns."), PARAMETER_TYPE_Int, 2, 1, true ); Parameters.Add_Choice( pNode , "CELL_MODE" , _TL("Cell Sizes"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("fit to page"), _TL("fixed cell height") ) ); Parameters.Add_Value( pNode , "CELL_HEIGHT" , _TL("Cell Height"), _TL(""), PARAMETER_TYPE_Int, 8, 1, true ); } //--------------------------------------------------------- CShapes_Report::~CShapes_Report(void) { } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Report::On_Execute(void) { int Page_Orientation; TSG_PDF_Page_Size Page_Size; CSG_String FileName(Parameters("FILENAME") ->asString()); CSG_Doc_PDF PDF; //----------------------------------------------------- m_pShapes = Parameters("SHAPES") ->asShapes(); m_iSubtitle = Parameters("SUBTITLE") ->asInt(); m_Color_Line = Parameters("COLOR_LINE") ->asColor(); m_Color_Fill = Parameters("COLOR_FILL") ->asColor(); m_nColumns = Parameters("COLUMNS") ->asInt(); switch( Parameters("CELL_MODE")->asInt() ) { default: case 0: m_Cell_Height = 0; break; case 1: m_Cell_Height = Parameters("CELL_HEIGHT")->asDouble(); break; } switch( Parameters("PAPER_SIZE")->asInt() ) { default: case 0: Page_Size = PDF_PAGE_SIZE_A4; Page_Orientation = PDF_PAGE_ORIENTATION_PORTRAIT; break; // A4 Portrait case 1: Page_Size = PDF_PAGE_SIZE_A4; Page_Orientation = PDF_PAGE_ORIENTATION_LANDSCAPE; break; // A4 Landscape case 2: Page_Size = PDF_PAGE_SIZE_A3; Page_Orientation = PDF_PAGE_ORIENTATION_PORTRAIT; break; // A3 Portrait case 3: Page_Size = PDF_PAGE_SIZE_A3; Page_Orientation = PDF_PAGE_ORIENTATION_LANDSCAPE; break; // A3 Landscape } //----------------------------------------------------- if( FileName.Length() > 0 && PDF.Open(Page_Size, Page_Orientation, CSG_String::Format(SG_T("%s: %s"), _TL("Summary"), m_pShapes->Get_Name())) ) { double d = Parameters("LAYOUT_BREAK")->asDouble(); switch( Parameters("LAYOUT_MODE")->asInt() ) { default: case 0: // horizontal PDF.Layout_Add_Box( 0, 0, 100, 5, "TITLE"); PDF.Layout_Add_Box( 0, 5, d, 100, "SHAPE"); PDF.Layout_Add_Box( d, 5, 100, 100, "TABLE"); break; case 1: // vertical PDF.Layout_Add_Box( 0, 0, 100, 5, "TITLE"); PDF.Layout_Add_Box( 0, 5, 100, d, "SHAPE"); PDF.Layout_Add_Box( 0, d, 100, 100, "TABLE"); break; } m_pPDF = &PDF; m_rTitle = PDF.Layout_Get_Box("TITLE"); m_rShape = PDF.Layout_Get_Box("SHAPE"); m_rTable = PDF.Layout_Get_Box("TABLE"); return( Add_Shapes() && PDF.Save(FileName) ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CShapes_Report::Add_Shapes(void) { if( m_pShapes && m_pShapes->is_Valid() && m_pPDF && m_pPDF->Add_Page() ) { bool bAddAll; CSG_Rect r(m_rShape), rWorld(m_pShapes->Get_Extent()); CSG_String Title; CSG_Strings sLeft, sRight; //------------------------------------------------- m_pPDF->Draw_Text(m_rTitle.Get_XCenter(), m_rTitle.Get_YCenter(), _TL("Overview"), (int)(0.7 * m_rTitle.Get_YRange()), PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_CENTER|PDF_STYLE_TEXT_UNDERLINE); //------------------------------------------------- r.Deflate(10, false); rWorld.Inflate(5, true); m_pPDF->Draw_Shapes (r, m_pShapes, PDF_STYLE_POLYGON_FILLSTROKE, m_Color_Fill, m_Color_Line, 0, &rWorld); m_pPDF->Draw_Graticule(r, rWorld, 10); //------------------------------------------------- sLeft .Add(CSG_String::Format(SG_T("%s:") , _TL("Name"))); sRight .Add(CSG_String::Format(SG_T("%s") , m_pShapes->Get_Name())); sLeft .Add(CSG_String::Format(SG_T("%s:") , _TL("Count"))); sRight .Add(CSG_String::Format(SG_T("%d") , m_pShapes->Get_Count())); m_pPDF->Draw_Text(m_rTable.Get_XMin() , m_rTable.Get_YMax(), sLeft , 8, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP); m_pPDF->Draw_Text(m_rTable.Get_XCenter(), m_rTable.Get_YMax(), sRight, 8, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP); //------------------------------------------------- bAddAll = m_pShapes->Get_Selection_Count() == 0; for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, m_pShapes->Get_Count()); iShape++) { if( bAddAll || m_pShapes->Get_Record(iShape)->is_Selected() ) { Title.Printf(SG_T("%s: %s"), m_pShapes->Get_Field_Name(m_iSubtitle), m_pShapes->Get_Shape(iShape)->asString(m_iSubtitle)); Add_Shape(m_pShapes->Get_Shape(iShape), Title); } } return( true ); } return( false ); } //--------------------------------------------------------- bool CShapes_Report::Add_Shape(CSG_Shape *pShape, const SG_Char *Title) { if( m_pPDF && m_pPDF->Is_Ready_To_Draw() && pShape && pShape->is_Valid() && m_pPDF->Add_Page() ) { CSG_Rect r(m_rShape), rWorld(pShape->Get_Extent()); //------------------------------------------------- m_pPDF->Add_Outline_Item(Title); m_pPDF->Draw_Text(m_rTitle.Get_XCenter(), m_rTitle.Get_YCenter(), Title, (int)(0.7 * m_rTitle.Get_YRange()), PDF_STYLE_TEXT_ALIGN_H_CENTER|PDF_STYLE_TEXT_ALIGN_V_CENTER|PDF_STYLE_TEXT_UNDERLINE); r.Deflate(10, false); rWorld.Inflate(5, true); m_pPDF->Draw_Shape (r, pShape, PDF_STYLE_POLYGON_FILLSTROKE, m_Color_Fill, m_Color_Line, 0, &rWorld); m_pPDF->Draw_Graticule (r, rWorld, 10); //------------------------------------------------- if( pShape->Get_Table()->Get_Field_Count() > 0 ) { CSG_Table_Record *pRecord; CSG_Table Table; Table.Set_Name(_TL("Attributes")); Table.Add_Field(_TL("Attribute"), SG_DATATYPE_String); Table.Add_Field(_TL("Value") , SG_DATATYPE_String); for(int iField=0; iFieldGet_Table()->Get_Field_Count(); iField++) { pRecord = Table.Add_Record(); pRecord->Set_Value(0, pShape->Get_Table()->Get_Field_Name(iField)); pRecord->Set_Value(1, pShape->asString(iField)); } m_pPDF->Draw_Table(m_rTable, &Table, m_nColumns, m_Cell_Height, 0.0); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// /*/--------------------------------------------------------- void CWKSP_Map::SaveAs_PDF_Indexed(void) { static CSG_Parameters Parameters(NULL, LNG("[CAP] Save to PDF"), LNG(""), NULL, false); //----------------------------------------------------- if( Parameters.Get_Count() == 0 ) { Parameters.Add_FilePath( NULL , "FILENAME" , LNG("[FLD] PDF Document"), LNG(""), CSG_String::Format( wxT("%s (*.pdf)|*pdf|") wxT("%s|*.*"), LNG("PDF Files"), LNG("All Files") ), NULL, true, false ); Parameters.Add_Choice( NULL , "PAPER_SIZE" , LNG("[FLD] Paper Format"), LNG(""), CSG_String::Format(wxT("%s|%s|%s|%s|"), LNG("A4 Portrait"), LNG("A4 Landscape"), LNG("A3 Portrait"), LNG("A3 Landscape") ) ); Parameters.Add_String( NULL , "NAME" , LNG("[FLD] Title"), LNG(""), LNG("") ); Parameters.Add_Shapes( NULL , "SHAPES" , LNG("[FLD] Shapes"), LNG(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Table_Field( Parameters("SHAPES") , "FIELD" , LNG("[FLD] Attribute"), LNG("") ); // Parameters.Add_Grid( // NULL , "GRID" , LNG("[FLD] Grid"), // LNG(""), // PARAMETER_INPUT_OPTIONAL // ); Parameters.Add_FilePath( NULL , "FILEICON" , LNG("[FLD] Icon"), LNG(""), CSG_String::Format(wxT("%s|*.png;*.jpg|%s|*.png|%s|*.jpg|%s|*.*"), LNG("All Recognised Files"), LNG("PNG Files"), LNG("JPG Files"), LNG("All Files") ), NULL, false, false ); Parameters.Add_Value( NULL , "ROUNDSCALE" , LNG("[FLD] Round Scale"), LNG(""), PARAMETER_TYPE_Bool, true ); } //----------------------------------------------------- if( DLG_Parameters(&Parameters) ) { bool bResult, bRoundScale; int iField; CSG_String Name, FileName, FileName_Icon, FilePath_Maps; CSG_Rect rOverview, rMap; CSG_Shapes *pShapes; // CSG_Grid *pGrid; CSG_Doc_PDF PDF; MSG_General_Add(CSG_String::Format(wxT("%s..."), LNG("[MSG] Save to PDF")), true, true); bResult = false; Name = Parameters("NAME") ->asString(); if( Name.Length() < 1 ) Name = LNG("Maps"); FileName = Parameters("FILENAME") ->asString(); FileName_Icon = Parameters("FILEICON") ->asString(); pShapes = Parameters("SHAPES") ->asShapes(); // pGrid = Parameters("GRID") ->asGrid(); iField = Parameters("FIELD") ->asInt(); bRoundScale = Parameters("ROUNDSCALE") ->asBool(); switch( Parameters("PAPER_SIZE")->asInt() ) { default: case 0: PDF.Open(PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_PORTRAIT , Name); break; // A4 Portrait case 1: PDF.Open(PDF_PAGE_SIZE_A4, PDF_PAGE_ORIENTATION_LANDSCAPE, Name); break; // A4 Landscape case 2: PDF.Open(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_PORTRAIT , Name); break; // A3 Portrait case 3: PDF.Open(PDF_PAGE_SIZE_A3, PDF_PAGE_ORIENTATION_LANDSCAPE, Name); break; // A3 Landscape } //------------------------------------------------- if( PDF.Is_Open() ) { PDF.Layout_Set_Box_Space(5, false); PDF.Layout_Add_Box( 0.0, 0.0, 100.0, 75.0, "MAP"); PDF.Layout_Add_Box( 0.0, 75.0, 50.0, 100.0, "DIVISIONS"); PDF.Layout_Add_Box( 50.0, 75.0, 60.0, 80.0, "ICON"); PDF.Layout_Add_Box( 60.0, 75.0, 100.0, 80.0, "TITLE"); PDF.Layout_Add_Box( 50.0, 80.0, 100.0, 100.0, "DESCRIPTION"); FilePath_Maps = SG_File_Make_Path(SG_File_Get_Path(FileName), SG_File_Get_Name(FileName, false)); rOverview = pShapes ? pShapes->Get_Extent() : Get_Extent(); // rOverview = pShapes ? pShapes->Get_Extent() : (pGrid ? pGrid->Get_Extent() : Get_Extent()); //--------------------------------------------- // PDF.Draw_Text (PDF.Layout_Get_Box("TITLE").Get_XMin(), PDF.Layout_Get_Box("TITLE").Get_YCenter(), LNG("This is a Test!!!"), 24); // PDF.Draw_Rectangle (PDF.Layout_Get_Box("DIVISIONS")); // PDF.Draw_Grid (PDF.Layout_Get_Box("DIVISIONS"), Parameters("GRID")->asGrid(), CSG_Colors(), 0.0, 0.0, 0, &rOverview); // PDF.Draw_Shapes (PDF.Layout_Get_Box("DIVISIONS"), pShapes, PDF_STYLE_POLYGON_STROKE, SG_COLOR_GREEN, SG_COLOR_BLACK, 1, &rOverview); // PDF.Draw_Graticule (PDF.Layout_Get_Box("DIVISIONS"), rOverview); //--------------------------------------------- Draw_PDF(&PDF, FilePath_Maps, -1, FileName_Icon, Name, rOverview, bRoundScale, iField, pShapes); if( pShapes ) { for(int i=0; iGet_Count() && SG_UI_Process_Set_Progress(i, pShapes->Get_Count()); i++) { Draw_PDF(&PDF, FilePath_Maps, i, FileName_Icon, Name, pShapes->Get_Shape(i)->Get_Extent(), bRoundScale, iField, pShapes); } } //--------------------------------------------- PROCESS_Set_Okay(true); Set_Buisy_Cursor(true); bResult = PDF.Save(FileName); Set_Buisy_Cursor(false); } MSG_General_Add(bResult ? LNG("[MSG] okay") : LNG("[MSG] failed"), false, false, bResult ? SG_UI_MSG_STYLE_SUCCESS : SG_UI_MSG_STYLE_FAILURE); } } //--------------------------------------------------------- void CWKSP_Map::Draw_PDF(CSG_Doc_PDF *pPDF, const wxChar *FilePath_Maps, int Image_ID, const wxChar *FileName_Icon, const wxChar *Title, CSG_Rect rWorld, bool bRoundScale, int iField, CSG_Shapes *pShapes) { int FrameSize_1 = 20, FrameSize_2 = 10; double d, e, Scale, Ratio; CSG_String FileName, Description, s; CSG_Rect rBox; wxRect rBMP; wxBitmap BMP; wxMemoryDC dc; if( pPDF && rWorld.Get_XRange() > 0.0 && rWorld.Get_YRange() > 0.0 && pPDF->Add_Page() ) { rWorld.Inflate(5.0, true); //------------------------------------------------- rBox = pPDF->Layout_Get_Box("MAP"); rBox.Deflate(FrameSize_1, false); rBMP = wxRect(0, 0, (int)rBox.Get_XRange(), (int)rBox.Get_YRange()); BMP.Create(rBMP.GetWidth(), rBMP.GetHeight()); dc.SelectObject(BMP); dc.SetBackground(*wxWHITE_BRUSH); dc.Clear(); if( bRoundScale ) { Scale = rWorld.Get_XRange() / (pPDF->Get_Page_To_Meter() * (double)rBMP.GetWidth()); // if( Scale > 1000 ) // { Ratio = ((ceil(Scale / 1000.)) / (Scale / 1000.) - 1); rWorld.Inflate(Ratio * 100, true); // } } Scale = rWorld.Get_XRange() / (pPDF->Get_Page_To_Meter() * rBMP.GetWidth()); Draw_Map(dc, rWorld, 1.0, rBMP, false); dc.SelectObject(wxNullBitmap); SG_Dir_Create(FilePath_Maps); FileName = SG_File_Make_Path(FilePath_Maps, CSG_String::Format(wxT("image_%03d"), Image_ID + 1), wxT("png")); BMP.SaveFile(FileName.c_str(), wxBITMAP_TYPE_PNG); pPDF->Draw_Image (rBox, FileName); pPDF->Draw_Graticule(rBox, rWorld, FrameSize_1); //------------------------------------------------- rBox = pPDF->Layout_Get_Box("ICON"); if( FileName_Icon ) { pPDF->Draw_Image(rBox, FileName_Icon); } else { pPDF->Draw_Rectangle(rBox); } //------------------------------------------------- rBox = pPDF->Layout_Get_Box("DIVISIONS"); pPDF->Draw_Rectangle(rBox); if( pShapes ) { CSG_Rect rShapes(pShapes->Get_Extent()); rShapes.Inflate(5.0, true); rBox.Deflate(FrameSize_2, false); pPDF->Draw_Graticule(rBox, rShapes, FrameSize_2); pPDF->Draw_Shapes(rBox, pShapes, PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_GREEN, SG_COLOR_BLACK, 0, &rShapes); if( Image_ID >= 0 && Image_ID < pShapes->Get_Count() ) { pPDF->Draw_Shape(rBox, pShapes->Get_Shape(Image_ID), PDF_STYLE_POLYGON_FILLSTROKE, SG_COLOR_YELLOW, SG_COLOR_RED, 1, &rShapes); } } //------------------------------------------------- rBox = pPDF->Layout_Get_Box("TITLE"); pPDF->Draw_Text(rBox.Get_XMin(), rBox.Get_YCenter(), Title, 20, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_CENTER|PDF_STYLE_TEXT_UNDERLINE); //------------------------------------------------- rBox = pPDF->Layout_Get_Box("DESCRIPTION"); Description.Append(CSG_String::Format(wxT("%d. %s\n"), Image_ID + 2, LNG("Map"))); if( pShapes && Image_ID >= 0 && Image_ID < pShapes->Get_Count() ) { switch( pShapes->Get_Type() ) { default: break; case SHAPE_TYPE_Line: d = ((CSG_Shape_Line *)pShapes->Get_Shape(Image_ID))->Get_Length(); e = d > 1000.0 ? 1000.0 : 1.0; s = d > 1000.0 ? wxT("km") : wxT("m"); Description.Append(CSG_String::Format(wxT("%s: %f%s\n"), LNG("Length") , d / e, s.c_str())); break; case SHAPE_TYPE_Polygon: d = ((CSG_Shape_Polygon *)pShapes->Get_Shape(Image_ID))->Get_Area(); e = d > 1000000.0 ? 1000000.0 : (d > 10000.0 ? 10000.0 : 1.0); s = d > 1000000.0 ? wxT("km\xc2\xb2") : (d > 10000.0 ? wxT("ha") : wxT("m\xc2\xb2")); Description.Append(CSG_String::Format(wxT("%s: %f%s\n"), LNG("Area") , d / e, s.c_str())); d = ((CSG_Shape_Polygon *)pShapes->Get_Shape(Image_ID))->Get_Perimeter(); e = d > 1000.0 ? 1000.0 : 1.0; s = d > 1000.0 ? wxT("km") : wxT("m"); Description.Append(CSG_String::Format(wxT("%s: %f%s\n"), LNG("Perimeter") , d / e, s.c_str())); Description.Append(CSG_String::Format(wxT("%s: %d\n") , LNG("Parts") , ((CSG_Shape_Polygon *)pShapes->Get_Shape(Image_ID))->Get_Part_Count())); break; } if( iField >= 0 && iField < pShapes->Get_Field_Count() ) { Description.Append(CSG_String::Format(wxT("%s: %s\n"), pShapes->Get_Field_Name(iField), pShapes->Get_Shape(Image_ID)->asString(iField))); } } Description.Append(CSG_String::Format(wxT("%s 1:%s"), LNG("Scale"), SG_Get_String(Scale, 2).c_str())); pPDF->Draw_Text(rBox.Get_XMin(), rBox.Get_YMax(), Description, 12, PDF_STYLE_TEXT_ALIGN_H_LEFT|PDF_STYLE_TEXT_ALIGN_V_TOP); } }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/docs/docs_pdf/Makefile.am0000744000175000017500000000133612737416156022610 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif if HAVE_HARU DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(DISABLELIBHARU) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(HARU_LIB) pkglib_LTLIBRARIES = libdocs_pdf.la libdocs_pdf_la_SOURCES =\ doc_pdf.cpp\ MLB_Interface.cpp\ Profile_Cross_Sections.cpp\ Shapes_Report.cpp\ Shapes_Summary.cpp\ doc_pdf.h\ MLB_Interface.h\ Profile_Cross_Sections.h\ Shapes_Report.h\ Shapes_Summary.h libdocs_pdf_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la endif saga-2.3.1/src/modules/docs/docs_pdf/Shapes_Report.h0000744000175000017500000001075112737416156023504 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Report.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_Tools // // // //-------------------------------------------------------// // // // Shapes_Report.h // // // // Copyright (C) 2005 by // // Olaf Conrad, Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Shapes_Report_H #define HEADER_INCLUDED__Shapes_Report_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Report : public CSG_Module { public: CShapes_Report(void); virtual ~CShapes_Report(void); protected: virtual bool On_Execute (void); private: int m_iSubtitle, m_nColumns, m_Color_Line, m_Color_Fill; double m_Cell_Height; CSG_Rect m_rTitle, m_rShape, m_rTable; CSG_Shapes *m_pShapes; class CSG_Doc_PDF *m_pPDF; bool Add_Shapes (void); bool Add_Shape (CSG_Shape *pShape, const SG_Char *Title); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Shapes_Report_H saga-2.3.1/src/modules/docs/docs_pdf/Shapes_Summary.h0000744000175000017500000000552412737416156023670 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Shapes_Summary.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Summarize.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_pdf.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Summary_PDF : public CSG_Doc_PDF { public: CShapes_Summary_PDF(); virtual ~CShapes_Summary_PDF(); void AddClassSummaryPage(CSG_Shapes*, CSG_Table*, int, CSG_String); void AddSummaryStatisticsPage(CSG_Table* pTable); private: void AddBarGraphStatistics(CSG_Points &, CSG_String*, const CSG_Rect &); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Summary : public CSG_Module { public: CShapes_Summary(void); virtual ~CShapes_Summary(void); protected: virtual bool On_Execute(void); private: int m_iField; CSG_Shapes *m_pShapes; CSG_Table *m_pTable; bool *m_bIncludeParam; std::vector m_ClassesID; int *m_pClasses; int *m_pCount; CSG_Parameters *m_pExtraParameters; CShapes_Summary_PDF m_DocEngine; void Summarize(); void CreatePDFDocs(); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/docs/docs_pdf/MLB_Interface.h0000744000175000017500000000756012737416156023324 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_pdf // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__docs_pdf__mlb_interface_H #define HEADER_INCLUDED__docs_pdf__mlb_interface_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef docs_pdf_EXPORTS #define docs_pdf_EXPORT _SAGA_DLL_EXPORT #else #define docs_pdf_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__docs_pdf__mlb_interface_H saga-2.3.1/src/modules/docs/docs_pdf/MLB_Interface.cpp0000744000175000017500000001076712737416156023662 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_pdf // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("PDF") ); case MLB_INFO_Category: return( _TL("Reports") ); case MLB_INFO_Author: return( SG_T("SAGA User Group (c) 2010") ); case MLB_INFO_Description: return( _TW( "Reports in Portable Document Format (PDF). PDF export is based on " "libharu." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Reports") ); } } //--------------------------------------------------------- #include "Shapes_Report.h" #include "Shapes_Summary.h" #include "Profile_Cross_Sections.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CShapes_Report ); case 1: return( new CShapes_Summary ); case 2: return( new CProfile_Cross_Sections ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/docs/docs_html/0000775000175000017500000000000012737740003020734 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/docs/docs_html/svg_interactive_map.cpp0000744000175000017500000036371212737416156025515 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: svg_interactive_map.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // SVG_Interactive_map.cpp // // // // Copyright (C) 2005 by Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "svg_interactive_map.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define MAP_WINDOW_WIDTH 550. #define MAP_WINDOW_HEIGHT 700. /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSVG_Interactive_Map::CSVG_Interactive_Map(void) { Set_Name (_TL("SVG Interactive Map")); Set_Author (SG_T("V.Olaya")); Set_Description (_TW( "" )); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("[FLD] SVG File"), _TL(""), CSG_String::Format(SG_T("%s|*.svg|%s|*.*"), _TL("SVG - Scalable Vector Graphics Files (*.svg)"), _TL("All Files") ), NULL, true, false ); Parameters.Add_Shapes_List( NULL , "LIST" , _TL("Shapes Layers"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("[FLD] Index Layer"), _TL(""), PARAMETER_INPUT_OPTIONAL ); } //--------------------------------------------------------- CSVG_Interactive_Map::~CSVG_Interactive_Map(void) {} //--------------------------------------------------------- bool CSVG_Interactive_Map::On_Execute(void) { CSG_String FileName; CSG_Shapes *pIndexLayer; CSVG_Interactive_Map SVG; Process_Set_Text(CSG_String::Format(SG_T("%s..."), _TL("[MSG] Save as Interactive SVG"))); pIndexLayer = Parameters("SHAPES") ->asShapes(); FileName = Parameters("FILENAME") ->asString(); return( SVG.Create_From_Map(Parameters("LIST")->asShapesList(), pIndexLayer, FileName) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSVG_Interactive_Map::Create_From_Map(CSG_Parameter_Shapes_List *pList, CSG_Shapes *pIndexLayer, const SG_Char *Filename) { int i; if( pList->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- m_Directory = SG_File_Get_Path(Filename); CSG_Rect r(pList->asShapes(0)->Get_Extent()); for(i=1; iGet_Count(); i++) { r.Union(pList->asShapes(i)->Get_Extent()); } _Add_Opening(r); //----------------------------------------------------- m_sSVGCode.Append(SG_T("\n")); for(i=pList->Get_Count()-1; i>=0; i--) { _Add_Shapes (pList->asShapes(i)); } m_sSVGCode.Append(SG_T("\n\n")); //----------------------------------------------------- _Add_CheckBoxes(pList); _Add_ReferenceMap(pIndexLayer, r); m_sSVGCode.Append(_Get_Code_Closing_1()); if( !Save(Filename) ) { return( false ); } //----------------------------------------------------- _Write_Code(SG_File_Make_Path(m_Directory, SG_T("checkbox") , SG_T("js")), _Get_Code_CheckBox()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("mapApp") , SG_T("js")), _Get_Code_MapApp ()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("timer") , SG_T("js")), _Get_Code_Timer ()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("slider") , SG_T("js")), _Get_Code_Slider ()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("helper_functions") , SG_T("js")), _Get_Code_Helper ()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("button") , SG_T("js")), _Get_Code_Buttons ()); _Write_Code(SG_File_Make_Path(m_Directory, SG_T("navigation") , SG_T("js")), CSG_String::Format(SG_T("%s%s"), _Get_Code_Navigation_1(), _Get_Code_Navigation_2())); return( true ); } //--------------------------------------------------------- void CSVG_Interactive_Map::_Write_Code(const CSG_String &FileName, const CSG_String &Code) { CSG_File Stream; if( Stream.Open(FileName, SG_FILE_W, false) ) { Stream.Write(Code); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_Opening(CSG_Rect r) { CSG_String sViewBox; double Width, Height; double OffsetX, OffsetY; m_sSVGCode.Append(_Get_Opening_Code_1()); m_sSVGCode.Append(SG_Get_String(r.Get_XRange(),2)); m_sSVGCode.Append(SG_T("),")); m_sSVGCode.Append(SG_Get_String(r.Get_XRange() / 400.,2)); m_sSVGCode.Append(_Get_Opening_Code_2()); if (r.Get_XRange() / r.Get_YRange() > MAP_WINDOW_WIDTH / MAP_WINDOW_HEIGHT) { Width = r.Get_XRange(); Height = r.Get_XRange() * MAP_WINDOW_HEIGHT / MAP_WINDOW_WIDTH; } else { Height = r.Get_YRange(); Width = r.Get_YRange() / MAP_WINDOW_HEIGHT * MAP_WINDOW_WIDTH; } OffsetX = (Width - r.Get_XRange()) / 2.; OffsetY = (Height - r.Get_YRange()) / 2.; sViewBox.Append(SG_Get_String(r.Get_XMin() - OffsetX,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(-r.Get_YMax() - OffsetY,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(Width,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(Height,2)); _AddAttribute(SG_T("viewBox"), sViewBox); m_sSVGCode.Append(SG_T(">\n")); m_dWidth = Width; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_ReferenceMap(CSG_Shapes *pIndexLayer, CSG_Rect r) { int i; CSG_String sViewBox; double Line_Width, Point_Width; double Width, Height; double OffsetX, OffsetY; CSG_Shape *pShape; if (r.Get_XRange() / r.Get_YRange() > MAP_WINDOW_WIDTH / MAP_WINDOW_HEIGHT) { Width = r.Get_XRange(); Height = r.Get_XRange() * MAP_WINDOW_HEIGHT / MAP_WINDOW_WIDTH; } else { Height = r.Get_YRange(); Width = r.Get_YRange() / MAP_WINDOW_HEIGHT * MAP_WINDOW_WIDTH; } OffsetX = (Width - r.Get_XRange()) / 2.; OffsetY = (Height - r.Get_YRange()) / 2.; sViewBox.Append(SG_Get_String(r.Get_XMin() - OffsetX,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(- r.Get_YMax() - OffsetY,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(Width,2)); sViewBox.Append(SG_T(" ")); sViewBox.Append(SG_Get_String(Height,2)); _AddAttribute(SG_T("viewBox"), sViewBox); m_sSVGCode.Append(_Get_Code_3()); if (pIndexLayer) { m_sSVGCode.Append(SG_T("\n")); for (i = 0; i < pIndexLayer->Get_Count(); i++) { pShape = pIndexLayer->Get_Shape(i); Line_Width = Point_Width = m_dWidth / MAP_WINDOW_WIDTH; Point_Width *= 5; _Add_Shape(pShape, 0, 0, Line_Width, Point_Width); } m_sSVGCode.Append(SG_T("\n")); } m_sSVGCode.Append(_Get_Code_4()); _AddAttribute(SG_T("x"), r.Get_XMin() - OffsetX); _AddAttribute(SG_T("y"), - r.Get_YMax() - OffsetY); _AddAttribute(SG_T("width"), Width); _AddAttribute(SG_T("height"), Height); m_sSVGCode.Append(_Get_Code_5()); } //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_Grid(CSG_Grid *pLayer) { /* CSG_String Filename; wxBitmap BMP; if( pLayer->Get_Image_Grid(BMP) ) { Filename = SG_File_Make_Path(m_Directory.c_str(), pLayer->Get_Name(), SG_T("jpg")); BMP.SaveFile(Filename, wxBITMAP_TYPE_JPEG); m_sSVGCode.Append(SG_T("Get_Name()); _AddAttribute(SG_T("x") , ((CSG_Grid *)pLayer->Get_Object())->Get_XMin()); _AddAttribute(SG_T("y") ,-((CSG_Grid *)pLayer->Get_Object())->Get_YMax()); _AddAttribute(SG_T("width") , ((CSG_Grid *)pLayer->Get_Object())->Get_XRange()); _AddAttribute(SG_T("height") , ((CSG_Grid *)pLayer->Get_Object())->Get_YRange()); _AddAttribute(SG_T("xlink:href") , SG_File_Get_Name(Filename, true)); m_sSVGCode.Append(SG_T("/>")); } /**/ } //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_Shapes(CSG_Shapes *pLayer) { int i; int Line_Color, Fill_Color; double Line_Width, Point_Width; CSG_Shape *pShape; CSG_String sLabel; m_sSVGCode.Append(SG_T("Get_Name()); m_sSVGCode.Append(SG_T("\" >\n")); // int iColorField = pLayer->Get_Color_Field(); m_sSVGCode.Append(SG_T("\n")); for (i = 0; i < pLayer->Get_Count(); i++) { pShape = pLayer->Get_Shape(i); // Line_Color = Fill_Color = pLayer->Get_Classifier()->Get_Class_Color_byValue(pShape->asDouble(iColorField)); Line_Color = SG_COLOR_BLACK; Fill_Color = SG_COLOR_GREEN; Line_Width = Point_Width = m_dWidth / MAP_WINDOW_WIDTH; Point_Width *= 5; _Add_Shape(pShape, Fill_Color, Line_Color, Line_Width, Point_Width); } // if (pLayer->Get_Label_Field() >= 0) { /* m_sSVGCode.Append(SG_T("")); for (i = 0; i < pLayer->Get_Count(); i++) { double dSize; pShape = pLayer->Get_Shape(i); Line_Width = Point_Width = m_dWidth / MAP_WINDOW_WIDTH; sLabel = pShape->asString(pLayer->Get_Label_Field()); switch( pLayer->Get_Parameters()->Get_Parameter(SG_T("LABEL_ATTRIB_SIZE_TYPE"))->asInt() ) { case 0: default: dSize = Line_Width * pLayer->Get_Parameters()->Get_Parameter(SG_T("LABEL_ATTRIB_FONT"))->asFont()->GetPointSize(); _Add_Label(sLabel, pShape, dSize, SG_T("%")); break; case 1: dSize = pLayer->Get_Parameters()->Get_Parameter(SG_T("LABEL_ATTRIB_SIZE"))->asDouble(); _Add_Label(sLabel, pShape, dSize, SG_T("")); break; } } m_sSVGCode.Append(SG_T("\n")); /**/ } m_sSVGCode.Append(SG_T("\n\n")); } //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_Label(const SG_Char* Label, CSG_Shape *pShape, double dSize, const SG_Char* Unit) { int iPoint, iPart; TSG_Point Point; switch( pShape->Get_Type() ) { case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: for(iPoint=0; iPoint < pShape->Get_Point_Count(0); iPoint++) { Point = pShape->Get_Point(iPoint); Draw_Text(100 * Point.x, -100 * Point.y, Label, 0, SG_T("Verdana"), 100 * dSize); } break; case SHAPE_TYPE_Line: ///************/// break; case SHAPE_TYPE_Polygon: for (iPart = 0; iPart < pShape->Get_Part_Count(); iPart++) { if(! ((CSG_Shape_Polygon *)pShape)->is_Lake(iPart) ) { Point = ((CSG_Shape_Polygon *)pShape)->Get_Centroid(iPart); Draw_Text(100 * Point.x, -100 * Point.y, Label, 0, SG_T("Verdana"), 100 * dSize); } } break; } } //--------------------------------------------------------- bool CSVG_Interactive_Map::_Add_Shape(CSG_Shape *pShape, int Fill_Color, int Line_Color, double Line_Width, double Point_Width) { if( pShape && pShape->is_Valid() ) { int iPart, iPoint; TSG_Point Point; CSG_Points Points; for(iPart=0; iPartGet_Part_Count(); iPart++) { Points.Clear(); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Point = pShape->Get_Point(iPoint, iPart); Points.Add(Point.x, Point.y); } switch( pShape->Get_Type() ) { case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: for(iPoint=0; iPointis_Lake(iPart) ) { Draw_Polygon(Points, -1, 0, 0.01); } else { Draw_Polygon(Points, Fill_Color, 0, 0.01); } break; } } return( true ); } return( false ); } //--------------------------------------------------------- void CSVG_Interactive_Map::_Add_CheckBoxes(CSG_Parameter_Shapes_List *pList) { int i; CSG_String s; int x,y; int iRow = 1; m_sSVGCode.Append(_Get_Code_1()); // 2* open m_sSVGCode.Append(_TL("Layers")); m_sSVGCode.Append(SG_T("\n")); for (i = 0; i < pList->Get_Count(); i++) { y = iRow * 30; if (i % 2) { x = 200; iRow++; } else { x = 0; } m_sSVGCode.Append(SG_T("\n")); m_sSVGCode.Append(SG_T("asShapes(i)->Get_Name()); _AddAttribute(SG_T("id"), s); _AddAttribute(SG_T("xlink:href"), SG_T("#checkBoxRect")); s = SG_T("checkBoxScript(evt,'"); s.Append(pList->asShapes(i)->Get_Name()); s.Append(SG_T("');")); _AddAttribute(SG_T("onclick"), s); m_sSVGCode.Append(SG_T("/>\n")); m_sSVGCode.Append(SG_T("asShapes(i)->Get_Name()); _AddAttribute(SG_T("id"), s); _AddAttribute(SG_T("xlink:href"), SG_T("#checkBoxCross")); _AddAttribute(SG_T("visibility"), SG_T("visible")); m_sSVGCode.Append(SG_T("/>\n")); m_sSVGCode.Append(SG_T("\n")); } m_sSVGCode.Append(SG_T("\n")); iRow = 1; for (i = 0; i < pList->Get_Count(); i++) { y = iRow * 30 + 6; if (i % 2) { x = 212; iRow++; } else { x = 12; } m_sSVGCode.Append(SG_T("")); m_sSVGCode.Append(pList->asShapes(i)->Get_Name()); m_sSVGCode.Append(SG_T("\n")); } m_sSVGCode.Append(SG_T("\n")); m_sSVGCode.Append(_Get_Code_2()); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Opening_Code_1(void) { return( "\n" "\n" "\n" "\n" "\n" "]>\n" "\n" "\n" " \n" "\n" " " ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_4(void) { return( " \n" " \n " " \n" " \n" ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_Closing_1(void) { return( " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_CheckBox(void) { return( "function checkBoxScript(evt,myLayer) { //checkBox for toggling layers an contextMenue\n" " var myLayerObj = document.getElementById(myLayer);\n" " var myCheckCrossObj = document.getElementById(\"checkCross\"+myLayer);\n" " var myCheckCrossVisibility = myCheckCrossObj.getAttributeNS(null,\"visibility\"));\n" " if (evt.type == \"click\" && evt.detail == 1) {\n" " if (myCheckCrossVisibility == \"visible\")) {\n" " myLayerObj.setAttributeNS(null,\"visibility\"),\"hidden\"));\n" " myCheckCrossObj.setAttributeNS(null,\"visibility\"),\"hidden\"));\n" " //you can do if/else or switch statements to set different actions on activating a checkbox here\n" " //myLayer holds the currentLayer name\n" " }\n" " else {\n" " myLayerObj.setAttributeNS(null,\"visibility\"),\"visible\"));\n" " myCheckCrossObj.setAttributeNS(null,\"visibility\"),\"visible\"));\n" " }\n" " }\n" "}\n" "\n" ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_MapApp(void) { return( "//holds data on window size\n" "function mapApp() {\n" " if (!document.documentElement.getScreenCTM) {\n" " this.resetFactors();\n" " //add resize event to document element\n" " document.documentElement.addEventListener(\"SVGResize\"),this,false);\n" " }\n" "}\n" "\n" "mapApp.prototype.handleEvent = function(evt) {\n" " if (evt.type == \"SVGResize\")) {\n" " this.resetFactors();\n" " }\n" "}\n" "\n" "mapApp.prototype.resetFactors = function() {\n" " if (!document.documentElement.getScreenCTM) {\n" " //case for viewers that don't support .getScreenCTM, such as ASV3\n" " //calculate ratio and offset values of app window\n" " var viewBoxArray = document.documentElement.getAttributeNS(null,\"viewBox\")).split(\" \"));\n" " var myRatio = viewBoxArray[2]/viewBoxArray[3];\n" " if ((window.innerWidth/window.innerHeight) > myRatio) { //case window is more wide than myRatio\n" " this.scaleFactor = viewBoxArray[3] / window.innerHeight;\n" " }\n" " else { //case window is more tall than myRatio\n" " this.scaleFactor = viewBoxArray[2] / window.innerWidth;\n" " }\n" " this.offsetX = (window.innerWidth - viewBoxArray[2] * 1 / this.scaleFactor) / 2;\n" " this.offsetY = (window.innerHeight - viewBoxArray[3] * 1 / this.scaleFactor) / 2;\n" " }\n" "}\n" "\n" "mapApp.prototype.calcCoord = function(evt,ctmNode) {\n" " var svgPoint = document.documentElement.createSVGPoint();\n" " svgPoint.x = evt.clientX;\n" " svgPoint.y = evt.clientY;\n" " if (!document.documentElement.getScreenCTM) {\n" " //case ASV3 a. Corel\n" " svgPoint.x = (svgPoint.x - this.offsetX) * this.scaleFactor;\n" " svgPoint.y = (svgPoint.y - this.offsetY) * this.scaleFactor;\n" " //undo the effect of transformations\n" " if (ctmNode) {\n" " var ctm = getTransformToRootElement(ctmNode).inverse();\n" " }\n" " else {\n" " var ctm = getTransformToRootElement(evt.target).inverse();\n" " }\n" " svgPoint = svgPoint.matrixTransform(ctm);\n" "\n" " }\n" " else {\n" " if (ctmNode) {\n" " var matrix = ctmNode.getScreenCTM();\n" " }\n" " else {\n" " var matrix = evt.target.getScreenCTM();\n" " }\n" " svgPoint = svgPoint.matrixTransform(matrix.inverse());\n" " }\n" " return svgPoint;\n" "}\n" "\n" ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_Timer(void) { return( "// source/credits: \"Algorithm\": http://www.codingforums.com/showthread.php?s=&threadid=10531\n" "// The constructor should be called with\n" "// the parent object (optional, defaults to window).\n" "\n" "function Timer(){\n" " this.obj = (arguments.length)?arguments[0]:window;\n" " return this;\n" "}\n" "\n" "// The set functions should be called with:\n" "// - The name of the object method (as a string) (required)\n" "// - The millisecond delay (required)\n" "// - Any number of extra arguments, which will all be\n" "// passed to the method when it is evaluated.\n" "\n" "Timer.prototype.setInterval = function(func, msec){\n" " var i = Timer.getNew();\n" " var t = Timer.buildCall(this.obj, i, arguments);\n" " Timer.set[i].timer = window.setInterval(t,msec);\n" " return i;\n" "}\n" "Timer.prototype.setTimeout = function(func, msec){\n" " var i = Timer.getNew();\n" " Timer.buildCall(this.obj, i, arguments);\n" " Timer.set[i].timer = window.setTimeout(\"Timer.callOnce(\"+i+\"));\"),msec);\n" " return i;\n" "}\n" "\n" "// The clear functions should be called with\n" "// the return value from the equivalent set function.\n" "\n" "Timer.prototype.clearInterval = function(i){\n" " if(!Timer.set[i]) return;\n" " window.clearInterval(Timer.set[i].timer);\n" " Timer.set[i] = null;\n" "}\n" "Timer.prototype.clearTimeout = function(i){\n" " if(!Timer.set[i]) return;\n" " window.clearTimeout(Timer.set[i].timer);\n" " Timer.set[i] = null;\n" "}\n" "\n" "// Private data\n" "\n" "Timer.set = new Array();\n" "Timer.buildCall = function(obj, i, args){\n" " var t = \"\");\n" " Timer.set[i] = new Array();\n" " if(obj != window){\n" " Timer.set[i].obj = obj;\n" " t = \"Timer.set[\"+i+\"].obj.\");\n" " }\n" " t += args[0]+\"(\");\n" " if(args.length > 2){\n" " Timer.set[i][0] = args[2];\n" " t += \"Timer.set[\"+i+\"][0]\");\n" " for(var j=1; (j+2) \n" "Version 1.1, 2004-11-18\n" "neumann@karto.baug.ethz.ch\n" "http://www.carto.net/\n" "http://www.carto.net/neumann/\n" "\n" "Credits: numerous people on svgdevelopers@yahoogroups.com\n" "\n" "This ECMA script library is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Lesser General Public\n" "License as published by the Free Software Foundation; either\n" "version 2.1 of the License, or (at your option) any later version.\n" "\n" "This library is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" "Lesser General Public License for more details.\n" "\n" "You should have received a copy of the GNU Lesser General Public\n" "License along with this library (http://www.carto.net/papers/svg/resources/lesser_gpl.txt); if not, write to the Free Software\n" "Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA\n" "\n" "----\n" "\n" "original document site: http://www.carto.net/papers/svg/resources/helper_functions.js\n" "Please contact the author in case you want to use code or ideas commercially.\n" "If you use this code, please include this copyright header, the included full\n" "LGPL 2.1 text and read the terms provided in the LGPL 2.1 license\n" "(http://www.gnu.org/copyleft/lesser.txt)\n" "\n" "-------------------------------\n" "\n" "Please report bugs and send improvements to neumann@karto.baug.ethz.ch\n" "If you use these scripts, please link to the original (http://www.carto.net/papers/svg/navigationTools/)\n" "somewhere in the source-code-comment or the \"about\" of your project and give credits, thanks!\n" "\n" "*/\n" "\n" "//global variables necessary to create elements in these namespaces, do not delete them!!!!\n" "var svgNS = \"http://www.w3.org/2000/svg\");\n" "var xlinkNS = \"http://www.w3.org/1999/xlink\");\n" "var cartoNS = \"http://www.carto.net/attrib\");\n" "var attribNS = \"http://www.carto.net/attrib\");\n" "var batikNS = \"http://xml.apache.org/batik/ext\");\n" "\n" "/* ----------------------- helper functions to calculate stuff ---------------- */\n" "/* ---------------------------------------------------------------------------- */\n" "function toPolarDir(xdiff,ydiff) { // Subroutine for calculating polar Coordinates\n" " direction = (Math.atan2(ydiff,xdiff));\n" " //result is angle in radian\n" " return(direction);\n" "}\n" "\n" "function toPolarDist(xdiff,ydiff) { // Subroutine for calculating polar Coordinates\n" " distance = Math.sqrt(xdiff * xdiff + ydiff * ydiff);\n" " return(distance);\n" "}\n" "\n" "function toRectX(direction,distance) { // Subroutine for calculating cartesic coordinates\n" " x = distance * Math.cos(direction);\n" " y = distance * Math.sin(direction);\n" " return(x);\n" "}\n" "\n" "function toRectY(direction,distance) { // Subroutine for calculating cartesic coordinates\n" " x = distance * Math.cos(direction);\n" " y = distance * Math.sin(direction);\n" " return(y);\n" "}\n" "\n" "//Converts degrees to radians.\n" "function DegToRad(deg) {\n" " return (deg / 180.0 * Math.PI);\n" "}\n" "\n" "//Converts radians to degrees.\n" "function RadToDeg(rad) {\n" " return (rad / Math.PI * 180.0);\n" "}\n" "\n" "//converts decimal degrees to degree/minutes/seconds\n" "function dd2dms(dd) {\n" " var minutes = (dd - Math.floor(dd)) * 60;\n" " var seconds = (minutes - Math.floor(minutes)) * 60;\n" " var minutes = Math.floor(minutes);\n" " var degrees = Math.floor(dd);\n" " return {deg:degrees,min:minutes,sec:seconds};\n" "}\n" "\n" "//converts degree/minutes/seconds to decimal degrees\n" "function dms2dd(deg,min,sec) {\n" " return deg + (min / 60) + (sec / 3600);\n" "}\n" "\n" "//log functions that do not exist in Math object\n" "function log(x,b) {\n" " if(b==null) b=Math.E;\n" " return Math.log(x)/Math.log(b);\n" "}\n" "\n" "//gets 4 z-values (4 corners), a position, delta x and delty and a cellsize as input and returns interpolated z-value\n" "function intBilinear(za,zb,zc,zd,xpos,ypos,ax,ay,cellsize) { //bilinear interpolation function\n" " e = (xpos - ax) / cellsize;\n" " f = (ypos - ay) / cellsize;\n" "\n" " //calculation of weights\n" " wa = (1 - e) * (1 - f);\n" " wb = e * (1 - f);\n" " wc = e * f;\n" " wd = f * (1 - e);\n" "\n" " height_interpol = wa * zc + wb * zd + wc * za + wd * zb;\n" "\n" " return (height_interpol); \n" "}\n" "\n" "//test if point is left of or right of, result is 1 (leftof) or 0 (rightof)\n" "function leftOfTest(pointx,pointy,linex1,liney1,linex2,liney2) {\n" " result = (liney1 - pointy) * (linex2 - linex1) - (linex1 - pointx) * (liney2 - liney1);\n" " if (result < 0) {\n" " leftof = 1; //case left of\n" " }\n" " else {\n" " leftof = 0; //case left of \n" " }\n" " return(leftof);\n" "}\n" "\n" "//input is point coordinate, and 2 line coordinates\n" "function distFromLine(xpoint,ypoint,linex1,liney1,linex2,liney2) {\n" " dx = linex2 - linex1;\n" " dy = liney2 - liney1;\n" " distance = (dy * (xpoint - linex1) - dx * (ypoint - liney1)) / Math.sqrt(Math.pow(dx,2) + Math.pow(dy,2));\n" " return(distance);\n" "}\n" "\n" "//converts radian value to degrees\n" "function radian2deg(radian) {\n" " deg = radian / Math.PI * 180;\n" " return(deg);\n" "}\n" "\n" "//input is two vectors (a1,a2 is vector a, b1,b2 is vector b), output is angle in radian\n" "//Formula: Acos from Scalaproduct of the two vectors divided by ( norm (deutsch Betrag) vector 1 by norm vector 2\n" "//see http://www.mathe-online.at/mathint/vect2/i.html#Winkel\n" "function angleBetwTwoLines(a1,a2,b1,b2) {\n" " angle = Math.acos((a1 * b1 + a2 * b2) / (Math.sqrt(Math.pow(a1,2) + Math.pow(a2,2)) * Math.sqrt(Math.pow(b1,2) + Math.pow(b2,2))));\n" " return(angle);\n" "}\n" "\n" "//input is two vectors (a1,a2 is vector a, b1,b2 is vector b), output is new vector c2 returned as array\n" "//Formula: Vektor a divided by Norm Vector a (Betrag) plus Vektor b divided by Norm Vector b (Betrag)\n" "//see http://www.mathe-online.at/mathint/vect1/i.html#Winkelsymmetrale\n" "function calcBisectorVector(a1,a2,b1,b2) {\n" " betraga = Math.sqrt(Math.pow(a1,2) + Math.pow(a2,2));\n" " betragb = Math.sqrt(Math.pow(b1,2) + Math.pow(b2,2));\n" " c = new Array();\n" " c[0] = a1 / betraga + b1 / betragb;\n" " c[1] = a2 / betraga + b2 / betragb;\n" " return(c);\n" "}\n" "\n" "//input is two vectors (a1,a2 is vector a, b1,b2 is vector b), output is angle in radian\n" "//Formula: Vektor a divided by Norm Vector a (Betrag) plus Vektor b divided by Norm Vector b (Betrag)\n" "//see http://www.mathe-online.at/mathint/vect1/i.html#Winkelsymmetrale\n" "function calcBisectorAngle(a1,a2,b1,b2) {\n" " betraga = Math.sqrt(Math.pow(a1,2) + Math.pow(a2,2));\n" " betragb = Math.sqrt(Math.pow(b1,2) + Math.pow(b2,2));\n" " c1 = a1 / betraga + b1 / betragb;\n" " c2 = a2 / betraga + b2 / betragb;\n" " angle = toPolarDir(c1,c2);\n" " return(angle);\n" "}\n" "\n" "function intersect2lines(line1x1,line1y1,line1x2,line1y2,line2x1,line2y1,line2x2,line2y2) {\n" " //formula see http://astronomy.swin.edu.au/~pbourke/geometry/lineline2d/\n" " var result = new Array();\n" " var denominator = (line2y2 - line2y1)*(line1x2 - line1x1) - (line2x2 - line2x1)*(line1y2 - line1y1);\n" " if (denominator == 0) {\n" " alert(\"lines are parallel\"));\n" " }\n" " else {\n" " ua = ((line2x2 - line2x1)*(line1y1 - line2y1) - (line2y2 - line2y1)*(line1x1 - line2x1)) / denominator;\n" " ub = ((line1x2 - line1x1)*(line1y1 - line2y1) - (line1y2 - line1y1)*(line1x1 - line2x1)) / denominator;\n" " }\n" " result[\"x\"] = line1x1 + ua * (line1x2 - line1x1);\n" " result[\"y\"] = line1y1 + ua * (line1y2 - line1y1);\n" " return(result);\n" "}\n" "\n" "/* ----------------------- helper function to sort arrays ---------------- */\n" "/* ----------------------------------------------------------------------- */\n" "//my own sort function, uses only first part of string (population value)\n" "function mySort(a,b) {\n" " var myResulta = a.split(\"+\"));\n" " var myResultb = b.split(\"+\"));\n" " if (parseFloat(myResulta[0]) < parseFloat(myResultb[0])) {\n" " return 1;\n" " }\n" " else {\n" " return -1;\n" " }\n" "}\n" "\n" "/* ----------------------- helper function format number strings -------------- */\n" "/* ---------------------------------------------------------------------------- */\n" "//formatting number strings\n" "//this function add's \"'\" to a number every third digit\n" "function formatNumberString(myString) {\n" " //check if of type string, if number, convert it to string\n" " if (typeof(myString) == \"number\")) {\n" " myTempString = myString.toString();\n" " }\n" " else {\n" " myTempString = myString;\n" " }\n" " var myNewString=\"\");\n" " //if it contains a comma, it will be split\n" " var splitResults = myTempString.split(\".\"));\n" " var myCounter= splitResults[0].length;\n" " if (myCounter > 3) {\n" " while(myCounter > 0) {\n" " if (myCounter > 3) {\n" " myNewString = \"),\" + splitResults[0].substr(myCounter - 3,3) + myNewString;\n" " }\n" " else {\n" " myNewString = splitResults[0].substr(0,myCounter) + myNewString;\n" " }\n" " myCounter -= 3;\n" " }\n" " }\n" " else {\n" " myNewString = splitResults[0];\n" " }\n" " //concatenate if it contains a comma\n" " if (splitResults[1]) {\n" " myNewString = myNewString + \".\" + splitResults[1];\n" " }\n" " return myNewString;\n" "}\n" "\n" "//function for status Bar\n" "function statusChange(statusText) {\n" " document.getElementById(\"statusText\")).firstChild.nodeValue = \"Statusbar: \" + statusText;\n" "}\n" "\n" "//scale an object\n" "function scaleObject(evt,factor) {\n" "//reference to the currently selected object\n" " var element = evt.currentTarget;\n" " var myX = element.getAttributeNS(null,\"x\"));\n" " var myY = element.getAttributeNS(null,\"y\"));\n" " var newtransform = \"scale(\" + factor + \")) translate(\" + (myX * 1 / factor - myX) + \" \" + (myY * 1 / factor - myY) +\"))\");\n" " element.setAttributeNS(null,'transform', newtransform);\n" "}\n" "\n" "//this code is copied from Kevin Lindsey\n" "//http://www.kevlindev.com/tutorials/basics/transformations/toUserSpace/index.htm\n" "function getTransformToRootElement(node) {\n" " try {\n" " //this part is for fully conformant players\n" " var CTM = node.getTransformToElement(document.documentElement);\n" " }\n" " catch (ex) {\n" " //this part is for ASV3 or other non-conformant players\n" " // Initialize our CTM the node's Current Transformation Matrix\n" " var CTM = node.getCTM();\n" " // Work our way through the ancestor nodes stopping at the SVG Document\n" " while ( ( node = node.parentNode ) != document ) {\n" " // Multiply the new CTM to the one with what we have accumulated so far\n" " CTM = node.getCTM().multiply(CTM);\n" " }\n" " }\n" " return CTM;\n" "}\n" "\n" "//calculate HSV 2 RGB: HSV (h 0 to 360, sat and val are between 0 and 1), RGB between 0 and 255\n" "function hsv2rgb(hue,sat,val) {\n" " //alert(\"Hue:\"+hue);\n" " var rgbArr = new Array();\n" " if ( sat == 0) {\n" " rgbArr[\"red\"] = Math.round(val * 255);\n" " rgbArr[\"green\"] = Math.round(val * 255);\n" " rgbArr[\"blue\"] = Math.round(val * 255);\n" " }\n" " else {\n" " var h = hue / 60;\n" " var i = Math.floor(h);\n" " var f = h - i;\n" " if (i % 2 == 0) {\n" " f = 1 - f;\n" " }\n" " var m = val * (1 - sat); \n" " var n = val * (1 - sat * f);\n" " switch(i) {\n" " case 0:\n" " rgbArr[\"red\"] = val;\n" " rgbArr[\"green\"] = n;\n" " rgbArr[\"blue\"] = m;\n" " break;\n" " case 1:\n" " rgbArr[\"red\"] = n;\n" " rgbArr[\"green\"] = val;\n" " rgbArr[\"blue\"] = m;\n" " break;\n" " case 2:\n" " rgbArr[\"red\"] = m;\n" " rgbArr[\"green\"] = val;\n" " rgbArr[\"blue\"] = n;\n" " break;\n" " case 3:\n" " rgbArr[\"red\"] = m;\n" " rgbArr[\"green\"] = n;\n" " rgbArr[\"blue\"] = val;\n" " break;\n" " case 4:\n" " rgbArr[\"red\"] = n;\n" " rgbArr[\"green\"] = m;\n" " rgbArr[\"blue\"] = val;\n" " break;\n" " case 5:\n" " rgbArr[\"red\"] = val;\n" " rgbArr[\"green\"] = m;\n" " rgbArr[\"blue\"] = n;\n" " break;\n" " case 6:\n" " rgbArr[\"red\"] = val;\n" " rgbArr[\"green\"] = n;\n" " rgbArr[\"blue\"] = m;\n" " break;\n" " }\n" " rgbArr[\"red\"] = Math.round(rgbArr[\"red\"] * 255);\n" " rgbArr[\"green\"] = Math.round(rgbArr[\"green\"] * 255);\n" " rgbArr[\"blue\"] = Math.round(rgbArr[\"blue\"] * 255);\n" " }\n" " return rgbArr;\n" "}\n" "\n" "//calculate rgb to hsv values\n" "function rgb2hsv (red,green,blue) {\n" " //input between 0 and 255 --> normalize to 0 to 1\n" " //result = \n" " var hsvArr = new Array();\n" " red = red / 255;\n" " green = green / 255;\n" " blue = blue / 255;\n" " myMax = Math.max(red, Math.max(green,blue));\n" " myMin = Math.min(red, Math.min(green,blue));\n" " v = myMax;\n" " if (myMax > 0) {\n" " s = (myMax - myMin) / myMax;\n" " }\n" " else {\n" " s = 0;\n" " }\n" " if (s > 0) {\n" " myDiff = myMax - myMin;\n" " rc = (myMax - red) / myDiff;\n" " gc = (myMax - green) / myDiff;\n" " bc = (myMax - blue) / myDiff;\n" " if (red == myMax) {\n" " h = (bc - gc) / 6;\n" " }\n" " if (green == myMax) {\n" " h = (2 + rc - bc) / 6;\n" " }\n" " if (blue == myMax) {\n" " h = (4 + gc - rc) / 6;\n" " }\n" " }\n" " else {\n" " h = 0;\n" " }\n" " if (h < 0) {\n" " h += 1;\n" " }\n" " hsvArr[\"hue\"] = Math.round(h * 360);\n" " hsvArr[\"sat\"] = s;\n" " hsvArr[\"val\"] = v;\n" " return hsvArr;\n" "}\n" "\n" "//populate an array that can be addressed by both a key or an index nr\n" "function assArrayPopulate(arrayKeys,arrayValues) {\n" " var returnArray = new Array();\n" " if (arrayKeys.length != arrayValues.length) {\n" " alert(\"error: arrays do not have same length!\"));\n" " }\n" " else {\n" " for (i=0;i 0) {\n" " this.init(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset);\n" " }\n" "}\n" "\n" "button.prototype.init = function(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset) {\n" " this.groupId = groupId; //the group id where all new content is appended to\n" " this.functionToCall = functionToCall; //function to be called if button was pressed\n" " this.buttonType = buttonType; //button type: currently either \"rect\" or \"ellipse\"\n" " this.buttonText = buttonText; //default value to be filled in when textbox is created\n" " this.buttonSymbolId = buttonSymbolId; //id to a symbol to be used as a button graphics\n" " this.x = x; //left of button rectangle\n" " this.y = y; //top of button rectangle\n" " this.width = width; //button rectangle width\n" " this.height = height; //button rectangle height\n" " this.fontSize = fontSize; //font size in user units/pixels\n" " this.fontFamily = fontFamily; //font family for text element, can be an empty string for image buttons\n" " this.textFill = textFill; //the fill color of the text for text buttons, can be an empty string for image buttons\n" " this.buttonFill = buttonFill; //the fill color of the button rectangle or ellipse\n" " this.shadeLightFill = shadeLightFill; //light fill color simulating 3d effect\n" " this.shadeDarkFill = shadeDarkFill; //dark fill color simulating 3d effect\n" " this.shadowOffset = shadowOffset; //shadow offset in viewBox units\n" " this.buttonGroup = document.getElementById(this.groupId); //reference to the button group node\n" " this.upperLeftLine = null; //later a reference to the upper left line simulating 3d effect\n" " this.buttonRect = null; //later a reference to the button area (rect)\n" " this.buttonTextElement = null; //later a reference to the button text\n" " this.buttonSymbolInstance = null; //later a reference to the button symbol\n" " this.deActivateRect = null; //later a reference to a rectangle that can be used to deactivate the button\n" " this.activated = true; //a property indicating if button is activated or not\n" " this.lowerRightLine = null; //later a reference to the lower right line simulating 3d effect\n" " this.createButton(); //method to initialize button\n" " this.timer = new Timer(this); //a Timer instance for calling the functionToCall\n" " this.timerMs = 200; //a constant of this object that is used in conjunction with the timer - functionToCall is called after 200 ms\n" "}\n" "\n" "//create button\n" "button.prototype.createButton = function() {\n" " //create upper left button line or ellipse\n" " if (this.buttonType == \"rect\")) {\n" " this.upperLeftShadow = document.createElementNS(svgNS,\"rect\"));\n" " this.upperLeftShadow.setAttributeNS(null,\"x\"),this.x - this.shadowOffset);\n" " this.upperLeftShadow.setAttributeNS(null,\"y\"),this.y - this.shadowOffset);\n" " this.upperLeftShadow.setAttributeNS(null,\"width\"),this.width);\n" " this.upperLeftShadow.setAttributeNS(null,\"height\"),this.height);\n" " this.upperLeftShadow.setAttributeNS(null,\"points\"),this.x+\"),\"+(this.y+this.height)+\" \"+this.x+\"),\"+this.y+\" \"+(this.x+this.width)+\"),\"+this.y);\n" " }\n" " else if (this.buttonType == \"ellipse\")) {\n" " this.upperLeftShadow = document.createElementNS(svgNS,\"ellipse\"));\n" " this.upperLeftShadow.setAttributeNS(null,\"cx\"),this.x + this.width * 0.5 - this.shadowOffset);\n" " this.upperLeftShadow.setAttributeNS(null,\"cy\"),this.y + this.height * 0.5 - this.shadowOffset);\n" " this.upperLeftShadow.setAttributeNS(null,\"rx\"),this.width * 0.5);\n" " this.upperLeftShadow.setAttributeNS(null,\"ry\"),this.height * 0.5);\n" " }\n" " else {\n" " alert(\"buttonType '\"+this.buttonType+\"' not supported. You need to specify 'rect' or 'ellipse'\"));\n" " }\n" " this.upperLeftShadow.setAttributeNS(null,\"fill\"),this.shadeLightFill);\n" " this.buttonGroup.appendChild(this.upperLeftShadow);\n" "\n" " //create lower right button line or ellipse\n" " if (this.buttonType == \"rect\")) {\n" " this.lowerRightShadow = document.createElementNS(svgNS,\"rect\"));\n" " this.lowerRightShadow.setAttributeNS(null,\"x\"),this.x + this.shadowOffset);\n" " this.lowerRightShadow.setAttributeNS(null,\"y\"),this.y + this.shadowOffset);\n" " this.lowerRightShadow.setAttributeNS(null,\"width\"),this.width);\n" " this.lowerRightShadow.setAttributeNS(null,\"height\"),this.height);\n" " this.lowerRightShadow.setAttributeNS(null,\"points\"),this.x+\"),\"+(this.y+this.height)+\" \"+this.x+\"),\"+this.y+\" \"+(this.x+this.width)+\"),\"+this.y);\n" " }\n" " else if (this.buttonType == \"ellipse\")) {\n" " this.lowerRightShadow = document.createElementNS(svgNS,\"ellipse\"));\n" " this.lowerRightShadow.setAttributeNS(null,\"cx\"),this.x + this.width * 0.5 + this.shadowOffset);\n" " this.lowerRightShadow.setAttributeNS(null,\"cy\"),this.y + this.height * 0.5 + this.shadowOffset);\n" " this.lowerRightShadow.setAttributeNS(null,\"rx\"),this.width * 0.5);\n" " this.lowerRightShadow.setAttributeNS(null,\"ry\"),this.height * 0.5);\n" " }\n" " this.lowerRightShadow.setAttributeNS(null,\"fill\"),this.shadeDarkFill);\n" " this.buttonGroup.appendChild(this.lowerRightShadow);\n" "\n" " //create buttonRect\n" " if (this.buttonType == \"rect\")) {\n" " this.buttonRect = document.createElementNS(svgNS,\"rect\"));\n" " this.buttonRect.setAttributeNS(null,\"x\"),this.x);\n" " this.buttonRect.setAttributeNS(null,\"y\"),this.y);\n" " this.buttonRect.setAttributeNS(null,\"width\"),this.width);\n" " this.buttonRect.setAttributeNS(null,\"height\"),this.height);\n" " }\n" " else if (this.buttonType == \"ellipse\")) {\n" " this.buttonRect = document.createElementNS(svgNS,\"ellipse\"));\n" " this.buttonRect.setAttributeNS(null,\"cx\"),this.x + this.width * 0.5);\n" " this.buttonRect.setAttributeNS(null,\"cy\"),this.y + this.height * 0.5);\n" " this.buttonRect.setAttributeNS(null,\"rx\"),this.width * 0.5);\n" " this.buttonRect.setAttributeNS(null,\"ry\"),this.height * 0.5);\n" " }\n" " this.buttonRect.setAttributeNS(null,\"fill\"),this.buttonFill);\n" " this.buttonRect.setAttributeNS(null,\"cursor\"),\"pointer\"));\n" " this.buttonRect.addEventListener(\"mousedown\"),this,false);\n" " this.buttonRect.addEventListener(\"mouseup\"),this,false);\n" " this.buttonRect.addEventListener(\"click\"),this,false);\n" " this.buttonGroup.appendChild(this.buttonRect);\n" " \n" " if (this.buttonText != undefined) {\n" " //create text element and add clipping path attribute\n" " this.buttonTextElement = document.createElementNS(svgNS,\"text\"));\n" " this.buttonTextElement.setAttributeNS(null,\"x\"),(this.x + this.width / 2));\n" " this.buttonTextElement.setAttributeNS(null,\"y\"),(this.y + this.height - ((this.height - this.fontSize) / 1.75)));\n" " this.buttonTextElement.setAttributeNS(null,\"fill\"),this.textFill);\n" " this.buttonTextElement.setAttributeNS(null,\"font-family\"),this.fontFamily);\n" " this.buttonTextElement.setAttributeNS(null,\"font-size\"),this.fontSize+\"px\"));\n" " this.buttonTextElement.setAttributeNS(null,\"pointer-events\"),\"none\"));\n" " this.buttonTextElement.setAttributeNS(null,\"text-anchor\"),\"middle\"));\n" " this.buttonTextElement.setAttributeNS(\"http://www.w3.org/XML/1998/namespace\"),\"space\"),\"preserve\"));\n" " var textboxTextContent = document.createTextNode(this.buttonText);\n" " this.buttonTextElement.appendChild(textboxTextContent);\n" " this.buttonGroup.appendChild(this.buttonTextElement);\n" " }\n" " \n" " if (this.buttonSymbolId != undefined) {\n" " this.buttonSymbolInstance = document.createElementNS(svgNS,\"use\"));\n" " this.buttonSymbolInstance.setAttributeNS(null,\"x\"),(this.x + this.width / 2));\n" " this.buttonSymbolInstance.setAttributeNS(null,\"y\"),(this.y + this.height / 2));\n" " this.buttonSymbolInstance.setAttributeNS(xlinkNS,\"href\"),\"#\"+this.buttonSymbolId);\n" " this.buttonSymbolInstance.setAttributeNS(null,\"pointer-events\"),\"none\"));\n" " this.buttonGroup.appendChild(this.buttonSymbolInstance);\n" " }\n" " \n" " //create rectangle to deactivate the button\n" " if (this.buttonType == \"rect\")) {\n" " this.deActivateRect = document.createElementNS(svgNS,\"rect\"));\n" " this.deActivateRect.setAttributeNS(null,\"x\"),this.x - this.shadowOffset);\n" " this.deActivateRect.setAttributeNS(null,\"y\"),this.y - this.shadowOffset);\n" " this.deActivateRect.setAttributeNS(null,\"width\"),this.width + this.shadowOffset * 2);\n" " this.deActivateRect.setAttributeNS(null,\"height\"),this.height + this.shadowOffset * 2);\n" " }\n" " else if (this.buttonType == \"ellipse\")) {\n" " this.deActivateRect = document.createElementNS(svgNS,\"ellipse\"));\n" " this.deActivateRect.setAttributeNS(null,\"cx\"),this.x + this.width * 0.5);\n" " this.deActivateRect.setAttributeNS(null,\"cy\"),this.y + this.height * 0.5);\n" " this.deActivateRect.setAttributeNS(null,\"rx\"),this.width * 0.5 + this.shadowOffset);\n" " this.deActivateRect.setAttributeNS(null,\"ry\"),this.height * 0.5 + this.shadowOffset);\n" " }\n" " \n" " this.deActivateRect.setAttributeNS(null,\"fill\"),\"white\"));\n" " this.deActivateRect.setAttributeNS(null,\"fill-opacity\"),\"0.5\"));\n" " this.deActivateRect.setAttributeNS(null,\"stroke\"),\"none\"));\n" " this.deActivateRect.setAttributeNS(null,\"display\"),\"none\"));\n" " this.deActivateRect.setAttributeNS(null,\"cursor\"),\"default\"));\n" " this.buttonGroup.appendChild(this.deActivateRect);\n" "}\n" "\n" "//remove all textbox elements\n" "button.prototype.removeButton = function() {\n" " this.buttonGroup.removeChild(this.upperLeftShadow);\n" " this.buttonGroup.removeChild(this.lowerRightShadow);\n" " this.buttonGroup.removeChild(this.buttonRect);\n" " if (this.buttonTextElement) {\n" " this.buttonGroup.removeChild(this.buttonTextElement); \n" " }\n" " if (this.buttonSymbolInstance) {\n" " this.buttonGroup.removeChild(this.buttonSymbolInstance); \n" " }\n" " this.buttonGroup.removeChild(this.deActivateRect);\n" "}\n" "\n" "//click on and write in textbox\n" "button.prototype.handleEvent = function(evt) {\n" " if (evt.type == \"mousedown\")) {\n" " this.togglePressed(\"pressed\"));\n" " document.documentElement.addEventListener(\"mouseup\"),this,false); \n" " }\n" " if (evt.type == \"mouseup\")) {\n" " this.togglePressed(\"released\"));\n" " document.documentElement.removeEventListener(\"mouseup\"),this,false); \n" " }\n" " if (evt.type == \"click\")) {\n" " //for some strange reasons I could not forward the evt object here ;-(, the code below using a literal is a workaround\n" " //attention: only some of the evt properties are forwarded here, you can add more, if you need them\n" " var timerEvt = {x:evt.clientX,y:evt.clientY,type:evt.type,detail:evt.detail,timeStamp:evt.timeStamp}\n" " this.timer.setTimeout(\"fireFunction\"),this.timerMs,timerEvt)\n" " }\n" "}\n" "\n" "button.prototype.togglePressed = function(type) {\n" " if (type == \"pressed\")) {\n" " this.upperLeftShadow.setAttributeNS(null,\"fill\"),this.shadeDarkFill); \n" " this.lowerRightShadow.setAttributeNS(null,\"fill\"),this.shadeLightFill);\n" " }\n" " if (type == \"released\")) {\n" " this.upperLeftShadow.setAttributeNS(null,\"fill\"),this.shadeLightFill); \n" " this.lowerRightShadow.setAttributeNS(null,\"fill\"),this.shadeDarkFill); \n" " }\n" "}\n" "\n" "button.prototype.fireFunction = function(evt) {\n" " if (typeof(this.functionToCall) == \"function\")) {\n" " if (this.buttonTextElement) {\n" " this.functionToCall(this.groupId,evt,this.buttonText);\n" " }\n" " if (this.buttonSymbolInstance) {\n" " this.functionToCall(this.groupId,evt);\n" " }\n" " }\n" " if (typeof(this.functionToCall) == \"object\")) {\n" " if (this.buttonTextElement) {\n" " this.functionToCall.buttonPressed(this.groupId,evt,this.buttonText);\n" " }\n" " if (this.buttonSymbolInstance) {\n" " this.functionToCall.buttonPressed(this.groupId,evt);\n" " }\n" " }\n" " if (typeof(this.functionToCall) == undefined) {\n" " return; \n" " }\n" "}\n" "\n" "button.prototype.getTextValue = function() {\n" " return this.buttonText;\n" "} \n" "\n" "button.prototype.setTextValue = function(value) {\n" " this.buttonText = value;\n" " this.buttonTextElement.firstChild.nodeValue=this.buttonText;\n" "}\n" "\n" "button.prototype.activate = function(value) {\n" " this.deActivateRect.setAttributeNS(null,\"display\"),\"none\"));\n" " this.activated = true;\n" "}\n" "\n" "button.prototype.deactivate = function(value) {\n" " this.deActivateRect.setAttributeNS(null,\"display\"),\"inherit\"));\n" " this.activated = false;\n" "}\n" "\n" "//switchbutton\n" "//initialize inheritance\n" "switchbutton.prototype = new button();\n" "switchbutton.prototype.constructor = switchbutton;\n" "switchbutton.superclass = button.prototype;\n" "\n" "function switchbutton(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset) {\n" " if (arguments.length > 0) {\n" " this.init(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset);\n" " }\n" "}\n" "\n" "switchbutton.prototype.init = function(groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset) {\n" " switchbutton.superclass.init.call(this,groupId,functionToCall,buttonType,buttonText,buttonSymbolId,x,y,width,height,fontSize,fontFamily,textFill,buttonFill,shadeLightFill,shadeDarkFill,shadowOffset);\n" " this.on = false;\n" "}\n" "\n" "//overwriting handleEventcode\n" "switchbutton.prototype.handleEvent = function(evt) {\n" " //for some strange reasons I could not forward the evt object here ;-(, the code below using a literal is a workaround\n" " //attention: only some of the evt properties are forwarded here, you can add more, if you need them\n" " var timerEvt = {x:evt.clientX,y:evt.clientY,type:evt.type,detail:evt.detail,timeStamp:evt.timeStamp}\n" " if (evt.type == \"click\")) {\n" " if (this.on) {\n" " this.on = false;\n" " this.togglePressed(\"released\"));\n" " this.timer.setTimeout(\"fireFunction\"),this.timerMs,timerEvt);\n" " }\n" " else {\n" " this.on = true;\n" " this.togglePressed(\"pressed\")); \n" " this.timer.setTimeout(\"fireFunction\"),this.timerMs,timerEvt);\n" " }\n" " }\n" "}\n" "\n" "switchbutton.prototype.getSwitchValue = function() {\n" " return this.on;\n" "}\n" "\n" "switchbutton.prototype.setSwitchValue = function(onOrOff,firefunction) {\n" " this.on = onOrOff;\n" " //artificial timer event - don't use the values!\n" " var timerEvt = {x:0,y:0,type:\"click\"),detail:1,timeStamp:0}\n" " if (this.on) {\n" " this.togglePressed(\"pressed\"));\n" " if (firefunction) {\n" " this.timer.setTimeout(\"fireFunction\"),this.timerMs,timerEvt);\n" " }\n" " }\n" " else {\n" " this.togglePressed(\"released\")); \n" " if (firefunction) {\n" " this.timer.setTimeout(\"fireFunction\"),this.timerMs,timerEvt)\n" " }\n" " }\n" "}\n" "\n" "//overwriting fireFunction code\n" "switchbutton.prototype.fireFunction = function(evt) {\n" " if (typeof(this.functionToCall) == \"function\")) {\n" " if (this.buttonTextElement) {\n" " this.functionToCall(this.groupId,evt,this.on,this.buttonText);\n" " }\n" " if (this.buttonSymbolInstance) {\n" " this.functionToCall(this.groupId,evt,this.on);\n" " }\n" " }\n" " if (typeof(this.functionToCall) == \"object\")) {\n" " if (this.buttonTextElement) {\n" " this.functionToCall.buttonPressed(this.groupId,evt,this.on,this.buttonText);\n" " }\n" " if (this.buttonSymbolInstance) {\n" " this.functionToCall.buttonPressed(this.groupId,evt,this.on);\n" " }\n" " }\n" " if (typeof(this.functionToCall) == undefined) {\n" " return; \n" " }\n" "}\n" "\n" ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_Navigation_1(void) { return( "/*\n" "Scripts for SVG only webmapping application navigation tools\n" "Copyright (C) <2005> \n" "Version 1.1, 2005-10-05\n" "neumann@karto.baug.ethz.ch\n" "http://www.carto.net/\n" "http://www.carto.net/neumann/\n" "\n" "Credits: numerous people on svgdevelopers@yahoogroups.com\n" "\n" "This ECMA script library is free software; you can redistribute it and/or\n" "modify it under the terms of the GNU Lesser General Public\n" "License as published by the Free Software Foundation; either\n" "version 2.1 of the License, or (at your option) any later version.\n" "\n" "This library is distributed in the hope that it will be useful,\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n" "Lesser General Public License for more details.\n" "\n" "You should have received a copy of the GNU Lesser General Public\n" "License along with this library (http://www.carto.net/papers/svg/navigationTools/lesser_gpl.txt); if not, write to the Free Software\n" "Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA\n" "\n" "----\n" "\n" "current version: 1.1\n" "\n" "version history:\n" "1.0 initial version\n" "1.01 (2005-02-15) added cleanUp() method to map and dragObj objects, some fixes in the documentation\n" "1.02 (2005-02-20) fixed problems with double clicks, the second click of a double click is now ignored, using the evt.detail property\n" "1.03 (2005-02-22) introduced timestamp and nrLayerToLoad array for dynamic loading (getUrl)\n" "1.04 (2005-09-15) introduced a few changes with coordinate calculation to support MozillaSVG, introduced epsg and unitsFactor property based on a suggestion by Bruce Rindahl\n" "1.1 (2005-10-05) introduced button object (see button.js file), introduced zoom and pan \"modes\" for repeated actions in the same mode, introduced history of map extents with the ability to go back and forth in the list of previous map extents, some internal changes in the code (e.g. less global variables), added experimental support for the batik SVG 1.2 \"static\" attribute to improve performance while panning the map, added cursors to give better status feedback\n" "\n" "original document site: http://www.carto.net/papers/svg/navigationTools/\n" "Please contact the author in case you want to use code or ideas commercially.\n" "If you use this code, please include this copyright header, the included full\n" "LGPL 2.1 text and read the terms provided in the LGPL 2.1 license\n" "(http://www.gnu.org/copyleft/lesser.txt)\n" "\n" "-------------------------------\n" "\n" "Please report bugs and send improvements to neumann@karto.baug.ethz.ch\n" "If you use these scripts, please link to the original (http://www.carto.net/papers/svg/navigationTools/)\n" "somewhere in the source-code-comment or the \"about\" of your project and give credits, thanks!\n" "\n" "*/\n" "\n" "//constructor: holds data on map and initializes various references\n" "function map(mapName,maxWidth,minWidth,zoomFact,nrDecimals,epsg,units,unitsFactor,showCoords,coordXId,coordYId,dynamicLayers,digiLayers,activeDigiLayer) {\n" " this.mapName = mapName; //id of svg element containing the map geometry\n" " this.mapSVG = document.getElementById(this.mapName); //reference to nested SVG element holding the map-graphics\n" " this.mainMapGroup = document.getElementById(this.mapName+\"Group\")); //group within mainmap - to be transformed when panning manually\n" " this.dynamicLayers = dynamicLayers; //an associative array holding ids of values that are loaded from the web server dynamically (.getUrl())\n" " this.nrLayerToLoad = 0; //statusVariable to indicate how many layers are still to load\n" " this.maxWidth = maxWidth; //max map width\n" " this.minWidth = minWidth; //min map width, after zooming in\n" " this.zoomFact = zoomFact; //ratio to zoom in or out in relation to previous viewBox\n" " this.digiLayers = digiLayers; //references to digiLayers (for digitizing tools)\n" " this.activeDigiLayer = activeDigiLayer; //active Digi Layer, key is final group id where geometry should be copied to after digitizing\n" " this.pixXOffset = parseFloat(this.mapSVG.getAttributeNS(null,\"x\"))); //offset from left margin of outer viewBox\n" " this.pixYOffset = parseFloat(this.mapSVG.getAttributeNS(null,\"y\"))); //offset from top margin of outer viewBox\n" " var viewBoxArray = this.mapSVG.getAttributeNS(null,\"viewBox\")).split(\" \"));\n" " this.curxOrig = parseFloat(viewBoxArray[0]); //holds the current xOrig\n" " this.curyOrig = parseFloat(viewBoxArray[1]); //holds the current yOrig\n" " this.curWidth = parseFloat(viewBoxArray[2]); //holds the current map width\n" " this.curHeight = parseFloat(viewBoxArray[3]); //holds the current map height\n" " this.pixWidth = parseFloat(this.mapSVG.getAttributeNS(null,\"width\"))); //holds width of the map in pixel coordinates\n" " this.pixHeight = parseFloat(this.mapSVG.getAttributeNS(null,\"height\"))); //holds height of the map in pixel coordinates\n" " this.pixSize = this.curWidth / this.pixWidth; //size of a screen pixel in map units\n" " this.zoomVal = this.maxWidth / this.curWidth * 100; //zoomVal in relation to initial zoom\n" " this.nrDecimals = nrDecimals; //nr of decimal places to be displayed for show coordinates or accuracy when working with digitizing\n" " this.epsg = epsg; //epsg projection code - can be used for building URL strings for loading data from a WMS or spatial database, if you don't need it just input any number\n" " this.navStatus = \"info\"); //to indicate status in navigation, default is \"info\"), no navigation mode active\n" " this.units = units; //holds a string with map units, e.g. \"m\"), alternatively String.fromCharCode(176) for degrees\n" " this.unitsFactor = unitsFactor; //a factor for unit conversion. Can be used f.e. to output feet coordinates when data is meter, If you don't need a conversion, just use a factor of 1\n" " this.showCoords = showCoords;\n" " //initialize array of timestamp/layertoLoad values\n" " this.nrLayerToLoad = new Array();\n" " this.timestamp = null; //holds the timestamp after a zoom or pan occurred\n" " //initialize coordinate display if showCoords == true\n" " if (this.showCoords == true) {\n" " //add event listener for coordinate display\n" " this.mapSVG.addEventListener(\"mousemove\"),this,false);\n" " if (typeof(coordXId) == \"string\")) {\n" " this.coordXText = document.getElementById(coordXId).firstChild;\n" " }\n" " else {\n" " alert(\"Error: coordXId needs to be an id of type string\"));\n" " }\n" " if (typeof(coordYId) == \"string\")) {\n" " this.coordYText = document.getElementById(coordYId).firstChild;\n" " }\n" " else {\n" " alert(\"Error: coordYId needs to be an id of type string\"));\n" " }\n" " }\n" " //a new array containing map extents\n" " this.mapExtents = new Array();\n" " this.mapExtents.push({xmin:this.curxOrig,ymin:((this.curyOrig + this.curHeight) * -1),xmax:(this.curxOrig + this.curWidth),ymax:(this.curyOrig * -1)});\n" " this.curMapExtentIndex = 0;\n" " //create background-element to receive events for showing coordinates\n" " //this rect is also used for manual zooming and panning\n" " this.backgroundRect = document.createElementNS(svgNS,\"rect\"));\n" " this.backgroundRect.setAttributeNS(null,\"x\"),this.curxOrig);\n" " this.backgroundRect.setAttributeNS(null,\"y\"),this.curyOrig);\n" " this.backgroundRect.setAttributeNS(null,\"width\"),this.curWidth);\n" " this.backgroundRect.setAttributeNS(null,\"height\"),this.curHeight);\n" " this.backgroundRect.setAttributeNS(null,\"fill\"),\"none\"));\n" " this.backgroundRect.setAttributeNS(null,\"stroke\"),\"none\"));\n" " this.backgroundRect.setAttributeNS(null,\"pointer-events\"),\"fill\"));\n" " this.backgroundRect.setAttributeNS(null,\"id\"),\"mapBackgroundRect\"));\n" " this.backgroundRect.addEventListener(\"mousedown\"),this,false);\n" " this.backgroundRect.addEventListener(\"mousemove\"),this,false);\n" " this.backgroundRect.addEventListener(\"mouseup\"),this,false);\n" " this.backgroundRect.addEventListener(\"mouseout\"),this,false);\n" " this.backgroundRect.addEventListener(\"click\"),this,false);\n" " this.mainMapGroup.insertBefore(this.backgroundRect,this.mainMapGroup.firstChild);\n" " //determine if viewer is capable of getScreenCTM\n" " if (document.documentElement.getScreenCTM) {\n" " this.getScreenCTM = true;\n" " }\n" " else {\n" " this.getScreenCTM = false; \n" " }\n" "}\n" "\n" "//resets viewBox of main map after zooming and panning\n" "map.prototype.newViewBox = function(refRectId,history) {\n" " var myRefRect = document.getElementById(refRectId);\n" " this.curxOrig = parseFloat(myRefRect.getAttributeNS(null,\"x\")));\n" " this.curyOrig = parseFloat(myRefRect.getAttributeNS(null,\"y\")));\n" " this.curWidth = parseFloat(myRefRect.getAttributeNS(null,\"width\")));\n" " this.curHeight = parseFloat(myRefRect.getAttributeNS(null,\"height\")));\n" " var myViewBoxString = this.curxOrig + \" \" + this.curyOrig + \" \" + this.curWidth + \" \" + this.curHeight;\n" " this.pixSize = this.curWidth / this.pixWidth;\n" " this.zoomVal = this.maxWidth / this.curWidth * 100;\n" " this.mapSVG.setAttributeNS(null,\"viewBox\"),myViewBoxString);\n" " myMapApp.zoomSlider.setValue(this.curWidth);\n" " loadProjectSpecific();\n" " if (history) {\n" " this.mapExtents.push({xmin:this.curxOrig,ymin:((this.curyOrig + this.curHeight) * -1),xmax:(this.curxOrig + this.curWidth),ymax:(this.curyOrig * -1)});\n" " this.curMapExtentIndex = (this.mapExtents.length - 1);\n" " }\n" " this.checkButtons();\n" "}\n" "\n" "map.prototype.backwardExtent = function() {\n" " if (this.curMapExtentIndex != 0) {\n" " this.curMapExtentIndex--;\n" " this.setNewViewBox(this.mapExtents[this.curMapExtentIndex].xmin,this.mapExtents[this.curMapExtentIndex].ymin,this.mapExtents[this.curMapExtentIndex].xmax,this.mapExtents[this.curMapExtentIndex].ymax,false);\n" " }\n" "}\n" "\n" "map.prototype.forwardExtent = function() {\n" " if (this.mapExtents.length != (this.curMapExtentIndex + 1)) {\n" " this.curMapExtentIndex++;\n" " this.setNewViewBox(this.mapExtents[this.curMapExtentIndex].xmin,this.mapExtents[this.curMapExtentIndex].ymin,this.mapExtents[this.curMapExtentIndex].xmax,this.mapExtents[this.curMapExtentIndex].ymax,false);\n" " }\n" "}\n" "\n" "map.prototype.checkButtons = function() {\n" " //check extent history\n" " if (this.curMapExtentIndex == 0) {\n" " if (myMapApp.buttons[\"backwardExtent\"].activated) {\n" " myMapApp.buttons[\"backwardExtent\"].deactivate();\n" " }\n" " }\n" " else {\n" " if (!myMapApp.buttons[\"backwardExtent\"].activated) {\n" " myMapApp.buttons[\"backwardExtent\"].activate();\n" " } \n" " }\n" " if (this.mapExtents.length == (this.curMapExtentIndex + 1)) {\n" " if (myMapApp.buttons[\"forwardExtent\"].activated) {\n" " myMapApp.buttons[\"forwardExtent\"].deactivate();\n" " }\n" " }\n" " else {\n" " if (!myMapApp.buttons[\"forwardExtent\"].activated) {\n" " myMapApp.buttons[\"forwardExtent\"].activate();\n" " } \n" " }\n" " \n" " //maximum map width reached, cannot zoom out further\n" " if (this.curWidth >= this.maxWidth) {\n" " if (myMapApp.buttons[\"zoomOut\"].activated) {\n" " myMapApp.buttons[\"zoomOut\"].deactivate();\n" " }\n" " if (myMapApp.buttons[\"zoomFull\"].activated) {\n" " myMapApp.buttons[\"zoomFull\"].deactivate();\n" " }\n" " if (myMapApp.buttons[\"panManual\"].activated) {\n" " myMapApp.buttons[\"panManual\"].deactivate();\n" " }\n" " if (myMapApp.buttons[\"recenterMap\"].activated) {\n" " myMapApp.buttons[\"recenterMap\"].deactivate();\n" " }\n" " if (!myMapApp.buttons[\"zoomIn\"].activated) {\n" " myMapApp.buttons[\"zoomIn\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"zoomManual\"].activated) {\n" " myMapApp.buttons[\"zoomManual\"].activate();\n" " }\n" " }\n" " //minimum map width reached, cannot zoom in further\n" " else if (this.curWidth <= this.minWidth) {\n" " if (myMapApp.buttons[\"zoomIn\"].activated) {\n" " myMapApp.buttons[\"zoomIn\"].deactivate();\n" " }\n" " if (myMapApp.buttons[\"zoomManual\"].activated) {\n" " myMapApp.buttons[\"zoomManual\"].deactivate();\n" " }\n" " if (!myMapApp.buttons[\"zoomOut\"].activated) {\n" " myMapApp.buttons[\"zoomOut\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"zoomFull\"].activated) {\n" " myMapApp.buttons[\"zoomFull\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"panManual\"].activated) {\n" " myMapApp.buttons[\"panManual\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"recenterMap\"].activated) {\n" " myMapApp.buttons[\"recenterMap\"].activate();\n" " } \n" " }\n" " //in between\n" " else {\n" " if (!myMapApp.buttons[\"zoomIn\"].activated) {\n" " myMapApp.buttons[\"zoomIn\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"zoomManual\"].activated) {\n" " myMapApp.buttons[\"zoomManual\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"zoomOut\"].activated) {\n" " myMapApp.buttons[\"zoomOut\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"zoomFull\"].activated) {\n" " myMapApp.buttons[\"zoomFull\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"panManual\"].activated) {\n" " myMapApp.buttons[\"panManual\"].activate();\n" " }\n" " if (!myMapApp.buttons[\"recenterMap\"].activated) {\n" " myMapApp.buttons[\"recenterMap\"].activate();\n" " } \n" " } \n" "}\n" "\n" "map.prototype.setNewViewBox = function(xmin,ymin,xmax,ymax,history) {\n" " //check if within constraints\n" " if (xmin < myMapApp.refMapDragger.constrXmin) {\n" " xmin = myMapApp.refMapDragger.constrXmin;\n" " }\n" " if (xmax > myMapApp.refMapDragger.constrXmax) {\n" " xmax = myMapApp.refMapDragger.constrXmin;\n" " }\n" " if (ymin < (myMapApp.refMapDragger.constrYmax * -1)) {\n" " ymin = myMapApp.refMapDragger.constrYmax * -1;\n" " }\n" " if (ymax > (myMapApp.refMapDragger.constrYmin * -1)) {\n" " ymax = myMapApp.refMapDragger.constrYmin * -1;\n" " }\n" " \n" " var origWidth = xmax - xmin;\n" " var origHeight = ymax - ymin;\n" " var myRatio = this.curWidth/this.curHeight;\n" " \n" " if (origWidth / origHeight > myRatio) { //case rect is more wide than ratio\n" " var newWidth = origWidth;\n" " var newHeight = origWidth * 1 / myRatio;\n" " ymin = (ymax + (newHeight - origHeight) / 2) * -1;\n" " }\n" " else {\n" " var newHeight = origHeight;\n" " var newWidth = newHeight * myRatio;\n" " xmin = xmin - (newWidth - origWidth) / 2;\n" " ymin = ymax * -1;\n" " }\n" " //check if within constraints\n" " if (xmin < myMapApp.refMapDragger.constrXmin) {\n" " xmin = myMapApp.refMapDragger.constrXmin;\n" " }\n" " if (ymin < myMapApp.refMapDragger.constrYmin) {\n" " ymin = myMapApp.refMapDragger.constrYmin;\n" " }\n" " if ((xmin + newWidth) > myMapApp.refMapDragger.constrXmax) {\n" " xmin = myMapApp.refMapDragger.constrXmax - newWidth;\n" " }\n" " if ((ymin + newHeight) > myMapApp.refMapDragger.constrYmax) {\n" " ymin = myMapApp.refMapDragger.constrYmax - newHeight;\n" " } \n" " myMapApp.refMapDragger.newView(xmin,ymin,newWidth,newHeight);\n" " this.newViewBox(myMapApp.refMapDragger.dragId,history);\n" "}\n" "\n" "//handles events associated with navigation\n" "map.prototype.handleEvent = function(evt) {\n" " var callerId = evt.currentTarget.getAttributeNS(null,\"id\"));\n" " if (callerId.match(/\\bzoomBgRectManual/)) {\n" " this.zoomManDragRect(evt);\n" " }\n" " if (callerId.match(/\\bzoomBgRectRecenter/)) {\n" " this.recenterFinally(evt);\n" " }\n" " if (callerId.match(/\\bbgPanManual/)) {\n" " this.panManualFinally(evt);\n" " }\n" " if (callerId == \"mainMap\" && evt.type == \"mousemove\")) {\n" " if (this.navStatus != \"panmanualActive\")) {\n" " this.showCoordinates(evt);\n" " }\n" " }\n" "}\n" "\n" "//calcs coordinates; relies on myMapApp to handle different window sizes and resizing of windows\n" "map.prototype.calcCoord = function(evt) {\n" " //with getScreenCTM the values are already in the inner coordinate system\n" " if (!this.getScreenCTM) {\n" " var coords = myMapApp.calcCoord(evt,this.mapSVG);\n" " coords.x = this.curxOrig + (coords.x - this.pixXOffset) * this.pixSize;\n" " coords.y = (this.curyOrig + (coords.y - this.pixYOffset) * this.pixSize);\n" " }\n" " else { \n" " var coords = myMapApp.calcCoord(evt,this.mainMapGroup);\n" " }\n" " return coords;\n" "}\n" "\n" "//displays x and y coordinates in two separate text elements\n" "map.prototype.showCoordinates = function(evt) {\n" " var mapCoords = this.calcCoord(evt);\n" " this.coordXText.nodeValue = \"X: \" + formatNumberString((mapCoords.x * this.unitsFactor).toFixed(this.nrDecimals)) + this.units;\n" " this.coordYText.nodeValue = \"Y: \" + formatNumberString((mapCoords.y * this.unitsFactor * -1).toFixed(this.nrDecimals)) + this.units;\n" "}\n" "\n" "//checks for and removes temporary rectangle objects\n" "map.prototype.stopNavModes = function() {\n" " if (this.navStatus != \"info\")) {\n" " if (this.navStatus == \"zoomManual\")) {\n" " myMapApp.buttons[\"zoomManual\"].setSwitchValue(false,false);\n" " }\n" " if (this.navStatus == \"panmanual\" || this.navStatus == \"panmanualActive\")) {\n" " myMapApp.buttons[\"panManual\"].setSwitchValue(false,false);\n" " }\n" " if (this.navStatus == \"recenter\")) {\n" " myMapApp.buttons[\"recenterMap\"].setSwitchValue(false,false);\n" " }\n" " this.backgroundRect.setAttributeNS(null,\"id\"),\"mapBackgroundRect\"));\n" " myMapApp.buttons[\"infoButton\"].setSwitchValue(true,false);\n" " this.navStatus = \"info\");\n" " this.mapSVG.setAttributeNS(null,\"cursor\"),\"crosshair\"));\n" " statusChange(\"Mode: Infomode\"));\n" " this.mainMapGroup.insertBefore(this.backgroundRect,this.mainMapGroup.firstChild);\n" " }\n" "}\n" "\n" "//starts manual zooming mode\n" "map.prototype.zoomManual = function(evt) {\n" " if (Math.round(myMainMap.curWidth) > myMainMap.minWidth && evt.detail == 1) {\n" " this.navStatus = \"zoomManual\");\n" " this.backgroundRect.setAttributeNS(null,\"id\"),\"zoomBgRectManual\")); \n" " this.mainMapGroup.appendChild(this.backgroundRect);\n" " this.mapSVG.setAttributeNS(null,\"cursor\"),\"se-resize\"));\n" " statusChange(\"Click and drag rectangle for new map extent.\"));\n" " }\n" "}\n" "\n" "//manages manual zooming by drawing a rectangle\n" "map.prototype.zoomManDragRect = function(evt) {\n" " var mapCoords = this.calcCoord(evt);\n" " var myX = mapCoords.x;\n" " var myY = mapCoords.y;\n" " var myYXFact = this.curHeight / this.curWidth;\n" " if (evt.type == \"mousedown\")) {\n" " this.manZoomActive = 1;\n" " this.zoomRect = document.createElementNS(svgNS,\"rect\"));\n" " var myLineWidth = this.curWidth * 0.003;\n" " this.zoomRect.setAttributeNS(null,\"id\"),\"zoomRect\"));\n" " this.zoomRect.setAttributeNS(null,\"fill\"),\"white\"));\n" " this.zoomRect.setAttributeNS(null,\"fill-opacity\"),\"0.5\"));\n" " this.zoomRect.setAttributeNS(null,\"stroke\"),\"dimgray\"));\n" " this.zoomRect.setAttributeNS(null,\"stroke-width\"),myLineWidth);\n" " this.zoomRect.setAttributeNS(null,\"stroke-dasharray\"),(myLineWidth*3)+\"),\"+myLineWidth);\n" " this.zoomRect.setAttributeNS(null,\"pointer-events\"),\"none\"));\n" " this.zoomRect.setAttributeNS(null,\"x\"),myX);\n" " this.zoomRect.setAttributeNS(null,\"y\"),myY);\n" " this.zoomRect.setAttributeNS(null,\"width\"),this.minWidth);\n" " this.zoomRect.setAttributeNS(null,\"height\"),this.minWidth * myYXFact);\n" " this.mainMapGroup.appendChild(this.zoomRect);\n" " this.zoomRectOrigX = myX;\n" " this.zoomRectOrigY = myY;\n" " }\n" " if (evt.type == \"mousemove\" && this.manZoomActive == 1) {\n" " var myZoomWidth = myX - this.zoomRectOrigX;\n" " if (myZoomWidth < 0) {\n" " if (Math.abs(myZoomWidth) < this.minWidth) {\n" " this.zoomRect.setAttributeNS(null,\"x\"),this.zoomRectOrigX - this.minWidth);\n" " this.zoomRect.setAttributeNS(null,\"y\"),this.zoomRectOrigY - this.minWidth * myYXFact);\n" " this.zoomRect.setAttributeNS(null,\"width\"),this.minWidth);\n" " this.zoomRect.setAttributeNS(null,\"height\"),this.minWidth * myYXFact);\n" " }\n" " else {\n" " this.zoomRect.setAttributeNS(null,\"x\"),myX);\n" " this.zoomRect.setAttributeNS(null,\"y\"),this.zoomRectOrigY - Math.abs(myZoomWidth) * myYXFact);\n" " this.zoomRect.setAttributeNS(null,\"width\"),Math.abs(myZoomWidth));\n" " this.zoomRect.setAttributeNS(null,\"height\"),Math.abs(myZoomWidth) * myYXFact); \n" " }\n" " }\n" " else {\n" " this.zoomRect.setAttributeNS(null,\"x\"),this.zoomRectOrigX);\n" " this.zoomRect.setAttributeNS(null,\"y\"),this.zoomRectOrigY);\n" " if (myZoomWidth < this.minWidth) {\n" " this.zoomRect.setAttributeNS(null,\"width\"),this.minWidth);\n" " this.zoomRect.setAttributeNS(null,\"height\"),this.minWidth * myYXFact); \n" " }\n" " else {\n" " this.zoomRect.setAttributeNS(null,\"width\"),myZoomWidth);\n" " this.zoomRect.setAttributeNS(null,\"height\"),myZoomWidth * myYXFact);\n" " }\n" " }\n" " }\n" " if ((evt.type == \"mouseup\" || evt.type == \"mouseout\")) && this.manZoomActive == 1) {\n" " this.manZoomActive = 0;\n" " if (parseFloat(this.zoomRect.getAttributeNS(null,\"width\"))) > this.curWidth * 0.02) {\n" " myMapApp.refMapDragger.newView(parseFloat(this.zoomRect.getAttributeNS(null,\"x\"))),parseFloat(this.zoomRect.getAttributeNS(null,\"y\"))),parseFloat(this.zoomRect.getAttributeNS(null,\"width\"))),parseFloat(this.zoomRect.getAttributeNS(null,\"height\"))));\n" " this.newViewBox(myMapApp.refMapDragger.dragId,true);\n" " }\n" " this.mainMapGroup.removeChild(this.zoomRect);\n" " statusChange(\"Mode: Manual Zooming\"));\n" " }\n" "}\n" "\n" "//initializes recentering mode\n" "map.prototype.recenter = function(evt) {\n" " if (evt.detail == 1) {\n" " this.navStatus = \"recenter\");\n" " this.backgroundRect.setAttributeNS(null,\"id\"),\"zoomBgRectRecenter\")); \n" " this.mainMapGroup.appendChild(this.backgroundRect);\n" " this.mapSVG.setAttributeNS(null,\"cursor\"),\"pointer\"));\n" " statusChange(\"Click in map to define new map center.\"));\n" " }\n" "}\n" "\n" "//finishes recentering after mouse-click\n" "map.prototype.recenterFinally = function(evt) {\n" " if (evt.type == \"click\")) {\n" " var mapCoords = this.calcCoord(evt);\n" " var myX = mapCoords.x;\n" " var myY = mapCoords.y;\n" " var myNewX = myX - this.curWidth / 2;\n" " var myNewY = myY - this.curHeight / 2;\n" " \n" " //check if within constraints\n" " if (myNewX < myMapApp.refMapDragger.constrXmin) {\n" " myNewX = myMapApp.refMapDragger.constrXmin;\n" " }\n" " if (myNewY < myMapApp.refMapDragger.constrYmin) {\n" " myNewY = myMapApp.refMapDragger.constrYmin;\n" " }\n" " if ((myNewX + this.curWidth) > myMapApp.refMapDragger.constrXmax) {\n" " myNewX = myMapApp.refMapDragger.constrXmax - this.curWidth;\n" " }\n" " if ((myNewY + this.curHeight) > myMapApp.refMapDragger.constrYmax) {\n" " myNewY = myMapApp.refMapDragger.constrYmax - this.curHeight;\n" " }\n" " myMapApp.refMapDragger.newView(myNewX,myNewY,this.curWidth,this.curHeight);\n" " this.newViewBox(myMapApp.refMapDragger.dragId,true);\n" " statusChange(\"Mode: Recentering Map\"));\n" " }\n" "}\n" "\n" "//initializes manual panning\n" "map.prototype.panManual = function(evt) {\n" " if (evt.detail == 1) {\n" " this.navStatus = \"panmanual\");\n" " this.backgroundRect.setAttributeNS(null,\"id\"),\"bgPanManual\")); \n" " this.mainMapGroup.appendChild(this.backgroundRect);\n" " this.mapSVG.setAttributeNS(null,\"cursor\"),\"move\"));\n" " statusChange(\"Mouse down and move to pan the map\"));\n" " }\n" "}\n" "\n" "//manages and finishes manual panning\n" "map.prototype.panManualFinally = function(evt) {\n" " if (evt.type == \"mousedown\")) {\n" " this.navStatus = \"panmanualActive\");\n" " this.panCoords = this.calcCoord(evt);\n" " this.panCoorX = this.panCoords.x;\n" " this.panCoorY = this.panCoords.y;\n" " this.diffX = 0;\n" " this.diffY = 0;\n" " this.mainMapGroup.setAttributeNS(batikNS,\"static\"),\"true\"));\n" " }\n" " if (evt.type == \"mousemove\" && this.navStatus == \"panmanualActive\")) {\n" " var mapCoords = this.calcCoord(evt);\n" " if (this.getScreenCTM) {\n" " this.diffX = this.panCoorX - mapCoords.x + this.diffX;\n" " this.diffY = this.panCoorY - mapCoords.y + this.diffY;\n" " }\n" " else {\n" " this.diffX = this.panCoorX - mapCoords.x;\n" " this.diffY = this.panCoorY - mapCoords.y; \n" " }\n" " var myNewX = this.curxOrig + this.diffX;\n" " var myNewY = this.curyOrig + this.diffY;\n" " //check if within constraints\n" " if (myNewX < myMapApp.refMapDragger.constrXmin) {\n" " var myNewXTemp = myMapApp.refMapDragger.constrXmin;\n" " this.diffX = this.diffX + (myNewXTemp - myNewX);\n" " myNewX = myNewXTemp;\n" " }\n" " if (myNewY < myMapApp.refMapDragger.constrYmin) {\n" " var myNewYTemp = myMapApp.refMapDragger.constrYmin;\n" " this.diffY = this.diffY + (myNewYTemp - myNewY);\n" " myNewY = myNewYTemp;\n" " }\n" " if ((myNewX + this.curWidth) > myMapApp.refMapDragger.constrXmax) {\n" " var myNewXTemp = myMapApp.refMapDragger.constrXmax - this.curWidth;\n" " this.diffX = this.diffX + (myNewXTemp - myNewX);\n" " myNewX = myNewXTemp;\n" " }\n" " if ((myNewY + this.curHeight) > myMapApp.refMapDragger.constrYmax) {\n" " var myNewYTemp = myMapApp.refMapDragger.constrYmax - this.curHeight;\n" " this.diffY = this.diffY + (myNewYTemp - myNewY);\n" " myNewY = myNewYTemp;\n" " } \n" " var transformString = \"translate(\"+(this.diffX * -1) +\"),\"+(this.diffY * -1)+\"))\");\n" " this.mainMapGroup.setAttributeNS(null,\"transform\"),transformString);\n" " myMapApp.refMapDragger.newView(myNewX,myNewY,this.curWidth,this.curHeight);\n" " }\n" " if ((evt.type == \"mouseup\" || evt.type == \"mouseout\")) && this.navStatus == \"panmanualActive\")) {\n" " this.navStatus = \"panmanual\");\n" " this.mainMapGroup.setAttributeNS(batikNS,\"static\"),\"false\"));\n" " this.mainMapGroup.setAttributeNS(null,\"transform\"),\"translate(0,0)\"));\n" " this.newViewBox(myMapApp.refMapDragger.dragId,true); \n" " statusChange(\"Mode: Manual Panning\")); \n" " }\n" "}\n" "\n" "//remove all temporarily added elements and event listeners\n" "map.prototype.cleanUp = function() {\n" " //remove background rect\n" " this.backgroundRect.parentNode.removeChild(this.backgroundRect);\n" " //remove eventlisteners\n" " if (this.showCoords == true) {\n" " //add event listener for coordinate display\n" " this.mapSVG.removeEventListener(\"mousemove\"),this,false);\n" " }\n" "\n" "}\n" "\n" "//make an element (rectangle) draggable within constraints\n" "function dragObj(dragId,referenceMap,myDragSymbol,dragSymbThreshold,showCoords,coordXId,coordYId,mainMapObj) {\n" " this.dragId = dragId;\n" " this.myDragger = document.getElementById(this.dragId);\n" " this.myRefMap = document.getElementById(referenceMap);\n" " this.myDragSymbol = document.getElementById(myDragSymbol); \n" " this.dragSymbThreshold = dragSymbThreshold;\n" " var viewBox = this.myRefMap.getAttributeNS(null,\"viewBox\")).split(\" \"));\n" " this.constrXmin = parseFloat(viewBox[0]);\n" " this.constrYmin = parseFloat(viewBox[1]);\n" " this.constrXmax = this.constrXmin + parseFloat(viewBox[2]);\n" " this.constrYmax = this.constrYmin + parseFloat(viewBox[3]);\n" " this.refMapX = parseFloat(this.myRefMap.getAttributeNS(null,\"x\")));\n" " this.refMapY = parseFloat(this.myRefMap.getAttributeNS(null,\"y\")));\n" " this.refMapWidth = parseFloat(this.myRefMap.getAttributeNS(null,\"width\")));\n" " this.pixSize = (this.constrXmax - this.constrXmin) / this.refMapWidth;\n" " this.mainMapObj = mainMapObj;\n" " //initialize coordinate display if showCoords == true\n" " this.showCoords = showCoords;\n" " if (this.showCoords == true) {\n" " if (typeof(coordXId) == \"string\")) {\n" " this.coordXText = document.getElementById(coordXId).firstChild;\n" " }\n" " else {\n" " alert(\"Error: coordXId needs to be an id of type string\"));\n" " }\n" " if (typeof(coordYId) == \"string\")) {\n" " this.coordYText = document.getElementById(coordYId).firstChild;\n" " }\n" " else {\n" " alert(\"Error: coordYId needs to be an id of type string\"));\n" " }\n" " }\n" " //determine if viewer is capable of getScreenCTM\n" " if (document.documentElement.getScreenCTM) {\n" " this.getScreenCTM = true;\n" " }\n" " else {\n" " this.getScreenCTM = false; \n" " }\n" " this.status = false;\n" "}\n" "\n" "dragObj.prototype.calcCoord = function(evt) {\n" " //with getScreenCTM the values are already in the inner coordinate system but without using the outer offset\n" " var coordPoint = myMapApp.calcCoord(evt,this.myRefMap);\n" " if (!this.getScreenCTM) {\n" " coordPoint.x = this.constrXmin + (coordPoint.x - this.refMapX) * this.pixSize;\n" " coordPoint.y = this.constrYmin + (coordPoint.y - this.refMapY) * this.pixSize;\n" " }\n" " return coordPoint;\n" "}\n" "\n" "dragObj.prototype.handleEvent = function(evt) {\n" " if (evt.type == \"mousemove\")) {\n" " var mapCoords = this.calcCoord(evt);\n" " this.coordXText.nodeValue = \"X: \" + formatNumberString(mapCoords.x.toFixed(this.mainMapObj.nrDecimals)) + this.mainMapObj.units;\n" " this.coordYText.nodeValue = \"Y: \" + formatNumberString((mapCoords.y * -1).toFixed(this.mainMapObj.nrDecimals)) + this.mainMapObj.units;\n" " }\n" " this.drag(evt);\n" "}\n" "\n" "dragObj.prototype.newView = function(x,y,width,height) {\n" " this.myDragger.setAttributeNS(null,\"x\"),x);\n" " this.myDragger.setAttributeNS(null,\"y\"),y);\n" " this.myDragger.setAttributeNS(null,\"width\"),width);\n" " this.myDragger.setAttributeNS(null,\"height\"),height);\n" " this.myDragSymbol.setAttributeNS(null,\"x\"),(x + width/2));\n" " this.myDragSymbol.setAttributeNS(null,\"y\"),(y + height/2));\n" " if (width < this.dragSymbThreshold) {\n" " this.myDragSymbol.setAttributeNS(null,\"visibility\"),\"visible\"));\n" " }\n" " else {\n" " this.myDragSymbol.setAttributeNS(null,\"visibility\"),\"hidden\")); \n" " }\n" "}\n" "\n" ); } //--------------------------------------------------------- const char * CSVG_Interactive_Map::_Get_Code_Navigation_2(void) { return( "//this method was previously called \"resizeDragger\" - now renamed to .getSliderVal\n" "//this method receives values from the zoom slider\n" "dragObj.prototype.getSliderVal = function(status,sliderGroupName,width) {\n" " var myX = parseFloat(this.myDragger.getAttributeNS(null,\"x\")));\n" " var myY = parseFloat(this.myDragger.getAttributeNS(null,\"y\")));\n" " var myWidth = parseFloat(this.myDragger.getAttributeNS(null,\"width\")));\n" " var myHeight = parseFloat(this.myDragger.getAttributeNS(null,\"height\")));\n" " var myCenterX = myX + myWidth / 2;\n" " var myCenterY = myY + myHeight / 2;\n" " var myRatio = myHeight / myWidth;\n" " var toMoveX = myCenterX - width / 2;\n" " var toMoveY = myCenterY - width * myRatio / 2;\n" " if (toMoveX < this.constrXmin) {\n" " toMoveX = this.constrXmin;\n" " }\n" " if ((toMoveX + width) > this.constrXmax) {\n" " toMoveX = this.constrXmax - width;\n" " }\n" " if (toMoveY < this.constrYmin) {\n" " toMoveY = this.constrYmin;\n" " }\n" " if ((toMoveY + width * myRatio) > this.constrYmax) {\n" " toMoveY = this.constrYmax - width * myRatio;\n" " }\n" " this.newView(toMoveX,toMoveY,width,width * myRatio);\n" " if (status == \"release\")) {\n" " myMainMap.stopNavModes();\n" " this.mainMapObj.newViewBox(this.dragId,true);\n" " }\n" "}\n" "\n" "dragObj.prototype.drag = function(evt) {\n" " if (evt.type == \"mousedown\")) {\n" " this.myRefMap.setAttributeNS(null,\"cursor\"),\"move\"));\n" " this.status = true;\n" " }\n" " if ((evt.type == \"mousemove\" || evt.type == \"mousedown\")) && this.status == true) {\n" " var coords = this.calcCoord(evt);\n" " var newEvtX = coords.x;\n" " var newEvtY = coords.y;\n" " var myX = parseFloat(this.myDragger.getAttributeNS(null,\"x\")));\n" " var myY = parseFloat(this.myDragger.getAttributeNS(null,\"y\")));\n" " var myWidth = parseFloat(this.myDragger.getAttributeNS(null,\"width\")));\n" " var myHeight = parseFloat(this.myDragger.getAttributeNS(null,\"height\")));\n" " var toMoveX = newEvtX - myWidth / 2;\n" " var toMoveY = newEvtY - myHeight / 2;\n" " if (toMoveX < this.constrXmin) {\n" " toMoveX = this.constrXmin;\n" " }\n" " if ((toMoveX + myWidth) > this.constrXmax) {\n" " toMoveX = this.constrXmax - myWidth;\n" " }\n" " if (toMoveY < this.constrYmin) {\n" " toMoveY = this.constrYmin;\n" " }\n" " if ((toMoveY + myHeight) > this.constrYmax) {\n" " toMoveY = this.constrYmax - myHeight;\n" " }\n" " this.newView(toMoveX,toMoveY,myWidth,myHeight);\n" " }\n" " if ((evt.type == \"mouseup\" || evt.type == \"mouseout\")) && this.status == true) {\n" " this.status = false;\n" " if (evt.detail == 1) { //second click is ignored\n" " this.myRefMap.setAttributeNS(null,\"cursor\"),\"crosshair\"));\n" " this.mainMapObj.newViewBox('dragRectForRefMap',true);\n" " }\n" " }\n" "}\n" "\n" "dragObj.prototype.zoom = function(inOrOut) {\n" " var myOldX = this.myDragger.getAttributeNS(null,\"x\"));\n" " var myOldY = this.myDragger.getAttributeNS(null,\"y\"));\n" " var myOldWidth = this.myDragger.getAttributeNS(null,\"width\"));\n" " var myOldHeight = this.myDragger.getAttributeNS(null,\"height\"));\n" " switch (inOrOut) {\n" " case \"in\":\n" " var myNewX = parseFloat(myOldX) + myOldWidth / 2 - (myOldWidth * this.mainMapObj.zoomFact * 0.5);\n" " var myNewY = parseFloat(myOldY) + myOldHeight / 2 - (myOldHeight * this.mainMapObj.zoomFact * 0.5);\n" " var myNewWidth = myOldWidth * this.mainMapObj.zoomFact;\n" " var myNewHeight = myOldHeight * this.mainMapObj.zoomFact;\n" " if (myNewWidth < this.mainMapObj.minWidth) {\n" " var myYXFact = this.mainMapObj.curHeight / this.mainMapObj.curWidth;\n" " myNewWidth = this.mainMapObj.minWidth;\n" " myNewHeight = myNewWidth * myYXFact;\n" " myNewX = parseFloat(myOldX) + myOldWidth / 2 - (myNewWidth * 0.5);\n" " myNewY = parseFloat(myOldY) + myOldHeight / 2 - (myNewHeight * 0.5);\n" " }\n" " break;\n" " case \"out\":\n" " var myNewX = parseFloat(myOldX) + myOldWidth / 2 - (myOldWidth * (1 + this.mainMapObj.zoomFact) * 0.5);\n" " var myNewY = parseFloat(myOldY) + myOldHeight / 2 - (myOldHeight * (1 + this.mainMapObj.zoomFact) * 0.5);\n" " var myNewWidth = myOldWidth * (1 + this.mainMapObj.zoomFact);\n" " var myNewHeight = myOldHeight * (1 + this.mainMapObj.zoomFact);\n" " break;\n" " default:\n" " var myNewX = this.constrXmin;\n" " var myNewY = this.constrYmin;\n" " var myNewWidth = this.constrXmax - this.constrXmin;\n" " var myNewHeight = this.constrYmax - this.constrYmin;\n" " break;\n" " } \n" " //check if within constraints\n" " if (myNewWidth > (this.constrXmax - this.constrXmin)) {\n" " myNewWidth = this.constrXmax - this.constrXmin;\n" " }\n" " if (myNewHeight > (this.constrYmax - this.constrYmin)) {\n" " myNewHeight = this.constrYmax - this.constrYmin;\n" " }\n" " if (myNewX < this.constrXmin) {\n" " myNewX = this.constrXmin;\n" " }\n" " if (myNewY < this.constrYmin) {\n" " myNewY = this.constrYmin;\n" " }\n" " if ((myNewX + myNewWidth) > this.constrXmax) {\n" " myNewX = this.constrXmax - myNewWidth;\n" " }\n" " if ((myNewY + myNewHeight) > this.constrYmax) {\n" " myNewY = this.constrYmax - myNewHeight;\n" " }\n" " this.newView(myNewX,myNewY,myNewWidth,myNewHeight);\n" " this.mainMapObj.newViewBox(this.dragId,true);\n" "}\n" "\n" "dragObj.prototype.pan = function (myX,myY,howmuch) {\n" " //get values from draggable rectangle\n" " var xulcorner = parseFloat(this.myDragger.getAttributeNS(null,\"x\")));\n" " var yulcorner = parseFloat(this.myDragger.getAttributeNS(null,\"y\")));\n" " var width = parseFloat(this.myDragger.getAttributeNS(null,\"width\")));\n" " var height = parseFloat(this.myDragger.getAttributeNS(null,\"height\")));\n" "\n" " //set values of draggable rectangle\n" " var rectXulcorner = xulcorner + howmuch * width * myX;\n" " var rectYulcorner = yulcorner + howmuch * height * myY;\n" " //check if within constraints\n" " if (rectXulcorner < this.constrXmin) {\n" " rectXulcorner = this.constrXmin;\n" " }\n" " if (rectYulcorner < this.constrYmin) {\n" " rectYulcorner = this.constrYmin;\n" " }\n" " if ((rectXulcorner + width) > this.constrXmax) {\n" " rectXulcorner = this.constrXmax - width;\n" " }\n" " if ((rectYulcorner + height) > this.constrYmax) {\n" " rectYulcorner = this.constrYmax - height;\n" " }\n" " this.newView(rectXulcorner,rectYulcorner,width,height);\n" "\n" " //set viewport of main map\n" " if ((xulcorner != rectXulcorner) || (yulcorner != rectYulcorner)) {\n" " this.mainMapObj.newViewBox(this.dragId,true);\n" " }\n" "\n" " statusChange(\"map ready ...\"));\n" "}\n" "\n" "//remove all temporarily used elements and event listeners\n" "dragObj.prototype.cleanUp = function() {\n" " //remove eventlisteners\n" " if (this.showCoords == true) {\n" " //add event listener for coordinate display\n" " this.myRefMap.removeEventListener(\"mousemove\"),this,false);\n" " }\n" "}\n" "\n" "function zoomIt(evt,inOrOut) {\n" " if (evt.detail == 1) { //only react on first click, double click: second click is ignored\n" " if (inOrOut == \"in\")) {\n" " if (Math.round(myMainMap.curWidth) > myMainMap.minWidth) {\n" " myMapApp.refMapDragger.zoom(\"in\"));\n" " }\n" " else {\n" " statusChange(\"Maximum zoom factor reached. Cannot zoom in any more.\"));\n" " }\n" " }\n" " if (inOrOut == \"out\")) {\n" " if (Math.round(myMainMap.curWidth) < myMainMap.maxWidth) {\n" " myMapApp.refMapDragger.zoom(\"out\"));\n" " }\n" " else {\n" " statusChange(\"Minimum zoom factor reached. Cannot zoom out any more.\"));\n" " }\n" " }\n" " if (inOrOut == \"full\")) {\n" " if (Math.round(myMainMap.curWidth) < myMainMap.maxWidth) {\n" " myMapApp.refMapDragger.zoom(\"full\"));\n" " }\n" " else {\n" " statusChange(\"Full view already reached.\"));\n" " }\n" " }\n" " }\n" "}\n" "\n" "//this function starts various zoom actions or map extent history functions\n" "function zoomImageButtons(id,evt) {\n" " myMainMap.stopNavModes();\n" " if (id == \"zoomIn\")) {\n" " zoomIt(evt,'in');\n" " }\n" " if (id == \"zoomOut\")) {\n" " zoomIt(evt,'out');\n" " }\n" " if (id == \"zoomFull\")) {\n" " zoomIt(evt,'full');\n" " }\n" " if (id == \"backwardExtent\")) {\n" " myMainMap.backwardExtent();\n" " }\n" " if (id == \"forwardExtent\")) {\n" " myMainMap.forwardExtent();\n" " }\n" "}\n" "\n" "//this function starts various interactive zoom or pan modes\n" "function zoomImageSwitchButtons(id,evt,onOrOff) {\n" " myMainMap.stopNavModes();\n" " if (onOrOff) {\n" " if (id == \"infoButton\")) {\n" " \n" " }\n" " else {\n" " if (id == \"zoomManual\")) {\n" " myMainMap.zoomManual(evt);\n" " }\n" " if (id == \"panManual\")) {\n" " myMainMap.panManual(evt);\n" " }\n" " if (id == \"recenterMap\")) {\n" " myMainMap.recenter(evt);\n" " }\n" " if (myMapApp.buttons[\"infoButton\"].getSwitchValue()) {\n" " myMapApp.buttons[\"infoButton\"].setSwitchValue(false,false);\n" " }\n" " }\n" " }\n" " else {\n" " if (id == \"infoButton\")) {\n" " myMapApp.buttons[\"infoButton\"].setSwitchValue(true,false);\n" " }\n" " }\n" "}\n" "\n" "//alert map extent\n" "function showExtent() {\n" " with(myMainMap) {\n" " alert(\n" " \"Xmin=\"+curxOrig.toFixed(nrDecimals)+units+\n" " \"); Xmax=\"+(curxOrig + curWidth).toFixed(nrDecimals)+units+\n" " \"\\nYmin=\"+((curyOrig + curHeight) * -1).toFixed(nrDecimals) +units+\n" " \"); Ymax=\"+(curyOrig*-1).toFixed(nrDecimals)+units+\n" " \"\\nWidth=\"+curWidth.toFixed(nrDecimals)+units+\n" " \"); Height=\"+curHeight.toFixed(nrDecimals)+units);\n" " }\n" "}\n" "\n" ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/docs/docs_html/doc_html.cpp0000744000175000017500000004475612737416156023261 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_html.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // // // //-------------------------------------------------------// // // // doc_html.cpp // // // // Copyright (C) 2005 by // // Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. // // // // This library is free software; you can redistribute // // it and/or modify it under the terms of the GNU Lesser // // General Public License as published by the Free // // Software Foundation, version 2.1 of the License. // // // // This library is distributed in the hope that it will // // be useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU Lesser General Public // // License for more details. // // // // You should have received a copy of the GNU Lesser // // General Public License along with this program; if // // not, write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Victor Olaya // // // // e-mail: volaya@saga-gis.org // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_html.h" //--------------------------------------------------------- #define GRAPH_WIDTH 700 #define GRAPH_HEIGHT 350 #define MAP_WIDTH 700. #define MAP_HEIGHT 700. #define OFFSET_X 50 #define OFFSET_Y 50 //--------------------------------------------------------- #define HTML_CODE_OPENING_1 SG_T("\n") #define HTML_CODE_OPENING_2 SG_T("\n")\ SG_T("\n")\ SG_T("\n")\ SG_T("\n") #define HTML_CODE_CLOSING SG_T("\n") /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Doc_HTML::CSG_Doc_HTML(){} CSG_Doc_HTML::~CSG_Doc_HTML(){} void CSG_Doc_HTML::Open(const SG_Char *Title) { m_sHTMLCode.Clear(); m_sHTMLCode.Append(HTML_CODE_OPENING_1); m_sHTMLCode.Append(Title); m_sHTMLCode.Append(HTML_CODE_OPENING_2); } bool CSG_Doc_HTML::Save(const SG_Char *Filename) { m_sHTMLCode.Append(HTML_CODE_CLOSING); CSG_File Stream(Filename, SG_FILE_W, false); if( Stream.is_Open() ) { Stream.Printf(SG_T("%s"), m_sHTMLCode.c_str()); return true; } return false; } void CSG_Doc_HTML::AddParagraph(const SG_Char *Text) { m_sHTMLCode.Append(SG_T("

")); m_sHTMLCode.Append(Text); m_sHTMLCode.Append(SG_T("

\n")); } void CSG_Doc_HTML::AddLineBreak() { m_sHTMLCode.Append(SG_T("
")); } void CSG_Doc_HTML::AddHeader(const SG_Char *Text, int iOrder) { m_sHTMLCode.Append(SG_T("")); m_sHTMLCode.Append(Text); m_sHTMLCode.Append(SG_T("\n")); } void CSG_Doc_HTML::AddHyperlink(const SG_Char *Text, const SG_Char *URL) { m_sHTMLCode.Append(SG_T("\n")); m_sHTMLCode.Append(Text); m_sHTMLCode.Append(SG_T("\n")); } CSG_String CSG_Doc_HTML::GetHyperlinkCode(const SG_Char *Text, const SG_Char *URL) { CSG_String s; s.Append(SG_T("\n")); s.Append(Text); s.Append(SG_T("\n")); return s; } void CSG_Doc_HTML::AddImage(const SG_Char *Filename) { m_sHTMLCode.Append(SG_T("\n")); } void CSG_Doc_HTML::AddThumbnail(const SG_Char *Filename, int iWidth, bool bIsPercent) { m_sHTMLCode.Append(SG_T("\n")); m_sHTMLCode.Append(SG_T("

\n")); } void CSG_Doc_HTML::AddThumbnails(const SG_Char **Filename, int iImages, int iThumbnailsPerRow) { int i,j; int iImage = 0; int iRows = (int)ceil((double)iImages / (double)iThumbnailsPerRow); int iWidth = (int)(100.0 / (double)iThumbnailsPerRow); m_sHTMLCode.Append(SG_T("\n")); for (i=0; i\n")); for (j=0; j")); AddThumbnail(Filename[iImage], 100, true); iImage++; if (iImage >= iImages){ break; } m_sHTMLCode.Append(SG_T("")); } m_sHTMLCode.Append(SG_T("\n\n")); } m_sHTMLCode.Append(SG_T("\n
\n")); } void CSG_Doc_HTML::StartUnorderedList() { m_sHTMLCode.Append(SG_T("
    \n")); } void CSG_Doc_HTML::StartOrderedList() { m_sHTMLCode.Append(SG_T("
      \n")); } void CSG_Doc_HTML::CloseUnorderedList() { m_sHTMLCode.Append(SG_T("
\n")); } void CSG_Doc_HTML::CloseOrderedList() { m_sHTMLCode.Append(SG_T("\n")); } void CSG_Doc_HTML::AddListElement(const SG_Char *Text) { m_sHTMLCode.Append(SG_T("
  • ")); m_sHTMLCode.Append(Text); m_sHTMLCode.Append(SG_T("
  • \n")); } void CSG_Doc_HTML::AddOrderedList(const SG_Char **Text, int iElements) { StartOrderedList(); for (int i = 0; i < iElements; i++) { AddListElement(Text[i]); } CloseOrderedList(); } void CSG_Doc_HTML::AddUnorderedList(const SG_Char **Text, int iElements) { StartUnorderedList(); for (int i = 0; i < iElements; i++) { AddListElement(Text[i]); } CloseUnorderedList(); } void CSG_Doc_HTML::AddCurve(const SG_Char *Filename, CSG_Points &Data, const SG_Char *Description, int iGraphType, bool bIncludeTableData) { int i; int iMag; int iNumLines; double fMinLine = 0; double fWidth; double fMax, fMin; double fRange, fRangeX; double fStep; double fX, fY, fY2; double fMaxX, fMinX; CSG_String sValue; CSG_String sTableFilename; CSG_Points Points; CSG_Doc_SVG SVG; m_sHTMLCode.Append(SG_T("
    \n")); m_sHTMLCode.Append(SG_T("

    ")); m_sHTMLCode.Append(Description); m_sHTMLCode.Append(SG_T("

    \n")); fMin = fMax = Data[0].y; for (i = 0; i < Data.Get_Count(); i++) { if (Data[i].y > fMax) { fMax = Data[i].y; } if (Data[i].y < fMin) { fMin = Data[i].y; } if (iGraphType == HTML_GRAPH_TYPE_BARS){ fMin = M_GET_MIN(0, fMin); } } fRange = fMax - fMin; fMaxX = Data[Data.Get_Count() - 1].x; fMinX = Data[0].x; fRangeX = fMaxX - fMinX; SVG.Open(GRAPH_WIDTH + OFFSET_X, GRAPH_HEIGHT + OFFSET_Y); if (fMin != fMax){ iMag = (int) (log(fMax - fMin) / log(10.0)); fStep = (int) pow(10.0, (double) iMag); if (fStep == 0) { fStep = 1.; } if (fMin < 0) { iMag = (int) (log(fabs(fMin)) / log(10.0)); fMinLine = -(int) pow(10.0, (double) iMag); } else { fMinLine=(int)(((int)(fMin/fStep)) *fStep); } iNumLines = (int) ((fMax - fMin) / fStep); while (iNumLines < 8) { fStep = fStep / 2.0; iNumLines = (int) ((fMax - fMin) / fStep); } iNumLines = (int) ((fMax - fMinLine) / fStep); } else{ if (fMin > 0) { fStep = fMin = 0; iNumLines = 1; fMinLine = fMax; } else if (fMin < 0) { fStep = 0; fMin = fMin - 1; fMinLine = fMax; } else { return; } } for (i = 0; i < iNumLines; i++) { fY = (fMinLine + fStep * i - fMin) / (fRange) * GRAPH_HEIGHT; fY = GRAPH_HEIGHT - fY; if (fY >= 0 && fY <= GRAPH_HEIGHT) { SVG.Draw_Line(OFFSET_X - 10, fY, GRAPH_WIDTH + OFFSET_X, fY); SVG.Draw_Text(OFFSET_X - 10, fY, SG_Get_String(fMinLine + fStep * i, 1), 0, SG_T("Verdana"), 8, SVG_ALIGNMENT_Right); } } if (iGraphType == HTML_GRAPH_TYPE_BARS) { fWidth = GRAPH_WIDTH / (double) (Data.Get_Count()) ; for (i = 0; i < Data.Get_Count(); i++) { fX = OFFSET_X + i * fWidth; fY = GRAPH_HEIGHT; fY2 = (Data.Get_Y(i) - fMin) / fRange * GRAPH_HEIGHT; fY2 = GRAPH_HEIGHT - fY2; SVG.Draw_Rectangle(fX, fY, fX + fWidth, fY2, 0x660000, 0x000000); } } else { for (i = 0; i < Data.Get_Count(); i++) { fX = OFFSET_X + (Data.Get_X(i) - fMinX) / fRangeX * GRAPH_WIDTH; fY = (Data.Get_Y(i) - fMin) / fRange * GRAPH_HEIGHT; fY = GRAPH_HEIGHT - fY; Points.Add(fX, fY); } SVG.Draw_Line(Points, 4, 0x660000); } if (fMaxX != fMinX) { iMag = (int) (log(fMaxX - fMinX) / log(10.0)); fStep = (double) pow(10.0, (double) iMag); iNumLines = (int) ((fMaxX -fMinX) / fStep); while (iNumLines < 5) { fStep = fStep / 2.0; iNumLines = (int) ((fMaxX-fMinX) / fStep); } fMinLine = (int)(((int)(fMinX/fStep)) * fStep); while (fMinLine = OFFSET_X && fX <= GRAPH_WIDTH + OFFSET_X){ if (fabs(fStep * i +fMinLine) > 100000) { sValue = SG_Get_String(fStep * i +fMinLine); } else { sValue = SG_Get_String(fStep * i + fMinLine, 2, true); } SVG.Draw_Text(fX, GRAPH_HEIGHT + 10, sValue, 0, SG_T("Verdana"), 8, SVG_ALIGNMENT_Center); SVG.Draw_Line(fX, GRAPH_HEIGHT, fX, GRAPH_HEIGHT - 5); } } } SVG.Draw_Line(OFFSET_X, 0, OFFSET_X, GRAPH_HEIGHT, 4); SVG.Draw_Line(OFFSET_X, GRAPH_HEIGHT, OFFSET_X + GRAPH_WIDTH, GRAPH_HEIGHT, 4); SVG.Save(Filename); if (bIncludeTableData) { CSG_Doc_HTML HTMLDoc; HTMLDoc.Open(_TL("Data Table")); sTableFilename = Filename; sTableFilename.Append(SG_T(".htm")); m_sHTMLCode.Append(SG_T("")); m_sHTMLCode.Append(_TL("Data Table")); m_sHTMLCode.Append(SG_T("

    \n")); HTMLDoc._AddBicolumTable(&Data); HTMLDoc.Save(sTableFilename); } }//method void CSG_Doc_HTML::_AddBicolumTable(CSG_Points *pData) { int i; m_sHTMLCode.Append(SG_T("\n")); m_sHTMLCode.Append( SG_T("\n") SG_T("\n") SG_T("\n") ); for (i=0; iGet_Count(); i++) { m_sHTMLCode.Append(SG_T("\n")); m_sHTMLCode.Append(SG_T("")); m_sHTMLCode.Append(SG_T("")); m_sHTMLCode.Append(SG_T("\n\n")); } m_sHTMLCode.Append(SG_T("\n
    XY
    ")); m_sHTMLCode.Append(SG_Get_String(pData->Get_X(i),2)); m_sHTMLCode.Append(SG_T("")); m_sHTMLCode.Append(SG_Get_String(pData->Get_Y(i),2)); m_sHTMLCode.Append(SG_T("
    \n")); m_sHTMLCode.Append(SG_T("

    ")); m_sHTMLCode.Append(_TL("Data Table")); m_sHTMLCode.Append(SG_T("

    \n")); } void CSG_Doc_HTML::AddTable(const SG_Char ***Table, int iRows, int iCols, const SG_Char *Description) { int i,j; int iWidth = (int) (100/iCols); m_sHTMLCode.Append(SG_T("\n")); for (i=0; i\n")); } else { m_sHTMLCode.Append(SG_T("\n")); } for (j=0; j")); try { m_sHTMLCode.Append(Table[i][j]); } catch(...){} m_sHTMLCode.Append(SG_T("")); } m_sHTMLCode.Append(SG_T("\n\n")); } m_sHTMLCode.Append(SG_T("\n
    \n")); m_sHTMLCode.Append(SG_T("

    ")); m_sHTMLCode.Append(Description); m_sHTMLCode.Append(SG_T("

    \n")); } void CSG_Doc_HTML::AddTable(CSG_Table *pTable) { int i,j; int iWidth = (int) (100/pTable->Get_Field_Count()); m_sHTMLCode.Append(SG_T("\n")); m_sHTMLCode.Append(SG_T("\n")); for (i=0; iGet_Field_Count(); i++){ m_sHTMLCode.Append(SG_T("")); } m_sHTMLCode.Append(SG_T("\n\n")); for (i=0; iGet_Record_Count(); i++) { m_sHTMLCode.Append(SG_T("\n")); for (j=0; jGet_Field_Count(); j++){ m_sHTMLCode.Append(SG_T("")); } m_sHTMLCode.Append(SG_T("\n\n")); } m_sHTMLCode.Append(SG_T("\n
    ")); m_sHTMLCode.Append(pTable->Get_Field_Name(i)); m_sHTMLCode.Append(SG_T("
    ")); try { m_sHTMLCode.Append(pTable->Get_Record(i)->asString(j)); } catch(...){} m_sHTMLCode.Append(SG_T("
    \n")); m_sHTMLCode.Append(SG_T("

    ")); m_sHTMLCode.Append(pTable->Get_Name()); m_sHTMLCode.Append(SG_T("

    \n")); } bool CSG_Doc_HTML::_Draw_Shape(CSG_Doc_SVG &SVG, CSG_Shape *pShape, CSG_Rect GlobalRect, int Fill_Color, int Line_Color, int Line_Width, int Point_Width) { if( pShape && pShape->is_Valid() ) { int iPart, iPoint; double x,y; TSG_Point Point; CSG_Points Points; double dWidth, dHeight; double dOffsetX, dOffsetY; if (GlobalRect.Get_XRange() / GlobalRect.Get_YRange() > MAP_WIDTH / MAP_HEIGHT) { dWidth = MAP_WIDTH * .95; dHeight = MAP_HEIGHT / GlobalRect.Get_XRange() * GlobalRect.Get_YRange(); } else{ dHeight = MAP_HEIGHT * .95; dWidth = MAP_WIDTH / GlobalRect.Get_YRange() * GlobalRect.Get_XRange(); } dOffsetX = (MAP_WIDTH - dWidth) / 2.; dOffsetY = (MAP_HEIGHT - dHeight) / 2.; SVG.Draw_Rectangle(0,0,MAP_WIDTH,MAP_HEIGHT,SG_COLOR_NONE,SG_COLOR_BLACK,1); for(iPart=0; iPartGet_Part_Count(); iPart++) { Points.Clear(); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Point = pShape->Get_Point(iPoint, iPart); x = dOffsetX + (Point.x - GlobalRect.Get_XMin()) / GlobalRect.Get_XRange() * dWidth; y = (Point.y - GlobalRect.Get_YMin()) / GlobalRect.Get_YRange() * dHeight; y = MAP_HEIGHT - y - dOffsetY; Points.Add(x, y); } switch( pShape->Get_Type() ) { case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: for(iPoint=0; iPointis_Lake(iPart) ) { SVG.Draw_Polygon(Points, SG_COLOR_WHITE, Line_Color, Line_Width); } else { SVG.Draw_Polygon(Points, Fill_Color, Line_Color, Line_Width); } break; } } return( true ); } return( false ); } bool CSG_Doc_HTML::Draw_Shapes(CSG_Shapes *pShapes, const SG_Char *Filename, int Fill_Color, int Line_Color, int Line_Width) { CSG_Doc_SVG SVG; CSG_Rect r; if( pShapes && pShapes->is_Valid()) { r = pShapes->Get_Extent(); SVG.Open((int)MAP_WIDTH, (int)MAP_HEIGHT); for(int iShape=0; iShapeGet_Count(); iShape++) { _Draw_Shape(SVG, pShapes->Get_Shape(iShape), r, Fill_Color, Line_Color, 1, 3); } SVG.Save(Filename); m_sHTMLCode.Append(SG_T("
    \n

    \n")); return( true ); } return( false ); } saga-2.3.1/src/modules/docs/docs_html/doc_html.h0000744000175000017500000001425012737416156022710 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_html.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // doc_html.h // // // // Copyright (C) 2005 by // // Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. // // // // This library is free software; you can redistribute // // it and/or modify it under the terms of the GNU Lesser // // General Public License as published by the Free // // Software Foundation, version 2.1 of the License. // // // // This library is distributed in the hope that it will // // be useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU Lesser General Public // // License for more details. // // // // You should have received a copy of the GNU Lesser // // General Public License along with this program; if // // not, write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__docs_html__doc_html_H #define HEADER_INCLUDED__docs_html__doc_html_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_svg.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define HTML_GRAPH_TYPE_BARS 1 #define HTML_GRAPH_TYPE_LINES 2 #define HTML_COLOR_RANDOM -2 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class docs_html_EXPORT CSG_Doc_HTML { public: CSG_Doc_HTML(void); virtual ~CSG_Doc_HTML(void); void Open (const SG_Char *Title); bool Save (const SG_Char *FileName); void AddCurve (const SG_Char *Filename, CSG_Points &Points, const SG_Char *Description, int iGraphType, bool bIncludeTableData); void AddTable (const SG_Char ***Table, int iRows, int iCols, const SG_Char *Description); void AddTable (CSG_Table *pTable); void AddParagraph (const SG_Char *Text); void AddLineBreak (); void AddHeader (const SG_Char *Text, int iOrder); void AddHyperlink (const SG_Char *Text, const SG_Char *URL); CSG_String GetHyperlinkCode (const SG_Char *Text, const SG_Char *URL); void AddImage (const SG_Char *Filename); void AddThumbnail (const SG_Char *Filename, int iWidth, bool bIsPercent); void AddThumbnails (const SG_Char **Text, int iImages, int iThumbnailsPerRow); void StartUnorderedList (void); void StartOrderedList (void); void CloseUnorderedList (void); void CloseOrderedList (void); void AddListElement (const SG_Char *Text); void AddOrderedList (const SG_Char **Text, int iElement); void AddUnorderedList (const SG_Char **Text, int iElement); bool Draw_Shapes (CSG_Shapes *pShapes, const SG_Char *Filename, int Fill_Color, int Line_Color, int Line_Width); private: CSG_String m_sHTMLCode; bool _Draw_Shape (CSG_Doc_SVG &SVG, CSG_Shape *pShape, CSG_Rect GlobalRect, int Fill_Color, int Line_Color, int Line_Width, int Point_Width); void _AddBicolumTable (CSG_Points *pData); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__docs_html__doc_html_H saga-2.3.1/src/modules/docs/docs_html/doc_svg.h0000744000175000017500000001402712737416156022545 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_svg.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // doc_svg.h // // // // Copyright (C) 2005 by // // Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. // // // // This library is free software; you can redistribute // // it and/or modify it under the terms of the GNU Lesser // // General Public License as published by the Free // // Software Foundation, version 2.1 of the License. // // // // This library is distributed in the hope that it will // // be useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU Lesser General Public // // License for more details. // // // // You should have received a copy of the GNU Lesser // // General Public License along with this program; if // // not, write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__docs_html__doc_svg_H #define HEADER_INCLUDED__docs_html__doc_svg_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- typedef enum ESG_SVG_Alignment { SVG_ALIGNMENT_Left = 0, SVG_ALIGNMENT_Center, SVG_ALIGNMENT_Right } TSG_SVG_Alignment; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class docs_html_EXPORT CSG_Doc_SVG { public: CSG_Doc_SVG(void); virtual ~CSG_Doc_SVG(void); void Open (int iWidth, int iHeight); bool Save (const SG_Char *FileName); void Draw_Line (double xa, double ya, double xb, double yb , double Width = 1., int Color = SG_COLOR_BLACK); void Draw_Line (CSG_Points &Points , double Width = 1., int Color = SG_COLOR_BLACK); void Draw_Rectangle (double xa, double ya, double xb, double yb , int Fill_Color = SG_COLOR_WHITE, int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_Rectangle (const CSG_Rect &r , int Fill_Color = SG_COLOR_WHITE, int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_Polygon (CSG_Points &Points , int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_LinkedPolygon (CSG_Points &Points, const SG_Char *Link , int Fill_Color = SG_COLOR_GREEN, int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_Circle (double x, double y, double Radius , int Fill_Color = SG_COLOR_RED , int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_LinkedCircle (double x, double y, double Radius, const SG_Char *Link, int Fill_Color = SG_COLOR_RED , int Line_Color = SG_COLOR_BLACK, double Line_Width = 1.); void Draw_Text (double x, double y, const SG_Char *Text, int iColor, const SG_Char* Font, double dSize, TSG_SVG_Alignment Alignment = SVG_ALIGNMENT_Center); protected: CSG_String m_sSVGCode; void _AddAttribute (const SG_Char *Attribute, const SG_Char *Value); void _AddAttribute (const SG_Char *Attribute, int Value); void _AddAttribute (const SG_Char *Attribute, double Value); CSG_String _Get_SVGColor (int iColor); private: int m_iWidth, m_iHeight; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif //#ifndef HEADER_INCLUDED__docs_html__doc_svg_H saga-2.3.1/src/modules/docs/docs_html/svg_interactive_map.h0000744000175000017500000001267612737416156025162 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: svg_interactive_map.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // SVG_Interactive_map.cpp // // // // Copyright (C) 2005 by Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Victor Olaya // // // // e-mail: volaya@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef _HEADER_INCLUDED__SAGA_GUI__svg_interactive_map_H #define _HEADER_INCLUDED__SAGA_GUI__svg_interactive_map_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_svg.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSVG_Interactive_Map : public CSG_Doc_SVG, public CSG_Module { public: CSVG_Interactive_Map(void); virtual ~CSVG_Interactive_Map(void); protected: virtual bool On_Execute(void); private: CSG_String m_Directory; double m_dWidth; bool Create_From_Map (CSG_Parameter_Shapes_List *pList, CSG_Shapes *pIndexLayer, const SG_Char *Filename); void _Write_Code (const CSG_String &FileName, const CSG_String &Code); void _Add_Opening (CSG_Rect r); void _Add_CheckBoxes (CSG_Parameter_Shapes_List *pList); void _Add_Shapes (CSG_Shapes *pLayer); bool _Add_Shape (CSG_Shape *pShape, int Fill_Color, int Line_Color, double Line_Width, double Point_Width); void _Add_Grid (CSG_Grid *pLayer); void _Add_ReferenceMap (CSG_Shapes *pIndexLayer, CSG_Rect r); void _Add_Label (const SG_Char* Label, CSG_Shape *pShape, double dSize, const SG_Char* Unit); const char * _Get_Opening_Code_1 (void); const char * _Get_Opening_Code_2 (void); const char * _Get_Code_1 (void); const char * _Get_Code_2 (void); const char * _Get_Code_3 (void); const char * _Get_Code_4 (void); const char * _Get_Code_5 (void); const char * _Get_Code_Closing_1 (void); const char * _Get_Code_CheckBox (void); const char * _Get_Code_MapApp (void); const char * _Get_Code_Timer (void); const char * _Get_Code_Slider (void); const char * _Get_Code_Helper (void); const char * _Get_Code_Buttons (void); const char * _Get_Code_Navigation_1 (void); const char * _Get_Code_Navigation_2 (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef _HEADER_INCLUDED__SAGA_GUI__svg_interactive_map_H saga-2.3.1/src/modules/docs/docs_html/CreateWebContent.cpp0000744000175000017500000001244412737416156024651 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CreateWebContent.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* PhotoLinks.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "CreateWebContent.h" CCreateWebContent::CCreateWebContent(void) { CSG_Parameter *pNode; //----------------------------------------------------- Parameters.Set_Name(_TL("Create Web Content")); Parameters.Set_Description(_TL("")); pNode = Parameters.Add_Shapes(NULL, "SHAPES", _TL("Shapes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Table_Field(pNode, "NAME", _TL("Name Field"), _TL("")); Parameters.Add_FilePath(NULL, "OUTPUTPATH", _TL("Path for HTML Files"), _TL(""), _TL(""), _TL(""), true, true); } CCreateWebContent::~CCreateWebContent(void) {} bool CCreateWebContent::On_Execute(void) { m_bDown = false; m_pShapes = Parameters("SHAPES")->asShapes(); m_iNameField = Parameters("NAME")->asInt(); m_sOutputPath = Parameters("OUTPUTPATH")->asString(); m_pShapes->Add_Field("HTML", SG_DATATYPE_String); m_iField = m_pShapes->Get_Field_Count() - 1; m_Pictures = new std::vector [m_pShapes->Get_Count()]; m_Links = new std::vector [m_pShapes->Get_Count()]; m_LinksDescription = new std::vector [m_pShapes->Get_Count()]; return true ; } bool CCreateWebContent::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { int i; int iIndex, iShape; CSG_Rect r; switch( Mode ){ case MODULE_INTERACTIVE_LDOWN: if( m_bDown == false ){ m_bDown = true; m_ptDown = ptWorld; }//if return true ; case MODULE_INTERACTIVE_LUP: if( m_bDown == true ){ m_bDown = false; r.Assign(m_ptDown.Get_X(), m_ptDown.Get_Y(), ptWorld.Get_X(), ptWorld.Get_Y()); if( r.Get_XRange() == 0.0 && r.Get_YRange() == 0.0 ){ m_pShapes->Select(m_pShapes->Get_Shape(m_ptDown), is_Shift()); }//if else{ m_pShapes->Select(r, is_Shift()); }//else DataObject_Update(m_pShapes, true); }//if return true; case MODULE_INTERACTIVE_RDOWN: CSG_String sFileName; CSG_Strings files; CSG_Parameters dlg_files; dlg_files.Add_FilePath(NULL, "FILES", _TL("Files"), _TL(""), _TL("Images|*.bmp;*.jpg;*.png;*.tif|HTML Files|*.htm|All Files|*.*"), NULL, false, false, true); if( Dlg_Parameters(&dlg_files, _TL("Add Link to Files")) && dlg_files("FILES")->asFilePath()->Get_FilePaths(files) ) { for (iShape = 0; iShape < m_pShapes->Get_Selection_Count(); iShape++){ iIndex = m_pShapes->Get_Selection(iShape)->Get_Index(); for (i = 0; i < files.Get_Count(); i++) { sFileName = "file://"; sFileName.Append((CSG_String)files[i]); if (SG_File_Cmp_Extension (files[i],SG_T("htm"))){ m_LinksDescription[iIndex].push_back(SG_File_Get_Name(files[i], true)); m_Links[iIndex].push_back(sFileName); }//if else if ( SG_File_Cmp_Extension (files[i],SG_T("bmp")) || SG_File_Cmp_Extension (files[i],SG_T("jpg")) || SG_File_Cmp_Extension (files[i],SG_T("png")) || SG_File_Cmp_Extension (files[i],SG_T("tif"))){ m_Pictures[iIndex].push_back(sFileName); }//else } sFileName = SG_File_Make_Path(m_sOutputPath.c_str(), m_pShapes->Get_Shape(iIndex)->asString(m_iNameField), SG_T("htm")); m_pShapes->Get_Shape(iIndex)->Set_Value(m_iField, sFileName); } } break; }//switch return false ; }//method bool CCreateWebContent::On_Execute_Finish(void){ int i,j; CSG_String sFileName; CSG_Doc_HTML HTMLDoc; for (i = 0; i < m_pShapes->Get_Count(); i++){ Set_Progress(i, m_pShapes->Get_Count()); const SG_Char **Pictures; if (m_Pictures[i].size() || m_Links[i].size()){ HTMLDoc.Open(m_pShapes->Get_Shape(i)->asString(m_iNameField)); Pictures = new const SG_Char *[m_Pictures[i].size()]; for (j = 0; j < m_Pictures[i].size(); j++){ Pictures[j] = m_Pictures[i].at(j).c_str(); }//for*/ HTMLDoc.AddThumbnails(Pictures, (int)m_Pictures[i].size(), 4); HTMLDoc.AddLineBreak(); for (j = 0; j < m_Links[i].size(); j++){ HTMLDoc.AddHyperlink(m_LinksDescription[i].at(j).c_str(), m_Links[i].at(j).c_str()); HTMLDoc.AddLineBreak(); }//for sFileName = SG_File_Make_Path(m_sOutputPath.c_str(), m_pShapes->Get_Shape(i)->asString(m_iNameField), SG_T("htm")); HTMLDoc.Save(sFileName); }//if }//for return true; }//method saga-2.3.1/src/modules/docs/docs_html/Makefile.in0000664000175000017500000005571712737447615023035 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/docs/docs_html ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libdocs_html_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libdocs_html_la_OBJECTS = CreateWebContent.lo doc_html.lo \ doc_svg.lo MLB_Interface.lo svg_interactive_map.lo libdocs_html_la_OBJECTS = $(am_libdocs_html_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdocs_html_la_SOURCES) DIST_SOURCES = $(libdocs_html_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libdocs_html.la libdocs_html_la_SOURCES = \ CreateWebContent.cpp\ doc_html.cpp\ doc_svg.cpp\ MLB_Interface.cpp\ svg_interactive_map.cpp\ CreateWebContent.h\ doc_html.h\ doc_svg.h\ MLB_Interface.h\ svg_interactive_map.h libdocs_html_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/docs/docs_html/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/docs/docs_html/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libdocs_html.la: $(libdocs_html_la_OBJECTS) $(libdocs_html_la_DEPENDENCIES) $(EXTRA_libdocs_html_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libdocs_html_la_OBJECTS) $(libdocs_html_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CreateWebContent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/doc_html.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/doc_svg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/svg_interactive_map.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/docs/docs_html/Makefile.am0000744000175000017500000000124512737416156023002 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libdocs_html.la libdocs_html_la_SOURCES =\ CreateWebContent.cpp\ doc_html.cpp\ doc_svg.cpp\ MLB_Interface.cpp\ svg_interactive_map.cpp\ CreateWebContent.h\ doc_html.h\ doc_svg.h\ MLB_Interface.h\ svg_interactive_map.h libdocs_html_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/docs/docs_html/doc_svg.cpp0000744000175000017500000002726012737416156023103 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: doc_svg.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // // // //-------------------------------------------------------// // // // doc_svg.cpp // // // // Copyright (C) 2005 by // // Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. // // // // This library is free software; you can redistribute // // it and/or modify it under the terms of the GNU Lesser // // General Public License as published by the Free // // Software Foundation, version 2.1 of the License. // // // // This library is distributed in the hope that it will // // be useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU Lesser General Public // // License for more details. // // // // You should have received a copy of the GNU Lesser // // General Public License along with this program; if // // not, write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "doc_svg.h" #include //--------------------------------------------------------- #define SVG_CODE_OPENING_1 SG_T("\n")\ SG_T("\n")\ SG_T("\n") #define SVG_CODE_CLOSING SG_T("") //--------------------------------------------------------- const SG_Char *g_Unit = SG_T(""); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Doc_SVG::CSG_Doc_SVG(){} CSG_Doc_SVG::~CSG_Doc_SVG(){} void CSG_Doc_SVG::Open(int iWidth, int iHeight) { m_sSVGCode.Append(SVG_CODE_OPENING_1); m_sSVGCode.Append(SG_Get_String(iWidth,0)); m_sSVGCode.Append(SG_T("\" height=\"")); m_sSVGCode.Append(SG_Get_String(iHeight,0)); m_sSVGCode.Append(SVG_CODE_OPENING_2); m_iWidth = iWidth; m_iHeight = iHeight; } bool CSG_Doc_SVG::Save(const SG_Char *Filename) { m_sSVGCode.Append(SVG_CODE_CLOSING); CSG_File Stream(Filename, SG_FILE_W, false); if( Stream.is_Open() ) { Stream.Printf(SG_T("%s"), m_sSVGCode.c_str()); return true; } return false; } void CSG_Doc_SVG::_AddAttribute(const SG_Char *Attribute, const SG_Char *Value) { m_sSVGCode.Append(Attribute); m_sSVGCode.Append(SG_T("=\"")); m_sSVGCode.Append(Value); m_sSVGCode.Append(SG_T("\" ")); } void CSG_Doc_SVG::_AddAttribute(const SG_Char *Attribute, int iValue) { _AddAttribute(Attribute, SG_Get_String(iValue, 0)); } void CSG_Doc_SVG::_AddAttribute(const SG_Char *Attribute, double dValue) { _AddAttribute(Attribute, SG_Get_String(dValue, 2)); } void CSG_Doc_SVG::Draw_Circle(double x, double y, double Radius, int Fill_Color, int Line_Color, double Line_Width) { CSG_String sWidth; m_sSVGCode.Append(SG_T("\n")); } void CSG_Doc_SVG::Draw_LinkedCircle(double x, double y, double Radius, const SG_Char *Link, int Fill_Color, int Line_Color, double Line_Width) { CSG_String sWidth; CSG_String sLink; m_sSVGCode.Append(SG_T("\n")); } void CSG_Doc_SVG::Draw_Line(double xa, double ya, double xb, double yb, double Width, int Color) { CSG_String sWidth; m_sSVGCode.Append(SG_T("\n")); } void CSG_Doc_SVG::Draw_Line(CSG_Points &Points, double Width, int Color) { int i; CSG_String sPoints; CSG_String sWidth; for (i = 0; i < Points.Get_Count(); i++) { sPoints.Append(SG_Get_String(Points.Get_X(i),2)); sPoints.Append(SG_T(",")); sPoints.Append(SG_Get_String(Points.Get_Y(i),2)); sPoints.Append(SG_T(" ")); } m_sSVGCode.Append(SG_T("\n")); } void CSG_Doc_SVG::Draw_Rectangle(double xa, double ya, double xb, double yb, int Fill_Color, int Line_Color, double Line_Width) { CSG_Points Points; Points.Add(xa, ya); Points.Add(xb, ya); Points.Add(xb, yb); Points.Add(xa, yb); Draw_Polygon(Points, Fill_Color, Line_Color, Line_Width); } void CSG_Doc_SVG::Draw_Rectangle(const CSG_Rect &r, int Fill_Color, int Line_Color, double Line_Width) { Draw_Rectangle(r.Get_XMin(), r.Get_YMin(), r.Get_XMax(), r.Get_YMax(), Fill_Color, Line_Color, Line_Width) ; } void CSG_Doc_SVG::Draw_Polygon(CSG_Points &Points, int Fill_Color, int Line_Color, double Line_Width) { if( Points.Get_Count() > 2 ) { int i; CSG_String sPoints; CSG_String sWidth; for (i = 0; i < Points.Get_Count(); i++) { sPoints.Append(SG_Get_String(Points.Get_X(i),2)); sPoints.Append(SG_T(",")); sPoints.Append(SG_Get_String(Points.Get_Y(i),2)); sPoints.Append(SG_T(" ")); } m_sSVGCode.Append(SG_T("\n")); } } void CSG_Doc_SVG::Draw_LinkedPolygon(CSG_Points &Points, const SG_Char* Link, int Fill_Color, int Line_Color, double Line_Width) { if( Points.Get_Count() > 2 ) { int i; CSG_String sPoints; CSG_String sWidth; CSG_String sLink; for (i = 0; i < Points.Get_Count(); i++) { sPoints.Append(SG_Get_String(Points.Get_X(i),2)); sPoints.Append(SG_T(",")); sPoints.Append(SG_Get_String(Points.Get_Y(i),2)); sPoints.Append(SG_T(" ")); } m_sSVGCode.Append(SG_T("\n")); } } void CSG_Doc_SVG::Draw_Text(double x, double y, const SG_Char *Text, int Color, const SG_Char* Font, double dSize, TSG_SVG_Alignment iAlignment) { CSG_String sAlignments[] = {SG_T(""), SG_T("middle"), SG_T("end")}; CSG_String sSize; sSize.Append(SG_Get_String(dSize,2)); sSize.Append(g_Unit); m_sSVGCode.Append(SG_T("\n")); m_sSVGCode.Append(Text); m_sSVGCode.Append(SG_T("")); } CSG_String CSG_Doc_SVG::_Get_SVGColor(int iColor) { CSG_String s; if (iColor == SG_COLOR_NONE) { return SG_T("none"); } else if (iColor == SG_COLOR_RANDOM) { s.Append(SG_T("rgb(")); s.Append(SG_Get_String((int)(255.0 * (double)rand() / (double)RAND_MAX),0)); s.Append(SG_T(",")); s.Append(SG_Get_String((int)(255.0 * (double)rand() / (double)RAND_MAX),0)); s.Append(SG_T(",")); s.Append(SG_Get_String((int)(255.0 * (double)rand() / (double)RAND_MAX),0)); s.Append(SG_T(")")); return s; } else { s.Append(SG_T("rgb(")); s.Append(SG_Get_String(SG_GET_R(iColor),0)); s.Append(SG_T(",")); s.Append(SG_Get_String(SG_GET_G(iColor),0)); s.Append(SG_T(",")); s.Append(SG_Get_String(SG_GET_B(iColor),0)); s.Append(SG_T(")")); return s; } } saga-2.3.1/src/modules/docs/docs_html/CreateWebContent.h0000744000175000017500000000355312737416156024317 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: CreateWebContent.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Photolinks.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #ifndef HEADER_INCLUDED__CreateWebContent_H #define HEADER_INCLUDED__CreateWebContent_H #include "doc_html.h" #include class CCreateWebContent : public CSG_Module_Interactive { public: CCreateWebContent(void); virtual ~CCreateWebContent(void); protected: virtual bool On_Execute(void); virtual bool On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); virtual bool On_Execute_Finish(void); private: bool m_bDown; CSG_Point m_ptDown; CSG_Shapes *m_pShapes; int m_iField, m_iNameField; CSG_String m_sOutputPath; std::vector *m_Pictures; std::vector *m_Links; std::vector *m_LinksDescription; }; #endif // #ifndef HEADER_INCLUDED__CreateWebContent_H saga-2.3.1/src/modules/docs/docs_html/MLB_Interface.h0000744000175000017500000000756612737416156023525 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__docs_html__mlb_interface_H #define HEADER_INCLUDED__docs_html__mlb_interface_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef docs_html_EXPORTS #define docs_html_EXPORT _SAGA_DLL_EXPORT #else #define docs_html_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__docs_html__mlb_interface_H saga-2.3.1/src/modules/docs/docs_html/MLB_Interface.cpp0000744000175000017500000001057712737416156024054 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // docs_html // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("HTML") ); case MLB_INFO_Category: return( _TL("Reports") ); case MLB_INFO_Author: return( SG_T("SAGA User Group (c) 2010") ); case MLB_INFO_Description: return( _TW( "Reports and document creation in Hypertext Mark Up Language (HTML) format." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Reports") ); } } //--------------------------------------------------------- #include "CreateWebContent.h" #include "svg_interactive_map.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CCreateWebContent ); case 1: return( new CSVG_Interactive_Map ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/docs/Makefile.in0000664000175000017500000004652612737447615021057 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/docs ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = docs_html docs_pdf all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/docs/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/docs/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/docs/Makefile.am0000744000175000017500000000003612737416156021023 0ustar00oconradoconrad00000000000000SUBDIRS = docs_html docs_pdf saga-2.3.1/src/modules/pointcloud/0000775000175000017500000000000012737740006020213 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/pointcloud/pointcloud_tools/0000775000175000017500000000000012737740006023613 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_attribute_calculator.h0000744000175000017500000001112612737416175030671 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_attribute_calculator.h // // // // Copyright (C) 2010 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_Attribute_Calculator_H #define HEADER_INCLUDED__PC_Attribute_Calculator_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Attribute_Calculator : public CSG_Module { public: CPC_Attribute_Calculator(void); virtual ~CPC_Attribute_Calculator(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: CSG_String Get_Formula(CSG_String sFormula, CSG_Table *pTable, int *Fields, int &nFields); virtual bool On_After_Execution(void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Attribute_Calculator_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_thinning_simple.h0000744000175000017500000001051312737416175027643 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_thinning_simple.h // // // // Copyright (C) 2010 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_Thinning_Simple_H #define HEADER_INCLUDED__PC_Thinning_Simple_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Thinning_Simple : public CSG_Module { public: CPC_Thinning_Simple(void); virtual ~CPC_Thinning_Simple(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Thinning_Simple_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_reclass_extract.h0000744000175000017500000001144112737416175027643 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_reclass_extract.h // // // // Copyright (C) 2009 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_Reclass_Extract_H #define HEADER_INCLUDED__PC_Reclass_Extract_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Reclass_Extract : public CSG_Module { public: CPC_Reclass_Extract(void); virtual ~CPC_Reclass_Extract(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: int m_Single; bool m_bExtract, m_bCreateAttrib; int m_AttrField; int m_iOrig; CSG_PointCloud *m_pInput, *m_pResult; void Reclass_Single (void); void Reclass_Range (void); bool Reclass_Table (bool bUser); void Set_Value (int i, double value); void Set_Display_Attributes (CSG_PointCloud *pPC, int iField, CSG_Parameters &sParms); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Reclass_Extract_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_merge.cpp0000744000175000017500000002331012737416175026105 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_merge.cpp // // // // Copyright (C) 2012 by // // Magnus Bremer // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: magnus.bremer@student.uibk.ac.at // // // // contact: Magnus Bremer // // Innrain 52 // // 6020 Innsbruck // // Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_merge.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Merge::CPC_Merge(void) { Set_Name (_TL("Merge Point Clouds")); Set_Author (SG_T("Magnus Bremer (c) 2012")); Set_Description (_TW("The module can be used to merge point clouds.\n" "The attribute fields of the merged point cloud resemble those " "of the main point cloud. In order to merge the attributes of the " "additional point cloud layers, these must be consistent " "(field name and type) with the main point cloud. Missing " "attribute values are set to NoData.\n\n" )); Parameters.Add_PointCloud( NULL , "PC_IN" , _TL("Main Point Cloud"), _TL("Main layer. The output layer will have the same fields in the attribute table as this layer."), PARAMETER_INPUT ); Parameters.Add_PointCloud_List( NULL , "PC_LAYERS" , _TL("Additional Point Clouds"), _TL("Additional point clouds to merge with main point cloud."), PARAMETER_INPUT ); Parameters.Add_PointCloud( NULL , "PC_OUT" , _TL("Merged Point Cloud"), _TL("The merged point cloud."), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "ADD_IDENTIFIER" , _TL("Add Identifier"), _TL("Add unique identifier attribute field to output, ID resembles processing order."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( Parameters("ADD_IDENTIFIER") , "START_VALUE" , _TL("Start Value"), _TL("The start value to use for the identifier."), PARAMETER_TYPE_Int, 0 ); } //--------------------------------------------------------- CPC_Merge::~CPC_Merge(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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 FieldNames; std::vector 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; iFieldGet_Attribute_Count(); iField++) { FieldNames.push_back(pMain->Get_Attribute_Name(iField)); FieldTypes.push_back(pMain->Get_Attribute_Type(iField)); } for(int i=0; iGet_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; iFieldGet_Attribute_Count(); iField++) { switch (pMain->Get_Attribute_Type(iField)) { default: pResult->Set_Attribute(iAccept, iField, pMain->Get_Attribute(i, iField)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: CSG_String sAttr; pMain->Get_Attribute(i, iField, sAttr); pResult->Set_Attribute(iAccept, iField, sAttr); break; } } 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; iLayerGet_Count(); iLayer++) { if( (pAdd = pPointCloudList->asPointCloud(iLayer)) != NULL ) { if( pAdd->Get_Type() == pMain->Get_Type() ) { pAdd = pPointCloudList->asPointCloud(iLayer); std::vector FieldMapping(FieldNames.size(), -1); // pMain to pAdd for(int iField=0; iFieldGet_Attribute_Count(); iField++) { CSG_String ThisField = pAdd->Get_Attribute_Name(iField); for(int j=0; jGet_Attribute_Type(iField) == FieldTypes[j] ) { FieldMapping[j] = iField; break; } } } } for(int i=0; iGet_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; iFieldGet_Attribute_Count(); iField++) { if( FieldMapping[iField] > -1 ) { switch (pAdd->Get_Attribute_Type(iField)) { default: pResult->Set_Attribute(iAccept, iField, pAdd->Get_Attribute(i, FieldMapping[iField])); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: CSG_String sAttr; pAdd->Get_Attribute(i, FieldMapping[iField], sAttr); pResult->Set_Attribute(iAccept, iField, sAttr); break; } } 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 ); } //--------------------------------------------------------- int CPC_Merge::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("ADD_IDENTIFIER")) ) { pParameters->Get_Parameter("START_VALUE")->Set_Enabled(pParameter->asBool()); } //----------------------------------------------------- return (1); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //---------------------------------------------------------saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_drop_attribute.h0000744000175000017500000001050112737416175027500 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_drop_attribute.h // // // // Copyright (C) 2010 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_Drop_Attribute_H #define HEADER_INCLUDED__PC_Drop_Attribute_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Drop_Attribute : public CSG_Module { public: CPC_Drop_Attribute(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); virtual bool On_After_Execution (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Drop_Attribute_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_from_grid.cpp0000744000175000017500000001273312737416175026765 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_grid.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_from_grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_From_Grid::CPC_From_Grid(void) { //----------------------------------------------------- Set_Name (_TL("Point Cloud from Grid Points")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Z Value"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Additional Values"), _TL(""), PARAMETER_INPUT_OPTIONAL, false ); Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_From_Grid::On_Execute(void) { int x, y, i; TSG_Point p; CSG_Grid *pGrid; CSG_Parameter_Grid_List *pGrids; CSG_PointCloud *pPoints; //----------------------------------------------------- pGrid = Parameters("GRID") ->asGrid(); pGrids = Parameters("GRIDS") ->asGridList(); pPoints = Parameters("POINTS") ->asPointCloud(); pPoints->Create(); pPoints->Set_Name(pGrid->Get_Name()); for(i=0; iGet_Count(); i++) { pPoints->Add_Field(pGrids->asGrid(i)->Get_Name(), SG_DATATYPE_Float); } //----------------------------------------------------- for(y=0, p.y=Get_YMin(); yis_NoData(x, y) ) { pPoints->Add_Point(p.x, p.y, pGrid->asDouble(x, y)); for(i=0; iGet_Count(); i++) { pPoints->Set_Value(3 + i, pGrids->asGrid(i)->Get_Value(p)); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_from_table.cpp0000744000175000017500000001567512737416175027137 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_table.cpp // // // // Copyright (C) 2015 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_from_table.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_From_Table::CPC_From_Table(void) { Set_Name (_TL("Point Cloud from Table")); Set_Author (SG_T("V. Wichmann (c) 2015")); Set_Description (_TW( "This tool allows one to create a point cloud from a table.\n\n" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Table( NULL , "TAB_IN" ,_TL("Table"), _TL("The input table."), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD_X" , _TL("X"), _TL("The attribute field with the x-coordinate.") ); Parameters.Add_Table_Field( pNode , "FIELD_Y" , _TL("Y"), _TL("The attribute field with the y-coordinate.") ); Parameters.Add_Table_Field( pNode , "FIELD_Z" , _TL("Z"), _TL("The attribute field with the z-coordinate.") ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("The attribute fields to convert, optional.") ); Parameters.Add_PointCloud( NULL , "PC_OUT" ,_TL("Point Cloud"), _TL("The output point cloud."), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_From_Table::On_Execute(void) { CSG_Table *pTable; int iFieldX, iFieldY, iFieldZ; int *Features, nFeatures; CSG_PointCloud *pPoints; //----------------------------------------------------- pTable = Parameters("TAB_IN")->asTable(); iFieldX = Parameters("FIELD_X")->asInt(); iFieldY = Parameters("FIELD_Y")->asInt(); iFieldZ = Parameters("FIELD_Z")->asInt(); Features = (int *)Parameters("FIELDS")->asPointer(); nFeatures = Parameters("FIELDS")->asInt (); pPoints = Parameters("PC_OUT")->asPointCloud(); //----------------------------------------------------- pPoints->Create(); pPoints->Set_Name(CSG_String::Format(SG_T("%s_pc"), pTable->Get_Name())); for( int j=0; jGet_Field_Type(Features[j]) ) { case SG_DATATYPE_Undefined: case SG_DATATYPE_Binary: SG_UI_Msg_Add_Error(_TL("Undefined or binary attribute field types are not supported!")); return( false ); case SG_DATATYPE_Date: case SG_DATATYPE_String: Data_Type = SG_DATATYPE_String; break; default: Data_Type = pTable->Get_Field_Type(Features[j]); break; } pPoints->Add_Field(pTable->Get_Field_Name(Features[j]), Data_Type); } //----------------------------------------------------- Process_Set_Text(_TL("Converting ...")); for( int iRecord=0; iRecordGet_Record_Count() && Set_Progress(iRecord, pTable->Get_Record_Count()); iRecord++ ) { pPoints->Add_Point(pTable->Get_Record(iRecord)->asDouble(iFieldX), pTable->Get_Record(iRecord)->asDouble(iFieldY), pTable->Get_Record(iRecord)->asDouble(iFieldZ)); for( int j=0; jGet_Attribute_Type(j) ) { case SG_DATATYPE_String: pPoints->Set_Value(iRecord, j + 3, pTable->Get_Record(iRecord)->asString(Features[j])); break; default: pPoints->Set_Value(iRecord, j + 3, pTable->Get_Record(iRecord)->asDouble(Features[j])); break; } } } //------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_reclass_extract.cpp0000744000175000017500000005751112737416175030206 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_reclass_extract.cpp // // // // Copyright (C) 2009 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_reclass_extract.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Reclass_Extract::CPC_Reclass_Extract(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name(_TL("Point Cloud Reclassifier / Subset Extractor")); Set_Author(SG_T("Volker Wichmann (c) 2009, LASERDATA GmbH")); Set_Description (_TW( "The module can be used to either reclassify a Point Cloud attribute or to extract " "a subset of a Point Cloud based on the values of an attribute.\n\n" "The module provides three different options:\n" "(a) reclassification of (or extraction based on) single values,\n" "(b) reclassification of (or extraction based on) a range of values and\n" "(c) reclassification of (or extraction based on) value ranges specified in a lookup table.\n\n" "Each of these three options provides it's own parameters. The 'new value' parameters are " "irrelevant in case a subset is extracted.\n\n" "In addition to these settings, two special cases ('NoData values' and 'other values' not " "included in the parameter setup) are supported:\n" "In mode (a) and (b) the 'NoData option' is evaluated before the method settings, in mode " "(c) the option is evaluated only if the NoData value ins't included in the lookup table.\n" "The 'other values' option is always evaluated after checking the method settings.\n\n") ); //----------------------------------------------------- Parameters.Add_PointCloud( NULL , "INPUT" ,_TL("Point Cloud"), _TL("Point Cloud to reclassify/extract"), PARAMETER_INPUT ); Parameters.Add_Table_Field( Parameters("INPUT"), "ATTRIB", _TL("Attribute"), _TL("Attribute to process."), false ); Parameters.Add_PointCloud( NULL , "RESULT" , _TL("Result"), _TL("Reclassified or extracted Point Cloud."), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "MODE" , _TL("Mode of operation"), _TL("Choose whether to reclassify a Point Cloud or to extract a subset from a Point Cloud."), _TL("Reclassify|Extract Subset|"), 0 ); Parameters.Add_Value( NULL , "CREATE_ATTRIB" , _TL("Create new Attribute"), _TL("Check this to create a new attribute with the reclassification result. If unchecked, the existing attribute is updated."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL("Select the desired method: 1. a single value or a range defined by a single value is reclassified, 2. a range of values is reclassified, 3. the lookup table is used to reclassify the grid."), _TL("single|range|simple table|user supplied table|"), 0 ); //----------------------------------------------------- Parameters.Add_Value( NULL , "OLD" , _TL("old value"), _TL("Value to reclassify."), PARAMETER_TYPE_Double, 0 ); Parameters.Add_Value( NULL , "NEW" , _TL("new value"), _TL("New value."), PARAMETER_TYPE_Double, 1 ); Parameters.Add_Choice( NULL , "SOPERATOR" , _TL("operator"), _TL("Select the desired operator (<;.;=; >;.); it is possible to define a range above or below the old value."), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("="), _TL("<"), _TL("<="), _TL(">="), _TL(">") ), 0 ); //----------------------------------------------------- Parameters.Add_Value( NULL , "MIN" , _TL("minimum value"), _TL("Minimum value of the range to be reclassified."), PARAMETER_TYPE_Double, 0 ); Parameters.Add_Value( NULL , "MAX" , _TL("maximum value"), _TL("Maximum value of the range to be reclassified."), PARAMETER_TYPE_Double, 10 ); Parameters.Add_Value( NULL , "RNEW" , _TL("new value"), _TL("new value"), PARAMETER_TYPE_Double, 5 ); Parameters.Add_Choice( NULL , "ROPERATOR" , _TL("operator"), _TL("Select operator: eg. min < value < max."), CSG_String::Format(SG_T("%s|%s|"), _TL("<="), _TL("<") ), 0 ); //----------------------------------------------------- Parameters.Add_FixedTable( NULL , "RETAB" , _TL("Lookup Table"), _TL("Lookup table used in method \"table\"") ); Parameters.Add_Choice( NULL , "TOPERATOR" , _TL("operator"), _TL("Select the desired operator (min < value < max; min . value < max; min .value . max; min < value . max)."), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("min <= value < max"), _TL("min <= value <= max"), _TL("min < value <= max"), _TL("min < value < max") ), 0 ); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "RETAB_2" , _TL("Lookup Table"), _TL("Lookup table used in method \"user supplied table\""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Table_Field( pNode , "F_MIN" , _TL("minimum value"), _TL("") ); Parameters.Add_Table_Field( pNode , "F_MAX" , _TL("maximum value"), _TL("") ); Parameters.Add_Table_Field( pNode , "F_CODE" , _TL("new value"), _TL("") ); //----------------------------------------------------- pNode = Parameters.Add_Node( NULL, "OPTIONS" , _TL("Special cases"), _TL("Parameter settings for No-Data and all other values.") ); Parameters.Add_Value( pNode , "NODATAOPT" , _TL("no data values"), _TL("Use this option to reclassify No-Data values independently of the method settings."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( Parameters("NODATAOPT") , "NODATA" , _TL("new value"), _TL("new value"), PARAMETER_TYPE_Double, 0 ); Parameters.Add_Value( pNode , "OTHEROPT" , _TL("other values"), _TL("Use this option to reclassify all other values that are not specified in the options above."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( Parameters("OTHEROPT") , "OTHERS" , _TL("new value"), _TL("new value"), PARAMETER_TYPE_Double, 0 ); //----------------------------------------------------- CSG_Table *pLookup; CSG_Table_Record *pRecord; pLookup = Parameters("RETAB")->asTable(); pLookup->Add_Field(_TL("minimum") , SG_DATATYPE_Double); pLookup->Add_Field(_TL("maximum") , SG_DATATYPE_Double); pLookup->Add_Field(_TL("new") , SG_DATATYPE_Double); pRecord = pLookup->Add_Record(); pRecord->Set_Value(0, 0.0); pRecord->Set_Value(1, 10.0); pRecord->Set_Value(2, 1.0); pRecord = pLookup->Add_Record(); pRecord->Set_Value(0, 10.0); pRecord->Set_Value(1, 20.0); pRecord->Set_Value(2, 2.0); } //--------------------------------------------------------- CPC_Reclass_Extract::~CPC_Reclass_Extract(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Reclass_Extract::On_Execute(void) { int method; CSG_Parameters sParms; m_pInput = Parameters("INPUT")->asPointCloud(); m_pResult = Parameters("RESULT")->asPointCloud(); method = Parameters("METHOD")->asInt(); m_AttrField = Parameters("ATTRIB")->asInt(); m_bExtract = Parameters("MODE")->asInt() == 0 ? false : true; m_bCreateAttrib = Parameters("CREATE_ATTRIB")->asBool(); m_pResult->Create(m_pInput); if (m_bExtract) m_pResult->Set_Name(CSG_String::Format(SG_T("%s_subset_%s"), m_pInput->Get_Name(), m_pInput->Get_Field_Name(m_AttrField))); else { m_pResult->Set_Name(CSG_String::Format(SG_T("%s_reclass_%s"), m_pInput->Get_Name(), m_pInput->Get_Field_Name(m_AttrField))); if( m_bCreateAttrib ) m_pResult->Add_Field(CSG_String::Format(SG_T("%s_reclass"), m_pInput->Get_Field_Name(m_AttrField)), m_pInput->Get_Field_Type(m_AttrField)); } m_iOrig = 0; // counter of unchanged points //----------------------------------------------------- switch( method ) { case 0: Reclass_Single(); break; case 1: Reclass_Range(); break; case 2: if( Reclass_Table(false) ) break; else return( false ); case 3: if( Reclass_Table(true) ) break; else return( false ); default: break; } //----------------------------------------------------- DataObject_Update(m_pResult); DataObject_Get_Parameters(m_pResult, sParms); if (m_bExtract) Set_Display_Attributes(m_pResult, 2, sParms); else { if( m_bCreateAttrib ) Set_Display_Attributes(m_pResult, m_pResult->Get_Field_Count()-1, sParms); else Set_Display_Attributes(m_pResult, m_AttrField, sParms); } if( m_bExtract) SG_UI_Msg_Add(CSG_String::Format(_TL("%d points out of %d extracted."), m_pInput->Get_Point_Count()-m_iOrig, m_pInput->Get_Point_Count()), true); else SG_UI_Msg_Add(CSG_String::Format(_TL("%d points out of %d reclassified."), m_pInput->Get_Point_Count()-m_iOrig, m_pInput->Get_Point_Count()), true); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPC_Reclass_Extract::Reclass_Range(void) { bool otherOpt, noDataOpt, floating; int opera; double minValue, maxValue, value, others, noData, noDataValue, newValue; minValue = Parameters("MIN")->asDouble(); maxValue = Parameters("MAX")->asDouble(); newValue = Parameters("RNEW")->asDouble(); others = Parameters("OTHERS")->asDouble(); noData = Parameters("NODATA")->asDouble(); opera = Parameters("ROPERATOR")->asInt(); otherOpt = m_bExtract ? false : Parameters("OTHEROPT")->asBool(); noDataOpt = m_bExtract ? false : Parameters("NODATAOPT")->asBool(); noDataValue = m_pInput->Get_NoData_Value(); if( (m_pInput->Get_Field_Type(m_AttrField) == SG_DATATYPE_Double) || (m_pInput->Get_Field_Type(m_AttrField) == SG_DATATYPE_Float) ) floating = true; else floating = false; for (int i=0; iGet_Point_Count() && Set_Progress(i, m_pInput->Get_Point_Count()); i++) { if( floating == true ) value = m_pInput->Get_Value(i, m_AttrField); else value = (int)m_pInput->Get_Value(i, m_AttrField); if( opera == 0 ) // operator <= { if( noDataOpt == true && value == noDataValue ) // noData option Set_Value(i, noData); else if( minValue <= value && value <= maxValue ) // reclass old range Set_Value(i, newValue); else if( otherOpt == true && value != noDataValue ) // other values option Set_Value(i, others); else { if (!m_bExtract) Set_Value(i, value); // or original value m_iOrig++; } } if( opera == 1 ) // operator < { if( noDataOpt == true && value == noDataValue ) // noData option Set_Value(i, noData); else if( minValue < value && value < maxValue ) // reclass old range Set_Value(i, newValue); else if( otherOpt == true && value != noDataValue ) // other values option Set_Value(i, others); else { if (!m_bExtract) Set_Value(i, value); // or original value m_iOrig++; } } } return; } //--------------------------------------------------------- void CPC_Reclass_Extract::Reclass_Single(void) { bool otherOpt, noDataOpt, floating; int opera; double oldValue, newValue, value, others, noData, noDataValue; oldValue = Parameters("OLD")->asDouble(); newValue = Parameters("NEW")->asDouble(); others = Parameters("OTHERS")->asDouble(); noData = Parameters("NODATA")->asDouble(); opera = Parameters("SOPERATOR")->asInt(); otherOpt = m_bExtract ? false : Parameters("OTHEROPT")->asBool(); noDataOpt = m_bExtract ? false : Parameters("NODATAOPT")->asBool(); noDataValue = m_pInput->Get_NoData_Value(); if( (m_pInput->Get_Field_Type(m_AttrField) == SG_DATATYPE_Double) || (m_pInput->Get_Field_Type(m_AttrField) == SG_DATATYPE_Float) ) floating = true; else floating = false; for (int i=0; iGet_Point_Count() && Set_Progress(i, m_pInput->Get_Point_Count()); i++) { if( floating == true ) value = m_pInput->Get_Value(i, m_AttrField); else value = (int)m_pInput->Get_Value(i, m_AttrField); if( opera == 0 ) // operator = { if( noDataOpt == true && value == noDataValue ) // noData option Set_Value(i, noData); else if( value == oldValue ) // reclass old value Set_Value(i, newValue); else if( otherOpt == true && value != noDataValue ) // other values option Set_Value(i, others); else { if (!m_bExtract) Set_Value(i, value); // or original value m_iOrig++; } } if( opera == 1 ) // operator < { if( noDataOpt == true && value == noDataValue ) // noData option Set_Value(i, noData); else if( value < oldValue ) // reclass old value Set_Value(i, newValue); else if( otherOpt == true && value != noDataValue ) // other values option Set_Value(i, others); else { if (!m_bExtract) Set_Value(i, value); // or original value m_iOrig++; } } if( opera == 2 ) // operator <= { if( noDataOpt == true && value == noDataValue ) // noData option Set_Value(i, noData); else if( value <= oldValue ) // reclass old value Set_Value(i, newValue); else if( otherOpt == true && value != noDataValue ) // other values option Set_Value(i, others); else { if (!m_bExtract) Set_Value(i, value); // or original value m_iOrig++; } } if( opera == 3 ) // operator >= { if( noDataOpt == true && value == noDataValue ) // noData option Set_Value(i, noData); else if( value >= oldValue ) // reclass old value Set_Value(i, newValue); else if( otherOpt == true && value != noDataValue ) // other values option Set_Value(i, others); else { if (!m_bExtract) Set_Value(i, value); // or original value m_iOrig++; } } if( opera == 4 ) // operator > { if( noDataOpt == true && value == noDataValue ) // noData option Set_Value(i, noData); else if( value > oldValue ) // reclass old value Set_Value(i, newValue); else if( otherOpt == true && value != noDataValue ) // other values option Set_Value(i, others); else { if (!m_bExtract) Set_Value(i, value); // or original value m_iOrig++; } } } return; } //--------------------------------------------------------- bool CPC_Reclass_Extract::Reclass_Table(bool bUser) { bool set, otherOpt, noDataOpt; int opera, field_Min, field_Max, field_Code; double value, others, noData, noDataValue; CSG_Table *pReTab; CSG_Table_Record *pRecord = NULL; if( bUser ) { pReTab = Parameters("RETAB_2") ->asTable(); field_Min = Parameters("F_MIN") ->asInt(); field_Max = Parameters("F_MAX") ->asInt(); field_Code = Parameters("F_CODE") ->asInt(); } else { pReTab = Parameters("RETAB") ->asTable(); field_Min = 0; field_Max = 1; field_Code = 2; } others = Parameters("OTHERS")->asDouble(); noData = Parameters("NODATA")->asDouble(); opera = Parameters("TOPERATOR")->asInt(); otherOpt = m_bExtract ? false : Parameters("OTHEROPT")->asBool(); noDataOpt = m_bExtract ? false : Parameters("NODATAOPT")->asBool(); noDataValue = m_pInput->Get_NoData_Value(); if( pReTab == NULL ) { Error_Set(_TL("You must specify a reclass table with a minimium (field 1), a maximum (field 2) and a code value (field 3)!\n")); return( false ); } if( pReTab->Get_Record_Count() == 0 ) { Error_Set(_TL("You must specify a reclass table with a minimium of one record!\n")); return( false ); } for (int i=0; iGet_Point_Count() && Set_Progress(i, m_pInput->Get_Point_Count()); i++) { value = m_pInput->Get_Value(i, m_AttrField); set = false; for(int iRecord=0; iRecordGet_Record_Count(); iRecord++) // reclass { pRecord = pReTab->Get_Record(iRecord); if( opera == 0 ) // min <= value < max { if( value >= pRecord->asDouble(field_Min) && value < pRecord->asDouble(field_Max) ) { Set_Value(i, pRecord->asDouble(field_Code)); set = true; break; } } else if( opera == 1 ) // min <= value <= max { if( value >= pRecord->asDouble(field_Min) && value <= pRecord->asDouble(field_Max) ) { Set_Value(i, pRecord->asDouble(field_Code)); set = true; break; } } else if( opera == 2 ) // min < value <= max { if( value > pRecord->asDouble(field_Min) && value <= pRecord->asDouble(field_Max) ) { Set_Value(i, pRecord->asDouble(field_Code)); set = true; break; } } else if( opera == 3 ) // min < value < max { if( value > pRecord->asDouble(field_Min) && value < pRecord->asDouble(field_Max) ) { Set_Value(i, pRecord->asDouble(field_Code)); set = true; break; } } } if( set == false ) { if( noDataOpt == true && value == noDataValue ) // noData option Set_Value(i, noData); else if( otherOpt == true && value != noDataValue) // other values option Set_Value(i, others); else { if (!m_bExtract) Set_Value(i, value); // or original value m_iOrig++; } } } return (true); } //--------------------------------------------------------- void CPC_Reclass_Extract::Set_Value(int i, double value) { m_pResult->Add_Point(m_pInput->Get_X(i), m_pInput->Get_Y(i), m_pInput->Get_Z(i)); for (int j=0; jGet_Attribute_Count(); j++) { switch (m_pInput->Get_Attribute_Type(j)) { default: m_pResult->Set_Attribute(j, m_pInput->Get_Attribute(i, j)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: CSG_String sAttr; m_pInput->Get_Attribute(i, j, sAttr); m_pResult->Set_Attribute(j, sAttr); break; } } if (!m_bExtract) { if (m_bCreateAttrib) m_pResult->Set_Value(m_pResult->Get_Field_Count()-1, value); else m_pResult->Set_Value(m_AttrField, value); } return; } //--------------------------------------------------------- void CPC_Reclass_Extract::Set_Display_Attributes(CSG_PointCloud *pPC, int iField, CSG_Parameters &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); // highest z sParms("COLORS_TYPE")->Set_Value(2); // graduated color sParms("METRIC_COLORS")->asColors()->Set_Count(255); // number of colors sParms("METRIC_ATTRIB")->Set_Value(iField); // attrib sParms("METRIC_ZRANGE")->asRange()->Set_Range(pPC->Get_Minimum(iField), pPC->Get_Maximum(iField)); } DataObject_Set_Parameters(pPC, sParms); DataObject_Update(pPC); return; } //--------------------------------------------------------- int CPC_Reclass_Extract::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("METHOD")) || !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("MODE")) ) { int iMode = pParameters->Get_Parameter("MODE")->asInt(); // 0 == reclassify, 1 == extract int Value = pParameters->Get_Parameter("METHOD")->asInt(); pParameters->Get_Parameter("CREATE_ATTRIB")->Set_Enabled(iMode == 0); // single pParameters->Get_Parameter("OLD" )->Set_Enabled(Value == 0); pParameters->Get_Parameter("NEW" )->Set_Enabled(Value == 0 && iMode == 0); pParameters->Get_Parameter("SOPERATOR" )->Set_Enabled(Value == 0); // range pParameters->Get_Parameter("MIN" )->Set_Enabled(Value == 1); pParameters->Get_Parameter("MAX" )->Set_Enabled(Value == 1); pParameters->Get_Parameter("RNEW" )->Set_Enabled(Value == 1 && iMode == 0); pParameters->Get_Parameter("ROPERATOR" )->Set_Enabled(Value == 1); // simple table pParameters->Get_Parameter("RETAB" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("TOPERATOR" )->Set_Enabled(Value == 2); // user supplied table pParameters->Get_Parameter("RETAB_2" )->Set_Enabled(Value == 3); //pParameters->Get_Parameter("F_MIN" )->Set_Enabled(Value == 3); //pParameters->Get_Parameter("F_MAX" )->Set_Enabled(Value == 3); //pParameters->Get_Parameter("F_CODE" )->Set_Enabled(Value == 3); // other options pParameters->Get_Parameter("NODATAOPT" )->Set_Enabled(iMode == 0); pParameters->Get_Parameter("OTHEROPT" )->Set_Enabled(iMode == 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("NODATAOPT")) ) { pParameters->Get_Parameter("NODATA" )->Set_Enabled(pParameter->asInt() > 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("OTHEROPT")) ) { pParameters->Get_Parameter("OTHERS" )->Set_Enabled(pParameter->asInt() > 0); } //----------------------------------------------------- return (1); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_to_grid.h0000744000175000017500000001025012737416175026101 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_to_grid.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_To_Grid_H #define HEADER_INCLUDED__PC_To_Grid_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_To_Grid : public CSG_Module { public: CPC_To_Grid(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Conversion") ); } protected: virtual bool On_Execute (void); private: int m_Aggregation; CSG_Grid *m_pGrid, *m_pCount; void Set_Value (int x, int y, double z, int Count, double value, CSG_Grid *pGrid); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_To_Grid_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_to_grid.cpp0000744000175000017500000002056112737416175026442 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_to_grid.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_to_grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_To_Grid::CPC_To_Grid(void) { //----------------------------------------------------- Set_Name (_TL("Point Cloud to Grid")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Z Value"), _TL("") ); Parameters.Add_Grid_Output( NULL , "COUNT" , _TL("Number of Points in Cell"), _TL("") ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Attributes"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("only z"), _TL("all attributes") ), 0 ); Parameters.Add_Choice( NULL , "AGGREGATION" , _TL("Aggregation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("first value"), _TL("last value"), _TL("mean value"), _TL("lowest z"), _TL("highest z") ), 0 ); Parameters.Add_Value( NULL , "CELLSIZE" , _TL("Cellsize"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_To_Grid::On_Execute(void) { int x, y, iField, iGrid; CSG_Grid_System System; CSG_Parameter_Grid_List *pGrids; CSG_PointCloud *pPoints; pPoints = Parameters("POINTS") ->asPointCloud(); pGrids = Parameters("GRIDS") ->asGridList(); m_Aggregation = Parameters("AGGREGATION") ->asInt(); //----------------------------------------------------- System.Assign(Parameters("CELLSIZE")->asDouble(), pPoints->Get_Extent()); //----------------------------------------------------- pGrids->Del_Items(); if( Parameters("OUTPUT")->asInt() != 0 ) { for(iField=3; iFieldGet_Field_Count(); iField++) { pGrids->Add_Item(SG_Create_Grid(System, SG_DATATYPE_Float)); pGrids->asGrid(iField - 3)->Set_Name(CSG_String::Format(SG_T("%s - %s"), pPoints->Get_Name(), pPoints->Get_Field_Name(iField))); } } Parameters("GRID") ->Set_Value(m_pGrid = SG_Create_Grid(System, SG_DATATYPE_Float)); Parameters("COUNT") ->Set_Value(m_pCount = SG_Create_Grid(System, SG_DATATYPE_Int)); m_pGrid ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), pPoints->Get_Field_Name(2))); m_pCount ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Points per Cell"))); m_pCount ->Set_NoData_Value(0.0); //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { pPoints->Set_Cursor(iPoint); if( System.Get_World_to_Grid(x, y, pPoints->Get_X(), pPoints->Get_Y()) ) { int n = m_pCount->asInt(x, y); double z = pPoints->Get_Z(); for(iGrid=0; iGridGet_Count(); iGrid++) { Set_Value(x, y, z, n, pPoints->Get_Value(iGrid + 3), pGrids->asGrid(iGrid)); } Set_Value(x, y, z, n, z, m_pGrid); m_pCount->Add_Value(x, y, 1); } } //----------------------------------------------------- for(y=0; yasInt(x, y); switch( n ) { case 0: m_pGrid->Set_NoData(x, y); for(iGrid=0; iGridGet_Count(); iGrid++) { pGrids->asGrid(iGrid)->Set_NoData(x, y); } break; case 1: break; default: if( m_Aggregation == 2 ) // mean value { m_pGrid->Mul_Value(x, y, 1.0 / n); for(iGrid=0; iGridGet_Count(); iGrid++) { pGrids->asGrid(iGrid)->Mul_Value(x, y, 1.0 / n); } } break; } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CPC_To_Grid::Set_Value(int x, int y, double z, int Count, double value, CSG_Grid *pGrid) { switch( m_Aggregation ) { case 0: // first value if( Count == 0 ) { pGrid->Set_Value(x, y, value); } break; case 1: // last value pGrid->Set_Value(x, y, value); break; case 2: // mean value pGrid->Add_Value(x, y, value); break; case 3: // lowest z if( Count == 0 || z < m_pGrid->asDouble(x, y) ) { pGrid->Set_Value(x, y, value); } break; case 4: // highest z if( Count == 0 || z > m_pGrid->asDouble(x, y) ) { pGrid->Set_Value(x, y, value); } break; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_to_shapes.h0000744000175000017500000001001412737416176026436 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_to_shapes.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_To_Shapes_H #define HEADER_INCLUDED__PC_To_Shapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_To_Shapes : public CSG_Module { public: CPC_To_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Conversion") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_To_Shapes_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_cut.cpp0000744000175000017500000004561712737416175025617 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_cut.cpp // // // // Copyright (C) 2009-10 by // // Olaf Conrad // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_cut.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Cut::CPC_Cut(void) { CSG_Parameters *pParameters; //----------------------------------------------------- Set_Name (_TL("Point Cloud Cutter")); Set_Author (SG_T("O. Conrad, V. Wichmann (c) 2009-15")); Set_Description (_TW( "This tool allows one to extract subsets from one or several " "point cloud datasets. The area-of-interest " "is defined either by bounding box coordinates, the extent of a grid system or " "a shapes layer, or by polygons of a shapes layer. Note that the latter " "does not support the inverse selection.\n\n" )); //----------------------------------------------------- Parameters.Add_PointCloud_List( NULL , "POINTS" , _TL("Points"), _TL("One or several input point cloud datasets to cut."), PARAMETER_INPUT ); Parameters.Add_PointCloud_List( NULL , "CUT" , _TL("Cut"), _TL("The cutted output point cloud dataset(s)."), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "AREA" , _TL("Choose Cut from ..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("User Defined Extent"), _TL("Grid System Extent"), _TL("Shapes Extent"), _TL("Polygons") ), 0 ); Parameters.Add_Value( NULL , "INVERSE" , _TL("Inverse"), _TL("Invert selection."), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- // User Defined Extent pParameters = Add_Parameters ( "USER" , _TL("User Defined Extent"), _TL("")); pParameters ->Add_Value (NULL, "XMIN" , _TL("Left") , _TL(""), PARAMETER_TYPE_Double); pParameters ->Add_Value (NULL, "XMAX" , _TL("Right") , _TL(""), PARAMETER_TYPE_Double); pParameters ->Add_Value (NULL, "YMIN" , _TL("Bottom") , _TL(""), PARAMETER_TYPE_Double); pParameters ->Add_Value (NULL, "YMAX" , _TL("Top") , _TL(""), PARAMETER_TYPE_Double); //----------------------------------------------------- // Grid System Extent pParameters = Add_Parameters ( "GRID" , _TL("Grid System Extent") , _TL("")); pParameters ->Add_Grid_System (NULL, "GRID" , _TL("Grid System") , _TL("")); //----------------------------------------------------- // Shapes Extent pParameters = Add_Parameters ( "EXTENT" , _TL("Shapes Extent") , _TL("")); pParameters ->Add_Shapes (NULL, "EXTENT" , _TL("Shapes Extent") , _TL(""), PARAMETER_INPUT_OPTIONAL); //----------------------------------------------------- // Polygons pParameters = Add_Parameters ( "POLYGONS" , _TL("Polygons") , _TL("")); pParameters ->Add_Shapes (NULL, "POLYGONS" , _TL("Polygons") , _TL(""), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Polygon); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Cut::On_Execute(void) { CSG_Parameter_PointCloud_List *pPointsList = Parameters("POINTS") ->asPointCloudList(); CSG_Parameter_PointCloud_List *pCutList = Parameters("CUT") ->asPointCloudList(); switch( Parameters("AREA")->asInt() ) { //----------------------------------------------------- case 0: // User Defined Extent if( Dlg_Parameters("USER") ) { CSG_Rect r( Get_Parameters("USER")->Get_Parameter("XMIN")->asDouble(), Get_Parameters("USER")->Get_Parameter("YMIN")->asDouble(), Get_Parameters("USER")->Get_Parameter("XMAX")->asDouble(), Get_Parameters("USER")->Get_Parameter("YMAX")->asDouble() ); return( Get_Cut(pPointsList, pCutList, r, Parameters("INVERSE")->asBool()) ); } break; //----------------------------------------------------- case 1: // Grid System Extent if( Dlg_Parameters("GRID") ) { return( Get_Cut(pPointsList, pCutList, Get_Parameters("GRID")->Get_Parameter("GRID")->asGrid_System()->Get_Extent(), Parameters("INVERSE")->asBool()) ); } break; //----------------------------------------------------- case 2: // Shapes Extent if( Dlg_Parameters("EXTENT") ) { if( Get_Parameters("EXTENT")->Get_Parameter("EXTENT")->asShapes() == NULL ) { SG_UI_Msg_Add_Error(_TL("Please provide a shapefile with the 'Shapes Extent' parameter!")); return( false ); } return( Get_Cut(pPointsList, pCutList, Get_Parameters("EXTENT")->Get_Parameter("EXTENT")->asShapes()->Get_Extent(), Parameters("INVERSE")->asBool()) ); } break; //----------------------------------------------------- case 3: // Polygons if( Dlg_Parameters("POLYGONS") ) { if( Get_Parameters("POLYGONS")->Get_Parameter("POLYGONS")->asShapes() == NULL ) { SG_UI_Msg_Add_Error(_TL("Please provide a shapefile with the 'Polygons' parameter!")); return( false ); } if( Parameters("INVERSE")->asBool() && Get_Parameters("POLYGONS")->Get_Parameter("POLYGONS")->asShapes()->Get_Count() > 1 ) { SG_UI_Msg_Add_Error(_TL("The inverse selection is not implemented for input shapefiles with more than one polygon!")); return (false); } return( Get_Cut(pPointsList, pCutList, Get_Parameters("POLYGONS")->Get_Parameter("POLYGONS")->asShapes(), Parameters("INVERSE")->asBool()) ); } break; } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Cut::Get_Cut(CSG_Parameter_PointCloud_List *pPointsList, CSG_Parameter_PointCloud_List *pCutList, const CSG_Rect &Extent, bool bInverse) { for(int iItem=0; iItemGet_Count(); iItem++) { SG_UI_Process_Set_Text(CSG_String::Format(_TL("Processing dataset %d"), iItem+1)); CSG_PointCloud *pPoints = pPointsList->asPointCloud(iItem); if( pPoints && pPoints->is_Valid() ) { CSG_PointCloud *pCut = new CSG_PointCloud(pPoints); pCut->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), _TL("Cut"))); if( Extent.Intersects(pPoints->Get_Extent()) ) { for(int i=0; iGet_Point_Count() && SG_UI_Process_Set_Progress(i, pPoints->Get_Point_Count()); i++) { pPoints->Set_Cursor(i); if( (Extent.Contains(pPoints->Get_X(), pPoints->Get_Y()) && !bInverse) || (!Extent.Contains(pPoints->Get_X(), pPoints->Get_Y()) && bInverse) ) { pCut->Add_Point(pPoints->Get_X(), pPoints->Get_Y(), pPoints->Get_Z()); for (int j=0; jGet_Attribute_Count(); j++) { switch (pPoints->Get_Attribute_Type(j)) { default: pCut->Set_Attribute(j, pPoints->Get_Attribute(i, j)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: CSG_String sAttr; pPoints->Get_Attribute(i, j, sAttr); pCut->Set_Attribute(j, sAttr); break; } } } } } if( pCut->Get_Count() <= 0 ) { delete pCut; SG_UI_Msg_Add(CSG_String::Format(_TL("Cutting %s resulted in an empty point cloud, skipping output!"), pPoints->Get_Name()), true); } else { pCutList->Add_Item(pCut); SG_UI_Msg_Add(CSG_String::Format(_TL("%d points from %s written to output %s."), pCut->Get_Point_Count(), pPoints->Get_Name(), pCut->Get_Name()), true); } } } return( true ); } //--------------------------------------------------------- bool CPC_Cut::Get_Cut(CSG_Parameter_PointCloud_List *pPointsList, CSG_Parameter_PointCloud_List *pCutList, CSG_Shapes *pPolygons, bool bInverse) { for(int iItem=0; iItemGet_Count(); iItem++) { SG_UI_Process_Set_Text(CSG_String::Format(_TL("Processing dataset %d"), iItem+1)); CSG_PointCloud *pPoints = pPointsList->asPointCloud(iItem); if( pPoints && pPoints->is_Valid() ) { CSG_PointCloud *pCut = new CSG_PointCloud(pPoints); pCut->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pPoints->Get_Name(), pPolygons->Get_Name())); if( pPolygons && pPolygons->Get_Type() == SHAPE_TYPE_Polygon && pPolygons->Get_Extent().Intersects(pPoints->Get_Extent()) ) { for(int i=0; iGet_Point_Count() && SG_UI_Process_Set_Progress(i, pPoints->Get_Point_Count()); i++) { pPoints->Set_Cursor(i); if( (Contains(pPolygons, pPoints->Get_X(), pPoints->Get_Y()) && !bInverse) || (!Contains(pPolygons, pPoints->Get_X(), pPoints->Get_Y()) && bInverse) ) { pCut->Add_Point(pPoints->Get_X(), pPoints->Get_Y(), pPoints->Get_Z()); for (int j=0; jGet_Attribute_Count(); j++) { switch (pPoints->Get_Attribute_Type(j)) { default: pCut->Set_Attribute(j, pPoints->Get_Attribute(i, j)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: CSG_String sAttr; pPoints->Get_Attribute(i, j, sAttr); pCut->Set_Attribute(j, sAttr); break; } } } } } if( pCut->Get_Count() <= 0 ) { delete pCut; SG_UI_Msg_Add(CSG_String::Format(_TL("Cutting %s resulted in an empty point cloud, skipping output!"), pPoints->Get_Name()), true); } else { pCutList->Add_Item(pCut); SG_UI_Msg_Add(CSG_String::Format(_TL("%d points from %s written to output %s."), pCut->Get_Point_Count(), pPoints->Get_Name(), pCut->Get_Name()), true); } } } return( true ); } //--------------------------------------------------------- bool CPC_Cut::Contains(CSG_Shapes *pPolygons, double x, double y) { if( pPolygons->Get_Extent().Contains(x, y) ) { for(int iPolygon=0; iPolygonGet_Count(); iPolygon++) { CSG_Shape_Polygon *pPolygon = (CSG_Shape_Polygon *)pPolygons->Get_Shape(iPolygon); if( pPolygon->Contains(x, y) ) { return( true ); } } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Cut_Interactive::CPC_Cut_Interactive(void) { //----------------------------------------------------- Set_Name (_TL("Point Cloud Cutter")); Set_Author (SG_T("O. Conrad, V. Wichmann (c) 2009-15")); Set_Description (_TW( "This tool allows one to extract subsets from one or several " "point cloud datasets. The area-of-interest " "is interactively defined either by dragging a box or by digitizing a polygon.\n" "Best practice is to display the point cloud in a new Map View first and then " "execute the module. Use the Action tool to define the AOI.\n\n" )); //----------------------------------------------------- Parameters.Add_PointCloud_List( NULL , "POINTS" , _TL("Points"), _TL("One or several input point cloud datasets to cut."), PARAMETER_INPUT ); Parameters.Add_PointCloud_List( NULL , "CUT" , _TL("Cut"), _TL("The cutted output point cloud dataset(s)."), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "AOI" , _TL("Define AOI by ..."), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("dragging a box"), _TL("digitzing a polygon") ), 0 ); Parameters.Add_Shapes( Parameters("AOI"), "AOISHAPE" , _TL("AOI Shape"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_Value( NULL , "INVERSE" , _TL("Inverse"), _TL("Invert selection."), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- CSG_Parameters *pParameters = Add_Parameters("CUT", _TL("Cut"), _TL("")); pParameters->Add_Value(NULL, "XMIN", _TL("Left") , _TL(""), PARAMETER_TYPE_Double); pParameters->Add_Value(NULL, "XMAX", _TL("Right") , _TL(""), PARAMETER_TYPE_Double); pParameters->Add_Value(NULL, "YMIN", _TL("Bottom") , _TL(""), PARAMETER_TYPE_Double); pParameters->Add_Value(NULL, "YMAX", _TL("Top") , _TL(""), PARAMETER_TYPE_Double); } //--------------------------------------------------------- bool CPC_Cut_Interactive::On_Execute(void) { m_pPointsList = Parameters("POINTS") ->asPointCloudList(); m_pCutList = Parameters("CUT") ->asPointCloudList(); m_bAOIBox = Parameters("AOI") ->asInt() == 0 ? true : false; m_pAOI = Parameters("AOISHAPE")->asShapes(); m_bInverse = Parameters("INVERSE") ->asBool(); if( !m_bAOIBox ) { m_bAdd = false; Set_Drag_Mode(MODULE_INTERACTIVE_DRAG_LINE); if( m_pAOI == NULL ) { m_pAOI = SG_Create_Shapes(SHAPE_TYPE_Polygon, SG_T("AOI_Cutter")); m_pAOI->Add_Field("ID", SG_DATATYPE_Int); Parameters("AOISHAPE")->Set_Value(m_pAOI); DataObject_Add(m_pAOI, true); } else if( m_pAOI->Get_Field_Count() < 1) { m_pAOI->Destroy(); m_pAOI->Add_Field("ID", SG_DATATYPE_Int); } CSG_Parameters sParms; if( DataObject_Get_Parameters(m_pAOI, sParms) && sParms("DISPLAY_BRUSH") && sParms("OUTLINE_COLOR")) { sParms("OUTLINE_COLOR") ->Set_Value((int)SG_GET_RGB(180, 0, 0)); // outline color sParms("DISPLAY_BRUSH") ->Set_Value(1); // fillstyle transparent DataObject_Set_Parameters(m_pAOI, sParms); DataObject_Update(m_pAOI, SG_UI_DATAOBJECT_SHOW_LAST_MAP); } } else { if( m_pAOI != NULL ) { m_pAOI->Destroy(); m_pAOI->Add_Field("ID", SG_DATATYPE_Int); } Set_Drag_Mode(MODULE_INTERACTIVE_DRAG_BOX); } if( m_pAOI != NULL ) { m_pAOI->Set_Name(_TL("AOI_Cutter")); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CPC_Cut_Interactive::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { switch( Mode ) { //----------------------------------------------------- case MODULE_INTERACTIVE_LDOWN: if( m_bAOIBox ) m_ptDown = ptWorld; else { if( !m_bAdd ) { m_bAdd = true; m_pAOI ->Del_Records(); m_pAOI ->Add_Shape(); m_pAOI->Get_Shape(0)->Add_Point(ptWorld); // workaround to have first line immediately displayed, } // i.e. we add the first point clicked two times m_pAOI->Get_Shape(0)->Add_Point(ptWorld); DataObject_Update(m_pAOI, SG_UI_DATAOBJECT_SHOW_LAST_MAP); } return( true ); //----------------------------------------------------- case MODULE_INTERACTIVE_LUP: if( m_bAOIBox ) { CSG_Rect r(m_ptDown.Get_X(), m_ptDown.Get_Y(), ptWorld.Get_X(), ptWorld.Get_Y()); CSG_Parameters *pParameters = Get_Parameters("CUT"); pParameters->Get_Parameter("XMIN")->Set_Value(r.Get_XMin()); pParameters->Get_Parameter("XMAX")->Set_Value(r.Get_XMax()); pParameters->Get_Parameter("YMIN")->Set_Value(r.Get_YMin()); pParameters->Get_Parameter("YMAX")->Set_Value(r.Get_YMax()); if( Dlg_Parameters("CUT") ) { r.Assign( pParameters->Get_Parameter("XMIN")->asDouble(), pParameters->Get_Parameter("YMIN")->asDouble(), pParameters->Get_Parameter("XMAX")->asDouble(), pParameters->Get_Parameter("YMAX")->asDouble() ); CPC_Cut::Get_Cut(m_pPointsList, m_pCutList, r, m_bInverse); if( m_pAOI != NULL ) { m_pAOI ->Del_Records(); m_pAOI ->Add_Shape(); m_pAOI->Get_Shape(0)->Add_Point(r.Get_XMin(), r.Get_YMin()); m_pAOI->Get_Shape(0)->Add_Point(r.Get_XMin(), r.Get_YMax()); m_pAOI->Get_Shape(0)->Add_Point(r.Get_XMax(), r.Get_YMax()); m_pAOI->Get_Shape(0)->Add_Point(r.Get_XMax(), r.Get_YMin()); m_pAOI->Get_Shape(0)->Add_Point(r.Get_XMin(), r.Get_YMin()); } } return( true ); } return( false ); //----------------------------------------------------- case MODULE_INTERACTIVE_RDOWN: if( !m_bAOIBox ) { m_bAdd = false; CPC_Cut::Get_Cut(m_pPointsList, m_pCutList, m_pAOI, m_bInverse); return( true ); } return( false ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_transform.cpp0000744000175000017500000002311112737416176027021 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_transform.cpp // // // // Copyright (C) 2010 by // // Volker Wichmann // // // // Based on TransformShapes.cpp, (C) Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_transform.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Transform::CPC_Transform(void) { CSG_Parameter *pNode_0, *pNode_1; //----------------------------------------------------- Set_Name(_TL("Transform Point Cloud")); Set_Author(_TL("Volker Wichmann (c) 2010, LASERDATA GmbH")); Set_Description (_TW( "The module can be used to shift, rotate and/or scale a Point Cloud.\n\n") ); //----------------------------------------------------- Parameters.Add_PointCloud( NULL , "IN" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_PointCloud( NULL , "OUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "MOVE" , _TL("Move"), _TL("") ); pNode_1 = Parameters.Add_Value( pNode_0 , "DX" , _TL("dX"), _TL("dX (Map Units)"), PARAMETER_TYPE_Double, 0.0 ); pNode_1 = Parameters.Add_Value( pNode_0, "DY" , _TL("dY"), _TL("dY (Map Units)"), PARAMETER_TYPE_Double, 0.0 ); pNode_1 = Parameters.Add_Value( pNode_0, "DZ" , _TL("dZ"), _TL("dZ (Map Units)"), PARAMETER_TYPE_Double, 0.0 ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "ROTATE" , _TL("Rotate"), _TL("")); pNode_1 = Parameters.Add_Value( pNode_0 , "ANGLEX" , _TL("Angle X"), _TL("Angle in degrees, clockwise around x axis"), PARAMETER_TYPE_Double, 0.0 ); pNode_1 = Parameters.Add_Value( pNode_0 , "ANGLEY" , _TL("Angle Y"), _TL("Angle in degrees, clockwise around y axis"), PARAMETER_TYPE_Double, 0.0 ); pNode_1 = Parameters.Add_Value( pNode_0 , "ANGLEZ" , _TL("Angle Z"), _TL("Angle in degrees, clockwise around z axis"), PARAMETER_TYPE_Double, 0.0 ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "SCALE" , _TL("Scale"), _TL("") ); pNode_1 = Parameters.Add_Value( pNode_0 , "SCALEX" , _TL("Scale Factor X"), _TL("Scale Factor X"), PARAMETER_TYPE_Double, 1.0 ); pNode_1 = Parameters.Add_Value( pNode_0 , "SCALEY" , _TL("Scale Factor Y"), _TL("Scale Factor Y"), PARAMETER_TYPE_Double, 1.0 ); pNode_1 = Parameters.Add_Value( pNode_0 , "SCALEZ" , _TL("Scale Factor Z"), _TL("Scale Factor Z"), PARAMETER_TYPE_Double, 1.0 ); //----------------------------------------------------- pNode_0 = Parameters.Add_Node( NULL , "ANCHOR" , _TL("Anchor Point"), _TL("") ); pNode_1 = Parameters.Add_Value( pNode_0 , "ANCHORX" , _TL("X"), _TL("X"), PARAMETER_TYPE_Double, 0.0 ); pNode_1 = Parameters.Add_Value( pNode_0 , "ANCHORY" , _TL("Y"), _TL("Y"), PARAMETER_TYPE_Double, 0.0 ); pNode_1 = Parameters.Add_Value( pNode_0 , "ANCHORZ" , _TL("Z"), _TL("Z"), PARAMETER_TYPE_Double, 0.0 ); } //--------------------------------------------------------- CPC_Transform::~CPC_Transform(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Transform::On_Execute(void) { bool bCopy; double angleX, angleY, angleZ; TSG_Point_Z P, Q, Move, Scale, Anchor; CSG_PointCloud *pIn, *pOut; double a11, a12, a13, a21, a22, a23, a31, a32, a33; //----------------------------------------------------- pIn = Parameters("IN") ->asPointCloud(); pOut = Parameters("OUT") ->asPointCloud(); Scale.x = Parameters("SCALEX") ->asDouble(); Scale.y = Parameters("SCALEY") ->asDouble(); Scale.z = Parameters("SCALEZ") ->asDouble(); Move.x = Parameters("DX") ->asDouble(); Move.y = Parameters("DY") ->asDouble(); Move.z = Parameters("DZ") ->asDouble(); Anchor.x = Parameters("ANCHORX") ->asDouble(); Anchor.y = Parameters("ANCHORY") ->asDouble(); Anchor.z = Parameters("ANCHORZ") ->asDouble(); angleX = Parameters("ANGLEX") ->asDouble() * -M_DEG_TO_RAD; angleY = Parameters("ANGLEY") ->asDouble() * -M_DEG_TO_RAD; angleZ = Parameters("ANGLEZ") ->asDouble() * -M_DEG_TO_RAD; if( pIn == pOut ) { bCopy = true; pOut = SG_Create_PointCloud(); } else bCopy = false; pOut->Create(pIn); pOut->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pIn->Get_Name(), _TL("Transformed"))); //----------------------------------------------------- for (int iPoint=0; iPointGet_Point_Count(); iPoint++) { P = pIn->Get_Point(iPoint); //anchor shift P.x -= Anchor.x; P.y -= Anchor.y; P.z -= Anchor.z; // create rotation matrix a11 = cos(angleY) * cos(angleZ); a12 = -cos(angleX) * sin(angleZ) + sin(angleX) * sin(angleY) * cos(angleZ); a13 = sin(angleX) * sin(angleZ) + cos(angleX) * sin(angleY) * cos(angleZ); a21 = cos(angleY) * sin(angleZ); a22 = cos(angleX) * cos(angleZ) + sin(angleX) * sin(angleY) * sin(angleZ); a23 = -sin(angleX) * cos(angleZ) + cos(angleX) * sin(angleY) * sin(angleZ); a31 = -sin(angleY); a32 = sin(angleX) * cos(angleY); a33 = cos(angleX) * cos(angleY); //transform Q.x = (P.x * a11 + P.y * a12 + P.z * a13) * Scale.x; Q.y = (P.x * a21 + P.y * a22 + P.z * a23) * Scale.y; Q.z = (P.x * a31 + P.y * a32 + P.z * a33) * Scale.z; //undo anchor shift and apply move Q.x += Anchor.x + Move.x; Q.y += Anchor.y + Move.y; Q.z += Anchor.z + Move.z; pOut->Add_Point(Q.x, Q.y, Q.z); for (int j=0; jGet_Attribute_Count(); j++) { switch (pIn->Get_Attribute_Type(j)) { default: pOut->Set_Attribute(iPoint, j, pIn->Get_Attribute(iPoint, j)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: CSG_String sAttr; pIn->Get_Attribute(iPoint, j, sAttr); pOut->Set_Attribute(iPoint, j, sAttr); break; } } } //----------------------------------------------------- if( bCopy ) { pIn->Assign(pOut); delete(pOut); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_from_table.h0000744000175000017500000000761612737416175026600 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_table.h // // // // Copyright (C) 2015 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_From_Table_H #define HEADER_INCLUDED__PC_From_Table_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_From_Table : public CSG_Module { public: CPC_From_Table(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Conversion") ); } protected: virtual bool On_Execute (void); private: }; #endif // #ifndef HEADER_INCLUDED__PC_From_Table_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_drop_attribute.cpp0000744000175000017500000001771112737416175030045 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_drop_attribute.cpp // // // // Copyright (C) 2010 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_drop_attribute.h" #include #include /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Drop_Attribute::CPC_Drop_Attribute(void) { Set_Name (_TL("Drop Point Cloud Attributes")); Set_Author ("Volker Wichmann (c) 2010, LASERDATA GmbH"); Set_Description (_TW( "The module can be used to drop attributes from a point cloud. " "In case the output dataset is not set, the attribute(s) will be dropped " "from the input dataset, i.e. the input dataset will be overwritten.\n\n" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_PointCloud( NULL , "INPUT" ,_TL("Input"), _TL("Point cloud to drop attribute(s) from."), PARAMETER_INPUT ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("The attribute field(s) to drop.") ); Parameters.Add_PointCloud( NULL , "OUTPUT" , _TL("Output"), _TL("Point cloud with attribute(s) dropped."), PARAMETER_OUTPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Drop_Attribute::On_Execute(void) { //------------------------------------------------- int *Features = (int *)Parameters("FIELDS")->asPointer(); int nFeatures = Parameters("FIELDS")->asInt (); if( !Features || nFeatures <= 0 ) { Error_Set(_TL("You must specify at least one attribute to drop!")); return( false ); } //----------------------------------------------------- CSG_PointCloud *pInput = Parameters("INPUT" )->asPointCloud(); CSG_PointCloud *pOutput = Parameters("OUTPUT")->asPointCloud(), Output; if( !pOutput || pOutput == pInput ) { pOutput = &Output; } pOutput->Create(pInput); //----------------------------------------------------- int i; std::set setCols; std::set::iterator it; setCols.clear(); for(i=0; iDel_Field(*it - i); } //----------------------------------------------------- for(i=0; iGet_Point_Count() && SG_UI_Process_Set_Progress(i, pInput->Get_Count()); i++) { pOutput->Add_Point(pInput->Get_X(i), pInput->Get_Y(i), pInput->Get_Z(i)); for(int j=0, k=0; jGet_Attribute_Count(); j++, k++) { it = setCols.find(j + 3); if( it != setCols.end() ) { k--; continue; } switch (pInput->Get_Attribute_Type(j)) { default: pOutput->Set_Attribute(k, pInput->Get_Attribute(i, j)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: CSG_String sAttr; pInput->Get_Attribute(i, j, sAttr); pOutput->Set_Attribute(k, sAttr); break; } } } //----------------------------------------------------- if( pOutput == &Output ) { CSG_MetaData History = pInput->Get_History(); CSG_String Name = pInput->Get_Name (); pInput->Assign(pOutput); pInput->Get_History() = History; pInput->Set_Name(Name); Parameters("OUTPUT")->Set_Value(pInput); } else { pOutput->Set_Name(CSG_String::Format("%s [%s]", pInput->Get_Name(), _TL("Dropped Attributes"))); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Drop_Attribute::On_After_Execution(void) { CSG_PointCloud *pOutput = Parameters("OUTPUT")->asPointCloud(); if( pOutput == NULL ) { pOutput = Parameters("INPUT")->asPointCloud(); } DataObject_Set_Parameter(pOutput, "DISPLAY_VALUE_AGGREGATE", 3); // highest z DataObject_Set_Parameter(pOutput, "METRIC_COLORS" , 12); // number of colors DataObject_Set_Parameter(pOutput, "COLORS_TYPE" , 3); // graduated color DataObject_Set_Parameter(pOutput, "METRIC_ATTRIB" , 2); // z attrib DataObject_Set_Parameter(pOutput, "METRIC_ZRANGE", pOutput->Get_Mean(2) - 2.0 * pOutput->Get_StdDev(2), pOutput->Get_Mean(2) + 2.0 * pOutput->Get_StdDev(2) ); DataObject_Set_Colors(pOutput, 11, SG_COLORS_RAINBOW); if( pOutput == Parameters("INPUT")->asPointCloud() ) { Parameters("OUTPUT")->Set_Value(DATAOBJECT_NOTSET); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_cluster_analysis.cpp0000744000175000017500000005253112737416175030401 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_cluster_analysis.h // // // // Copyright (C) 2010 by // // Volker Wichmann // // // // This module is a port of the Grid_Cluster_Analysis // // module from the Grid_Discretisation module library, // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_cluster_analysis.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Cluster_Analysis::CPC_Cluster_Analysis(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Cluster Analysis for Point Clouds")); Set_Author (SG_T("Volker Wichmann (c) 2010, LASERDATA GmbH")); Set_Description (_TW( "Cluster analysis for point clouds.\n\n" "References:\n\n" "This tool is a port of the 'Cluster Analysis for Grids' " "module from the 'Imagery - Classification' tool library, " "Copyright (C) 2003 by Olaf Conrad.\n\n" "Iterative Minimum Distance:\n" "- Forgy, E. (1965):\n" " 'Cluster Analysis of multivariate data: efficiency vs. interpretability of classifications',\n" " Biometrics 21:768\n\n" "Hill-Climbing:" "- Rubin, J. (1967):\n" " 'Optimal Classification into Groups: An Approach for Solving the Taxonomy Problem',\n" " J. Theoretical Biology, 15:103-144\n\n" )); //----------------------------------------------------- // 2. Datasets... CSG_Parameter *pNode = Parameters.Add_PointCloud( NULL , "PC_IN" ,_TL("Point Cloud"), _TL("Input"), PARAMETER_INPUT ); Parameters.Add_Table_Fields( pNode , "FIELDS" , _TL("Attributes"), _TL("The attribute fields to cluster") ); Parameters.Add_PointCloud( NULL , "PC_OUT" ,_TL("Result"), _TL("Output"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Table( NULL , "STATISTICS" , _TL("Statistics"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- // 3. General Parameters... Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Iterative Minimum Distance (Forgy 1965)"), _TL("Hill-Climbing (Rubin 1967)"), _TL("Combined Minimum Distance / Hillclimbing") ),1 ); Parameters.Add_Value( NULL , "NCLUSTER" , _TL("Clusters"), _TL("Number of clusters"), PARAMETER_TYPE_Int, 10, 2, true ); Parameters.Add_Value( NULL , "NORMALISE" , _TL("Normalise"), _TL("Automatically normalise attributes by standard deviation before clustering."), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Cluster_Analysis::On_Execute(void) { int nCluster; long nElements; double SP; //----------------------------------------------------- nCluster = Parameters("NCLUSTER")->asInt(); pPC_in = Parameters("PC_IN") ->asPointCloud(); pPC_out = Parameters("PC_OUT") ->asPointCloud(); //------------------------------------------------- m_Features = (int *)Parameters("FIELDS")->asPointer(); m_nFeatures = Parameters("FIELDS")->asInt (); if( !m_Features || m_nFeatures <= 0 ) { Error_Set(_TL("no features in selection")); return( false ); } //----------------------------------------------------- if (!pPC_out || pPC_out == pPC_in) { pPC_out = &PC_out; } pPC_out->Create(pPC_in); pPC_out->Add_Field(SG_T("CLUSTER"), SG_DATATYPE_Int); clustField = pPC_out->Get_Field_Count() - 1; pPC_out->Set_NoData_Value(-1.0); //----------------------------------------------------- Process_Set_Text(_TL("Initializing ...")); for( int i=0; i() ); for( int i=0; iGet_Record_Count() && SG_UI_Process_Set_Progress(i, pPC_in->Get_Record_Count()); i++ ) { pPC_out->Add_Point(pPC_in->Get_X(i), pPC_in->Get_Y(i), pPC_in->Get_Z(i)); for (int j=0; jGet_Attribute_Count(); j++) { switch (pPC_in->Get_Attribute_Type(j)) { default: pPC_out->Set_Attribute(i, j, pPC_in->Get_Attribute(i, j)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: CSG_String sAttr; pPC_in->Get_Attribute(i, j, sAttr); pPC_out->Set_Attribute(i, j, sAttr); break; } } pPC_out->Set_NoData(i, clustField); bool bNoData = false; for( int j=0; jis_NoData(i, m_Features[j]) ) { bNoData = true; break; } } if( !bNoData ) { for( int j=0; jasBool() ) vValues.at(j).push_back( (pPC_in->Get_Value(i, m_Features[j]) - pPC_in->Get_Mean(m_Features[j])) / pPC_in->Get_StdDev(m_Features[j]) ); else vValues.at(j).push_back(pPC_in->Get_Value(i, m_Features[j])); } } else { for( int j=0; jGet_NoData_Value()); } } } nMembers = (int *)SG_Malloc(nCluster * sizeof(int)); Variances = (double *)SG_Malloc(nCluster * sizeof(double)); Centroids = (double **)SG_Malloc(nCluster * sizeof(double *)); for( int i=0; iGet_Point_Count(); switch( Parameters("METHOD")->asInt() ) { case 0: SP = MinimumDistance (nElements, nCluster); break; case 1: SP = HillClimbing (nElements, nCluster); break; case 2: SP = MinimumDistance (nElements, nCluster); nElements = pPC_in->Get_Point_Count(); // may have been diminished because of no data values... SP = HillClimbing (nElements, nCluster); break; } //------------------------------------------------- if( Parameters("NORMALISE")->asBool() ) { int iv = 0; for( int i=0; iGet_Variance(m_Features[i])) * Centroids[j][iv] + pPC_in->Get_Mean(m_Features[i]); } iv++; } } Write_Result(Parameters("STATISTICS")->asTable(), nElements, nCluster, SP); //------------------------------------------------- for( int i=0; iGet_History(); CSG_String sName = pPC_in->Get_Name(); pPC_in->Assign(pPC_out); pPC_in->Get_History() = History; pPC_in->Set_Name(sName); Parameters("PC_OUT")->Set_Value(pPC_in); } else { pPC_out->Set_Name(CSG_String::Format(SG_T("%s_cluster"), pPC_in->Get_Name())); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPC_Cluster_Analysis::Write_Result(CSG_Table *pTable, long nElements, int nCluster, double SP) { CSG_String s; CSG_Table_Record *pRecord; pTable->Destroy(); s = CSG_String::Format(_TL("Cluster Analysis PC")); s += CSG_String::Format(SG_T("_%s"), pPC_in->Get_Name()); pTable->Set_Name(s); pTable->Add_Field(_TL("ClusterID") , SG_DATATYPE_Int); pTable->Add_Field(_TL("Elements") , SG_DATATYPE_Int); pTable->Add_Field(_TL("Variance") , SG_DATATYPE_Double); s.Printf(SG_T("\n%s:\t%ld \n%s:\t%d \n%s:\t%d \n%s:\t%f"), _TL("Number of Elements") , nElements, _TL("\nNumber of Variables") , m_nFeatures, _TL("\nNumber of Clusters") , nCluster, _TL("\nValue of Target Function") , SP ); s.Append(CSG_String::Format(SG_T("%s\t%s\t%s"), _TL("Cluster"), _TL("Elements"), _TL("Variance"))); for( int j=0; jGet_Field_Name(m_Features[j]))); pTable->Add_Field(pPC_in->Get_Field_Name(m_Features[j]), SG_DATATYPE_Double); } Message_Add(s); for( int i=0; iAdd_Record(); pRecord->Set_Value(0, i); pRecord->Set_Value(1, nMembers[i]); pRecord->Set_Value(2, Variances[i]); for( int j=0; jSet_Value(j + 3, Centroids[i][j]); } Message_Add(s); } } /////////////////////////////////////////////////////////// // // // Minimum Distance // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // (nElements)-Array -> Bei Eingabe Startgruppierung oder 0. // Bei Ausgabe Gruppierung: >Das ite Element ist im Cluster Cluster(i). double CPC_Cluster_Analysis::MinimumDistance(long &nElements, int nCluster) { //----------------------------------------------------- // Variablen... bool bContinue; int iElement, iField, iCluster, nClusterElements, nShifts, minCluster, nPasses; double d, Variance, minVariance, SP, SP_Last = -1; //----------------------------------------------------- // Anfangspartition (Standard falls nicht vorgegeben for( iElement=0, nClusterElements=0; iElementGet_Value(iElement, clustField) < 0 || pPC_out->Get_Value(iElement, clustField) >= nCluster ) { pPC_out->Set_Value(iElement, clustField, iElement % nCluster); } nClusterElements++; } //----------------------------------------------------- // Hauptschleife der Iteration for( nPasses=1, bContinue=true; bContinue && Process_Get_Okay(false); nPasses++ ) { //------------------------------------------------- for( iCluster=0; iClusterGet_Value(iElement, clustField) >= 0 ) { iCluster = (int)pPC_out->Get_Value(iElement, clustField); nMembers[iCluster]++; for( iField=0; iField 0 ? 1.0 / (double)nMembers[iCluster] : 0; for( iField=0; iFieldGet_Value(iElement, clustField) >= 0 ) { minVariance = -1; for( iCluster=0; iClusterGet_Value(iElement, clustField) != minCluster ) { pPC_out->Set_Value(iElement, clustField, minCluster); nShifts++; } SP += minVariance; Variances[minCluster] += minVariance; } } //------------------------------------------------- if( nShifts == 0 || (SP_Last >= 0 && SP >= SP_Last) ) { bContinue = false; } Process_Set_Text(CSG_String::Format(SG_T("%s: %d >> %s %f"), _TL("pass") , nPasses, _TL("change") , SP_Last < 0.0 ? SP : SP_Last - SP )); SP_Last = SP; } nElements = nClusterElements; return( SP ); } /////////////////////////////////////////////////////////// // // // Hill-Climbing // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CPC_Cluster_Analysis::HillClimbing(long &nElements, int nCluster) { //----------------------------------------------------- // Variablen... bool bContinue; int iElement, iField, iCluster, jCluster, kCluster, nClusterElements, noShift, nPasses; double d, e, n_iK, n_jK, V, VMin, V1, V2, SP, SP_Last = -1; //----------------------------------------------------- for( iCluster=0; iClusterGet_Value(iElement, clustField) < 0 || pPC_out->Get_Value(iElement, clustField) >= nCluster ) { pPC_out->Set_Value(iElement, clustField, iElement % nCluster); } nClusterElements++; iCluster = (int)pPC_out->Get_Value(iElement, clustField); nMembers[iCluster]++; V = 0.0; for( iField=0; iFieldGet_Value(iElement, clustField) >= 0 ) { if( noShift++ >= nElements ) { bContinue = false; } else { //--------------------------------------------- iCluster = (int)pPC_out->Get_Value(iElement, clustField); if( nMembers[iCluster] > 1 ) { V = 0.0; for( iField=0; iField= 0 && VMin < V1 ) { noShift = 0; Variances[iCluster] -= V1; Variances[kCluster] += VMin; SP = SP - V1 + VMin; V1 = 1.0 / (n_iK - 1.0); n_jK = nMembers[kCluster]; V2 = 1.0 / (n_jK + 1.0); for( iField=0; iFieldSet_Value(iElement, clustField, kCluster); nMembers[iCluster]--; nMembers[kCluster]++; } } } } } Process_Set_Text(CSG_String::Format(SG_T("%s: %d >> %s %f"), _TL("pass") , nPasses, _TL("change") , SP_Last < 0.0 ? SP : SP_Last - SP )); SP_Last = SP; } nElements = nClusterElements; return( SP ); } //--------------------------------------------------------- bool CPC_Cluster_Analysis::On_After_Execution(void) { CSG_PointCloud *pPC_out = Parameters("PC_OUT")->asPointCloud(); if (pPC_out == NULL) { pPC_out = Parameters("PC_IN")->asPointCloud(); } CSG_Parameters Parms; if( DataObject_Get_Parameters(pPC_out, Parms) && Parms("COLORS_TYPE") && Parms("LUT") && Parms("LUT_ATTRIB") ) { CSG_Table_Record *pClass; CSG_Table *pLUT = Parms("LUT")->asTable(); for( int i=0; i<=pPC_out->Get_Maximum(pPC_out->Get_Field_Count()-1); i++ ) { if( (pClass = pLUT->Get_Record(i)) == NULL ) { pClass = pLUT->Add_Record(); pClass->Set_Value(0, SG_GET_RGB(rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX, rand() * 255.0 / RAND_MAX)); } pClass->Set_Value(1, CSG_String::Format(SG_T("%s %d"), _TL("Class"), i)); pClass->Set_Value(2, CSG_String::Format(SG_T("%s %d"), _TL("Class"), i)); pClass->Set_Value(3, i); pClass->Set_Value(4, i); } while( pLUT->Get_Record_Count() > (pPC_out->Get_Maximum(pPC_out->Get_Field_Count()-1) + 1) ) { pLUT->Del_Record(pLUT->Get_Record_Count() - 1); } Parms("COLORS_TYPE") ->Set_Value(1); // Color Classification Type: Lookup Table Parms("LUT_ATTRIB") ->Set_Value(clustField); DataObject_Set_Parameters(pPC_out, Parms); } if (pPC_out == Parameters("PC_IN")->asPointCloud()) { Parameters("PC_OUT")->Set_Value(DATAOBJECT_NOTSET); } return (true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_thinning_simple.cpp0000744000175000017500000001263212737416175030202 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_thinning_simple.cpp // // // // Copyright (C) 2010 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_thinning_simple.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Thinning_Simple::CPC_Thinning_Simple(void) { Set_Name(_TL("Point Cloud Thinning (simple)")); Set_Author(SG_T("Volker Wichmann (c) 2010, LASERDATA GmbH")); Set_Description (_TW( "The module can be used to remove every i-th point from a point cloud. This thinning " "method is most suited for data in chronological order.\n\n") ); //----------------------------------------------------- Parameters.Add_PointCloud( NULL , "INPUT" ,_TL("Input"), _TL("Point Cloud to drop attribute from."), PARAMETER_INPUT ); Parameters.Add_PointCloud( NULL , "RESULT" , _TL("Result"), _TL("Resulting Point Cloud."), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "STEP" , _TL("Stepwidth"), _TL("Remove every i-th point."), PARAMETER_TYPE_Int, 2, 2, true ); } //--------------------------------------------------------- CPC_Thinning_Simple::~CPC_Thinning_Simple(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Thinning_Simple::On_Execute(void) { CSG_PointCloud *pInput, *pResult; int step; pInput = Parameters("INPUT")->asPointCloud(); pResult = Parameters("RESULT")->asPointCloud(); step = Parameters("STEP")->asInt() - 1; pResult->Create(pInput); pResult->Assign(pInput); pResult->Set_Name(CSG_String::Format(SG_T("%s_thinned"), pInput->Get_Name())); for (int i=step; iGet_Point_Count() && Set_Progress(i, pInput->Get_Point_Count()); i+=step) { pResult->Del_Point(i); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_tools/Makefile.in0000664000175000017500000006064412737447617025706 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/pointcloud/pointcloud_tools ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libpointcloud_tools_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libpointcloud_tools_la_OBJECTS = MLB_Interface.lo \ pc_attribute_calculator.lo pc_cluster_analysis.lo pc_cut.lo \ pc_drop_attribute.lo pc_from_grid.lo pc_from_shapes.lo \ pc_from_table.lo pc_merge.lo pc_reclass_extract.lo \ pc_thinning_simple.lo pc_to_grid.lo pc_to_shapes.lo \ pc_transform.lo libpointcloud_tools_la_OBJECTS = $(am_libpointcloud_tools_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libpointcloud_tools_la_SOURCES) DIST_SOURCES = $(libpointcloud_tools_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LFLG) pkglib_LTLIBRARIES = libpointcloud_tools.la libpointcloud_tools_la_SOURCES = \ MLB_Interface.cpp\ pc_attribute_calculator.cpp\ pc_cluster_analysis.cpp\ pc_cut.cpp\ pc_drop_attribute.cpp\ pc_from_grid.cpp\ pc_from_shapes.cpp\ pc_from_table.cpp\ pc_merge.cpp\ pc_reclass_extract.cpp\ pc_thinning_simple.cpp\ pc_to_grid.cpp\ pc_to_shapes.cpp\ pc_transform.cpp\ MLB_Interface.h\ pc_attribute_calculator.h\ pc_cluster_analysis.h\ pc_cut.h\ pc_drop_attribute.h\ pc_from_grid.h\ pc_from_shapes.h\ pc_from_table.h\ pc_merge.h\ pc_reclass_extract.h\ pc_thinning_simple.h\ pc_to_grid.h\ pc_to_shapes.h\ pc_transform.h libpointcloud_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/pointcloud/pointcloud_tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/pointcloud/pointcloud_tools/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libpointcloud_tools.la: $(libpointcloud_tools_la_OBJECTS) $(libpointcloud_tools_la_DEPENDENCIES) $(EXTRA_libpointcloud_tools_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libpointcloud_tools_la_OBJECTS) $(libpointcloud_tools_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_attribute_calculator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_cluster_analysis.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_cut.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_drop_attribute.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_from_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_from_shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_from_table.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_merge.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_reclass_extract.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_thinning_simple.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_to_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_to_shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pc_transform.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_from_grid.h0000744000175000017500000001001712737416175026423 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_grid.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_From_Grid_H #define HEADER_INCLUDED__PC_From_Grid //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_From_Grid : public CSG_Module_Grid { public: CPC_From_Grid(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Conversion") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_From_Grid_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_cluster_analysis.h0000744000175000017500000001124512737416175030043 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_cluster_analysis.h // // // // Copyright (C) 2010 by // // Volker Wichmann // // // // This module is a port of the Grid_Cluster_Analysis // // module from the Grid_Discretisation module library, // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_Cluster_Analysis_H #define HEADER_INCLUDED__PC_Cluster_Analysis_H //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Cluster_Analysis : public CSG_Module { public: CPC_Cluster_Analysis(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Classification") ); } protected: virtual bool On_Execute (void); private: int *m_Features, m_nFeatures, clustField, *nMembers; double **Centroids, *Variances; CSG_PointCloud *pPC_in, *pPC_out, PC_out; std::vector< std::vector > vValues; void Write_Result (CSG_Table *pTable, long nElements, int nCluster, double SP); double MinimumDistance (long &nElements, int nCluster); double HillClimbing (long &nElements, int nCluster); virtual bool On_After_Execution(void); }; #endif // #ifndef HEADER_INCLUDED__PC_Cluster_Analysis_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_merge.h0000744000175000017500000001021712737416175025554 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_merge.h // // // // Copyright (C) 2012 by // // Magnus Bremer // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: magnus.bremer@uibk.ac.at // // // // contact: Magnus Bremer // // Innrain 52 // // 6020 Innsbruck // // Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_Merge_H #define HEADER_INCLUDED__PC_Merge_H //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Merge : public CSG_Module { public: CPC_Merge(void); virtual ~CPC_Merge(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Merge_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/Makefile.am0000744000175000017500000000220012737416175025647 0ustar00oconradoconrad00000000000000if DEBUG DBGFLAGS = -g -DDEBUG endif DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LFLG) pkglib_LTLIBRARIES = libpointcloud_tools.la libpointcloud_tools_la_SOURCES =\ MLB_Interface.cpp\ pc_attribute_calculator.cpp\ pc_cluster_analysis.cpp\ pc_cut.cpp\ pc_drop_attribute.cpp\ pc_from_grid.cpp\ pc_from_shapes.cpp\ pc_from_table.cpp\ pc_merge.cpp\ pc_reclass_extract.cpp\ pc_thinning_simple.cpp\ pc_to_grid.cpp\ pc_to_shapes.cpp\ pc_transform.cpp\ MLB_Interface.h\ pc_attribute_calculator.h\ pc_cluster_analysis.h\ pc_cut.h\ pc_drop_attribute.h\ pc_from_grid.h\ pc_from_shapes.h\ pc_from_table.h\ pc_merge.h\ pc_reclass_extract.h\ pc_thinning_simple.h\ pc_to_grid.h\ pc_to_shapes.h\ pc_transform.h libpointcloud_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/pointcloud/pointcloud_tools/MLB_Interface.h0000744000175000017500000000747712737416175026403 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pointcloud_tools_H #define HEADER_INCLUDED__pointcloud_tools_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef pointcloud_tools_EXPORTS #define pointcloud_tools_EXPORT _SAGA_DLL_EXPORT #else #define pointcloud_tools_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pointcloud_tools_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_from_shapes.cpp0000744000175000017500000001463012737416175027321 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_shapes.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_from_shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_From_Shapes::CPC_From_Shapes(void) { //----------------------------------------------------- Set_Name (_TL("Point Cloud from Shapes")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ZFIELD" , _TL("Z Value"), _TL(""), true ); Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("only z"), _TL("all attributes") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_From_Shapes::On_Execute(void) { int zField, nFields, *Fields; CSG_PointCloud *pPoints; CSG_Shapes *pShapes; pShapes = Parameters("SHAPES")->asShapes(); pPoints = Parameters("POINTS")->asPointCloud(); zField = Parameters("ZFIELD")->asInt(); if( !pShapes->is_Valid() ) { Error_Set(_TL("invalid input")); return( false ); } //----------------------------------------------------- pPoints->Create(); pPoints->Set_Name(pShapes->Get_Name()); nFields = 0; Fields = new int[pShapes->Get_Field_Count()]; if( Parameters("OUTPUT")->asInt() == 1 ) // all attributes { for(int iField=0; iFieldGet_Field_Count(); iField++) { if( iField != zField && pPoints->Add_Field(pShapes->Get_Field_Name(iField), pShapes->Get_Field_Type(iField)) ) { Fields[nFields++] = iField; } } } //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); pPoints->Add_Point(p.x, p.y, zField < 0 ? pShape->Get_Z(iPoint, iPart) : pShape->asDouble(zField)); for(int iField=0, jField=3; iFieldGet_Field_Type(jField) ) { case SG_DATATYPE_Date: case SG_DATATYPE_String: pPoints->Set_Value(jField, pShape->asString(Fields[iField])); break; default: pPoints->Set_Value(jField, pShape->asDouble(Fields[iField])); break; } } } } } //----------------------------------------------------- delete[](Fields); return( pPoints->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_cut.h0000744000175000017500000001212512737416175025250 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_cut.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_Cut_H #define HEADER_INCLUDED__PC_Cut_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Cut : public CSG_Module { public: CPC_Cut(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } static bool Get_Cut (CSG_Parameter_PointCloud_List *pPointsList, CSG_Parameter_PointCloud_List *pCutList, const CSG_Rect &Extent, bool bInverse); static bool Get_Cut (CSG_Parameter_PointCloud_List *pPointsList, CSG_Parameter_PointCloud_List *pCutList, CSG_Shapes *pPolygons, bool bInverse); protected: virtual bool On_Execute (void); private: static bool Contains (CSG_Shapes *pPolygons, double x, double y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Cut_Interactive : public CSG_Module_Interactive { public: CPC_Cut_Interactive(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CSG_Point m_ptDown; CSG_Parameter_PointCloud_List *m_pPointsList, *m_pCutList; CSG_Shapes *m_pAOI; bool m_bAOIBox, m_bAdd, m_bInverse; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Cut_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_transform.h0000744000175000017500000001045012737416176026470 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_transform.h // // // // Copyright (C) 2010 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_Transform_H #define HEADER_INCLUDED__PC_Transform_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_Transform : public CSG_Module { public: CPC_Transform(void); virtual ~CPC_Transform(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_Transform_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/MLB_Interface.cpp0000744000175000017500000001210312737416175026714 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Point Clouds") ); case MLB_INFO_Category: return( _TL("Shapes") ); case MLB_INFO_Author: return( SG_T("O.Conrad, V.Wichmann, M.Bremer (c) 2009-15") ); case MLB_INFO_Description: return( _TL("Tools for point clouds.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Shapes|Point Clouds") ); } } //--------------------------------------------------------- #include "pc_attribute_calculator.h" #include "pc_cluster_analysis.h" #include "pc_cut.h" #include "pc_drop_attribute.h" #include "pc_from_grid.h" #include "pc_from_shapes.h" #include "pc_from_table.h" #include "pc_merge.h" #include "pc_reclass_extract.h" #include "pc_thinning_simple.h" #include "pc_to_grid.h" #include "pc_to_shapes.h" #include "pc_transform.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CPC_Cut ); case 1: return( new CPC_Cut_Interactive ); case 2: return( new CPC_From_Grid ); case 3: return( new CPC_From_Shapes ); case 4: return( new CPC_To_Grid ); case 5: return( new CPC_To_Shapes ); case 6: return( new CPC_Reclass_Extract ); case 7: return( new CPC_Drop_Attribute ); case 8: return( new CPC_Transform ); case 9: return( new CPC_Thinning_Simple ); case 10: return( new CPC_Attribute_Calculator ); case 11: return( new CPC_Cluster_Analysis ); case 12: return( new CPC_Merge ); case 13: return( new CPC_From_Table ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_from_shapes.h0000744000175000017500000001002612737416175026761 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_from_shapes.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PC_From_Shapes_H #define HEADER_INCLUDED__PC_From_Shapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPC_From_Shapes : public CSG_Module { public: CPC_From_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Conversion") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PC_From_Shapes_H saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_attribute_calculator.cpp0000744000175000017500000002532312737416175031230 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_attribute_calculator.cpp // // // // Copyright (C) 2010 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_attribute_calculator.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_Attribute_Calculator::CPC_Attribute_Calculator(void) { Set_Name(_TL("Point Cloud Attribute Calculator")); Set_Author(_TL("Volker Wichmann (c) 2010-213, LASERDATA GmbH")); CSG_String s(_TW( "The Point Cloud Attribute Calculator calculates a new attribute " "based on existing attributes and a mathematical formula. " "Attribute fields are addressed by the character 'f' (for 'field') " "followed by the field number (i.e.: f1, f2, ..., fn) " "or by the field name in square brackets (e.g.: [Field Name]).\n" "Examples:\n" "sin(f1) * f2 + f3\n" "[intensity] / 1000\n\n" "The following operators are available for the formula definition:\n" )); s += CSG_Formula::Get_Help_Operators(); Set_Description(s); //----------------------------------------------------- Parameters.Add_PointCloud( NULL , "PC_IN" ,_TL("Point Cloud"), _TL("Input"), PARAMETER_INPUT ); Parameters.Add_PointCloud( NULL , "PC_OUT" ,_TL("Result"), _TL("Output"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_String( NULL , "FORMULA" , _TL("Formula"), _TL(""), SG_T("f1+f2") ); Parameters.Add_String( NULL , "NAME" , _TL("Output Field Name"), _TL(""), SG_T("Calculation") ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Field data type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("1 bit"), _TL("1 byte unsigned integer"), _TL("1 byte signed integer"), _TL("2 byte unsigned integer"), _TL("2 byte signed integer"), _TL("4 byte unsigned integer"), _TL("4 byte signed integer"), _TL("4 byte floating point"), _TL("8 byte floating point") ), 7 ); Parameters.Add_Value( NULL , "USE_NODATA" , _TL("Use NoData"), _TL("Check this in order to include NoData points in the calculation."), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------- CPC_Attribute_Calculator::~CPC_Attribute_Calculator(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_Attribute_Calculator::On_Execute(void) { CSG_PointCloud *pPC_in, *pPC_out, PC_out; TSG_Data_Type Type; bool bUseNoData; //--------------------------------------------------------- pPC_in = Parameters("PC_IN")->asPointCloud(); pPC_out = Parameters("PC_OUT")->asPointCloud(); bUseNoData = Parameters("USE_NODATA")->asBool(); switch( Parameters("TYPE")->asInt() ) { case 0: Type = SG_DATATYPE_Bit; break; case 1: Type = SG_DATATYPE_Byte; break; case 2: Type = SG_DATATYPE_Char; break; case 3: Type = SG_DATATYPE_Word; break; case 4: Type = SG_DATATYPE_Short; break; case 5: Type = SG_DATATYPE_DWord; break; case 6: Type = SG_DATATYPE_Int; break; case 7: default: Type = SG_DATATYPE_Float; break; case 8: Type = SG_DATATYPE_Double; break; } //----------------------------------------------------- if( !pPC_in->is_Valid() || pPC_in->Get_Field_Count() <= 0 || pPC_in->Get_Record_Count() <= 0 ) { Error_Set(_TL("invalid point cloud")); return( false ); } //----------------------------------------------------- CSG_Formula Formula; int nFields = pPC_in->Get_Field_Count(); int *pFields = new int[nFields]; if( !Formula.Set_Formula(Get_Formula(Parameters("FORMULA")->asString(), pPC_in, pFields, nFields)) ) { CSG_String Message; Formula.Get_Error(Message); Error_Set(Message); delete[](pFields); return( false ); } if( nFields == 0 ) { SG_UI_Msg_Add_Error(_TL("No attribute fields specified!")); delete[](pFields); return( false ); } //----------------------------------------------------- if (!pPC_out || pPC_out == pPC_in) { pPC_out = &PC_out; } pPC_out->Create(pPC_in); pPC_out->Add_Field(Parameters("NAME")->asString(), Type); //--------------------------------------------------------- CSG_Vector Values(nFields); for( int i=0; iGet_Point_Count() && Set_Progress(i, pPC_in->Get_Point_Count()); i++ ) { bool bOkay = true; pPC_out->Add_Point(pPC_in->Get_X(i), pPC_in->Get_Y(i), pPC_in->Get_Z(i)); for (int j=0; jGet_Attribute_Count(); j++) { switch (pPC_in->Get_Attribute_Type(j)) { default: pPC_out->Set_Attribute(i, j, pPC_in->Get_Attribute(i, j)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: CSG_String sAttr; pPC_in->Get_Attribute(i, j, sAttr); pPC_out->Set_Attribute(i, j, sAttr); break; } } for( int iField=0; iFieldis_NoData(i, pFields[iField]) || bUseNoData ) { Values[iField] = pPC_in->Get_Value(i, pFields[iField]); } else { bOkay = false; } } if( bOkay ) { pPC_out->Set_Value(i, pPC_in->Get_Field_Count(), Formula.Get_Value(Values.Get_Data(), nFields)); } else { pPC_out->Set_NoData(i, pPC_in->Get_Field_Count()); } } delete[](pFields); //----------------------------------------------------- if (pPC_out == &PC_out) { CSG_MetaData History = pPC_in->Get_History(); CSG_String sName = pPC_in->Get_Name(); pPC_in->Assign(pPC_out); pPC_in->Get_History() = History; pPC_in->Set_Name(sName); Parameters("PC_OUT")->Set_Value(pPC_in); } else { pPC_out->Set_Name(CSG_String::Format(SG_T("%s_%s"), pPC_in->Get_Name(), Parameters("NAME")->asString())); } return (true); } //--------------------------------------------------------- CSG_String CPC_Attribute_Calculator::Get_Formula(CSG_String sFormula, CSG_Table *pTable, int *Fields, int &nFields) { const SG_Char vars[27] = SG_T("abcdefghijklmnopqrstuvwxyz"); int iField; for(iField=pTable->Get_Field_Count()-1, nFields=0; iField>=0 && nFields<26; iField--) { bool bUse = false; CSG_String sField; sField.Printf(SG_T("f%d"), iField + 1); if( sFormula.Find(sField) >= 0 ) { sFormula.Replace(sField, CSG_String(vars[nFields])); bUse = true; } sField.Printf(SG_T("[%s]"), pTable->Get_Field_Name(iField)); if( sFormula.Find(sField) >= 0 ) { sFormula.Replace(sField, CSG_String(vars[nFields])); bUse = true; } if( bUse ) { Fields[nFields++] = iField; } } return( sFormula ); } //--------------------------------------------------------- int CPC_Attribute_Calculator::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FORMULA")) ) pParameters->Get_Parameter(SG_T("NAME"))->Set_Value(pParameter->asString()); return (true); } //--------------------------------------------------------- bool CPC_Attribute_Calculator::On_After_Execution(void) { CSG_PointCloud *pPC_out = Parameters("PC_OUT")->asPointCloud(); if (pPC_out == NULL) { pPC_out = Parameters("PC_IN")->asPointCloud(); } DataObject_Set_Parameter(pPC_out, "DISPLAY_VALUE_AGGREGATE", 3); DataObject_Set_Parameter(pPC_out, "COLORS_TYPE", 2); DataObject_Set_Parameter(pPC_out, "METRIC_ATTRIB", 2); DataObject_Set_Parameter(pPC_out, "METRIC_ZRANGE", pPC_out->Get_Minimum(2), pPC_out->Get_Maximum(2)); CSG_Colors Colors; Colors.Set_Default(255); DataObject_Set_Colors(pPC_out, Colors); if (pPC_out == Parameters("PC_IN")->asPointCloud()) { Parameters("PC_OUT")->Set_Value(DATAOBJECT_NOTSET); } return (true); }saga-2.3.1/src/modules/pointcloud/pointcloud_tools/pc_to_shapes.cpp0000744000175000017500000001312312737416176026775 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_tools // // // //-------------------------------------------------------// // // // pc_to_shapes.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pc_to_shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPC_To_Shapes::CPC_To_Shapes(void) { //----------------------------------------------------- Set_Name (_TL("Point Cloud to Shapes")); Set_Author (SG_T("O.Conrad (c) 2009")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPC_To_Shapes::On_Execute(void) { int iField; CSG_PointCloud *pPoints; CSG_Shapes *pShapes; pPoints = Parameters("POINTS") ->asPointCloud(); pShapes = Parameters("SHAPES") ->asShapes(); //----------------------------------------------------- pShapes->Create(SHAPE_TYPE_Point, pPoints->Get_Name(), NULL, SG_VERTEX_TYPE_XYZ); for(iField=2; iFieldGet_Field_Count(); iField++) { pShapes->Add_Field(pPoints->Get_Field_Name(iField), pPoints->Get_Field_Type(iField)); } //----------------------------------------------------- for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { pPoints->Set_Cursor(iPoint); CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Add_Point(pPoints->Get_X(), pPoints->Get_Y()); pShape->Set_Z(pPoints->Get_Z(), 0); for(iField=2; iFieldGet_Field_Count(); iField++) { switch (pPoints->Get_Field_Type(iField)) { default: pShape->Set_Value(iField - 2, pPoints->Get_Value(iField)); break; case SG_DATATYPE_Date: case SG_DATATYPE_String: CSG_String sAttr; pPoints->Get_Value(iField, sAttr); pShape->Set_Value(iField - 2, sAttr); break; } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/Makefile.in0000664000175000017500000004671212737447616022305 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/pointcloud ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = pointcloud_tools pointcloud_viewer am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @WITH_GUI_FALSE@SUBDIRS = pointcloud_tools @WITH_GUI_TRUE@SUBDIRS = pointcloud_viewer pointcloud_tools all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/pointcloud/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/pointcloud/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/pointcloud/Makefile.am0000744000175000017500000000014412737416175022254 0ustar00oconradoconrad00000000000000if WITH_GUI SUBDIRS = pointcloud_viewer pointcloud_tools else SUBDIRS = pointcloud_tools endif saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/0000775000175000017500000000000012737740006023754 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/points_view_module.h0000744000175000017500000001010112737416176030040 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // points_view_module // // // //-------------------------------------------------------// // // // points_view_module.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_view_module_H #define HEADER_INCLUDED__points_view_module_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_View_Module : public CSG_Module { public: CPoints_View_Module(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_view_module_H saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.h0000744000175000017500000001230612737416176030023 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // image_io // // // //-------------------------------------------------------// // // // points_view_dialog.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_view_dialog_H #define HEADER_INCLUDED__points_view_dialog_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_View_Dialog : public CSGDI_Dialog { public: CPoints_View_Dialog(CSG_PointCloud *pPoints); void Update_Rotation (void); void Update_Extent (void); private: wxButton *m_pBtn_Prop; wxCheckBox *m_pCheck_Central, *m_pCheck_Stereo, *m_pCheck_Scale; wxChoice *m_pField_Color, *m_pField_Z; wxTextCtrl *m_pFormula, *m_pParameters; CSGDI_Slider *m_pSlide_xRotate, *m_pSlide_yRotate, *m_pSlide_zRotate, *m_pSlide_Central, *m_pSlide_Detail; class CPoints_View_Control *m_pView; class CPoints_View_Extent *m_pExtent; CSG_Parameters m_Settings; void On_Update_Control (wxCommandEvent &event); void On_Update_Choices (wxCommandEvent &event); void On_Button (wxCommandEvent &event); void On_Mouse_Wheel (wxMouseEvent &event); DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_view_dialog_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/points_view_extent.cpp0000744000175000017500000003203312737416176030425 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // SAGA_GUI_API // // // //-------------------------------------------------------// // // // points_view_extent.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #ifdef __BORLANDC__ #pragma hdrstop #endif #include #include #include #include //--------------------------------------------------------- #include "points_view_extent.h" #include "points_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define m_Settings (*m_pSettings) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(CPoints_View_Extent, wxPanel) EVT_SIZE (CPoints_View_Extent::On_Size) EVT_ERASE_BACKGROUND (CPoints_View_Extent::On_EraseBackGround) EVT_PAINT (CPoints_View_Extent::On_Paint) EVT_LEFT_DOWN (CPoints_View_Extent::On_Mouse_LDown) EVT_LEFT_UP (CPoints_View_Extent::On_Mouse_LUp) EVT_RIGHT_DOWN (CPoints_View_Extent::On_Mouse_RDown) EVT_RIGHT_UP (CPoints_View_Extent::On_Mouse_RUp) EVT_MOTION (CPoints_View_Extent::On_Mouse_Motion) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_View_Extent::CPoints_View_Extent(wxWindow *pParent, CSG_PointCloud *pPoints, CSG_Parameters &Settings, wxSize Size) : wxPanel(pParent, wxID_ANY, wxDefaultPosition, Size, wxTAB_TRAVERSAL|wxSUNKEN_BORDER|wxNO_FULL_REPAINT_ON_RESIZE) { m_pPoints = pPoints; m_pSettings = &Settings; m_cField = 2; m_Select = wxRect(0, 0, GetClientSize().x - 1, GetClientSize().y - 1); //----------------------------------------------------- CSG_Parameter *pNode = m_pSettings->Add_Node(NULL, "NODE_EXTENT", _TL("Zoom View"), _TL("")); m_pSettings->Add_Range( pNode , "EXT_C_RANGE" , _TL("Colors Value Range"), _TL("") ); //----------------------------------------------------- _Draw_Image(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_View_Extent::On_Size(wxSizeEvent &event) { _Draw_Image(); event.Skip(); } //--------------------------------------------------------- void CPoints_View_Extent::On_EraseBackGround(wxEraseEvent &event) { // event.Skip(); } //--------------------------------------------------------- void CPoints_View_Extent::On_Paint(wxPaintEvent &WXUNUSED(event)) { if( m_Image.IsOk() && m_Image.GetWidth() > 0 && m_Image.GetHeight() > 0 ) { wxPaintDC dc(this); dc.DrawBitmap(wxBitmap(m_Image), 0, 0, false); dc.SetPen(wxPen(*wxRED)); int ax = m_Select.GetX(); int ay = m_Select.GetY(); int bx = m_Select.GetX() + m_Select.GetWidth(); int by = m_Select.GetY() + m_Select.GetHeight(); dc.DrawLine(ax, ay, bx, ay); dc.DrawLine(bx, ay, bx, by); dc.DrawLine(bx, by, ax, by); dc.DrawLine(ax, by, ax, ay); } } //--------------------------------------------------------- void CPoints_View_Extent::Update_View(void) { if( _Draw_Image() ) { Refresh(false); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_View_Extent::On_Mouse_LDown(wxMouseEvent &event) { m_Mouse_Down = m_Mouse_Move = event.GetPosition(); CaptureMouse(); } //--------------------------------------------------------- void CPoints_View_Extent::On_Mouse_LUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } _Draw_Inverse(m_Mouse_Down, m_Mouse_Move); wxPoint p; p.x = event.GetX() < 0 ? 0 : event.GetX() >= GetClientSize().x ? GetClientSize().x - 1 : event.GetX(); p.y = event.GetY() < 0 ? 0 : event.GetY() >= GetClientSize().y ? GetClientSize().y - 1 : event.GetY(); if( m_Mouse_Down.x != p.x || m_Mouse_Down.y != p.y ) { m_Select = wxRect(wxPoint(m_Mouse_Down.x, m_Mouse_Down.y), p); } else { m_Select.SetX(p.x - m_Select.GetWidth () / 2); m_Select.SetY(p.y - m_Select.GetHeight() / 2); } Refresh(false); ((CPoints_View_Dialog *)GetParent())->Update_Extent(); } //--------------------------------------------------------- void CPoints_View_Extent::On_Mouse_RDown(wxMouseEvent &event) { m_Mouse_Down = m_Mouse_Move = event.GetPosition(); CaptureMouse(); } //--------------------------------------------------------- void CPoints_View_Extent::On_Mouse_RUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } m_Select = wxRect(0, 0, GetClientSize().x - 1, GetClientSize().y - 1); Refresh(false); ((CPoints_View_Dialog *)GetParent())->Update_Extent(); } //--------------------------------------------------------- void CPoints_View_Extent::On_Mouse_Motion(wxMouseEvent &event) { if( HasCapture() && event.Dragging() ) { if( event.LeftIsDown() ) { _Draw_Inverse(m_Mouse_Down, m_Mouse_Move); _Draw_Inverse(m_Mouse_Down, event.GetPosition()); } } m_Mouse_Move = event.GetPosition(); } //--------------------------------------------------------- TSG_Rect CPoints_View_Extent::Get_Extent(void) { TSG_Rect r; double d = m_Extent.Get_XRange() / m_Image.GetWidth(); r.xMin = m_Extent.Get_XMin() + d * m_Select.GetX(); r.xMax = m_Extent.Get_XMin() + d * (m_Select.GetX() + m_Select.GetWidth()); r.yMax = m_Extent.Get_YMax() - d * m_Select.GetY(); r.yMin = m_Extent.Get_YMax() - d * (m_Select.GetY() + m_Select.GetHeight()); return( r ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_View_Extent::_Draw_Image(void) { if( m_pPoints->Get_Count() <= 0 || m_pPoints->Get_Extent().Get_XRange() <= 0.0 || m_pPoints->Get_Extent().Get_YRange() <= 0.0 || m_cField < 0 || m_cField >= m_pPoints->Get_Field_Count() ) { return( false ); } //------------------------------------------------- wxSize Size; double dx, dy; Size = GetClientSize(); if (Size.x <= 0 || Size.y <= 0) // temporary hack for wxGTK to suppress 'assert "isOK()" failed in Get_Height(): invalid image' return( false ); // when dlg.ShowModal() is called; during construction everything is fine, but the first call of // the On_Size() event returns a client size of 0 m_Image .Create(Size.x, Size.y); m_Image_Value .Create(Size.x, Size.y); m_Image_Count .Create(Size.x, Size.y); //------------------------------------------------- m_Extent = m_pPoints->Get_Extent(); if( (dx = Size.y / (double)Size.x) < (m_Extent.Get_YRange() / m_Extent.Get_XRange()) ) { dx = 0.5 * (m_Extent.Get_XRange() - m_Extent.Get_YRange() / dx); m_Extent.m_rect.xMin += dx; m_Extent.m_rect.xMax -= dx; } else { dy = 0.5 * (m_Extent.Get_YRange() - m_Extent.Get_XRange() * dx); m_Extent.m_rect.yMin += dy; m_Extent.m_rect.yMax -= dy; } dx = Size.x / m_Extent.Get_XRange(); dy = Size.y / m_Extent.Get_YRange(); //------------------------------------------------- bool bColorAsRGB = m_Settings("C_AS_RGB")->asBool(); for(int i=0; iGet_Count(); i++) { TSG_Point_Z p = m_pPoints->Get_Point(i); p.z = m_pPoints->Get_Value(i, m_cField); int ix = (p.x - m_Extent.Get_XMin()) * dx; int iy = (p.y - m_Extent.Get_YMin()) * dy; if( ix >= 0 && ix <= m_Image.GetWidth() && iy >= 0 && iy < m_Image.GetHeight() ) { if( !bColorAsRGB ) { m_Image_Value[iy][ix] += p.z; } else { m_Image_Value[iy][ix] = p.z; } m_Image_Count[iy][ix]++; } } //------------------------------------------------- double zMin = m_pPoints->Get_Mean(m_cField) - 1.5 * m_pPoints->Get_StdDev(m_cField); double zRange = m_pPoints->Get_Mean(m_cField) + 1.5 * m_pPoints->Get_StdDev(m_cField) - zMin; CSG_Colors *pColors = m_Settings("COLORS")->asColors(); for(int iy=0; iy 0 ) { if( !bColorAsRGB ) { int ic = (int)(pColors->Get_Count() * (m_Image_Value[iy][ix] / m_Image_Count[iy][ix] - zMin) / zRange); int c = pColors->Get_Color(ic < 0 ? 0 : ic >= pColors->Get_Count() ? pColors->Get_Count() - 1 : ic); _Draw_Pixel(ix, iy, c); } else { _Draw_Pixel(ix, iy, m_Image_Value[iy][ix]); } } else { _Draw_Pixel(ix, iy, 0); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CPoints_View_Extent::_Draw_Pixel(int x, int y, int color) { if( x >= 0 && x < m_Image.GetWidth() && y >= 0 && y < m_Image.GetHeight() ) { BYTE *pRGB = m_Image.GetData() + 3 * ((m_Image.GetHeight() - y - 1) * m_Image.GetWidth() + x); *pRGB = SG_GET_R(color); pRGB++; *pRGB = SG_GET_G(color); pRGB++; *pRGB = SG_GET_B(color); } } //--------------------------------------------------------- void CPoints_View_Extent::_Draw_Inverse(wxPoint pa, wxPoint pb) { wxClientDC dc(this); dc.SetLogicalFunction(wxINVERT); dc.DrawRectangle(pa.x, pa.y, pb.x - pa.x, pb.y - pa.y); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/Makefile.in0000664000175000017500000005663112737447617026050 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/pointcloud/pointcloud_viewer ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libpointcloud_viewer_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la \ $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la am_libpointcloud_viewer_la_OBJECTS = MLB_Interface.lo \ points_view_control.lo points_view_dialog.lo \ points_view_extent.lo points_view_module.lo libpointcloud_viewer_la_OBJECTS = \ $(am_libpointcloud_viewer_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libpointcloud_viewer_la_SOURCES) DIST_SOURCES = $(libpointcloud_viewer_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libpointcloud_viewer.la libpointcloud_viewer_la_SOURCES = \ MLB_Interface.cpp\ points_view_control.cpp\ points_view_dialog.cpp\ points_view_extent.cpp\ points_view_module.cpp\ MLB_Interface.h\ points_view_control.h\ points_view_dialog.h\ points_view_extent.h\ points_view_module.h libpointcloud_viewer_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la $(ADD_MLBS) all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/pointcloud/pointcloud_viewer/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/pointcloud/pointcloud_viewer/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libpointcloud_viewer.la: $(libpointcloud_viewer_la_OBJECTS) $(libpointcloud_viewer_la_DEPENDENCIES) $(EXTRA_libpointcloud_viewer_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libpointcloud_viewer_la_OBJECTS) $(libpointcloud_viewer_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_view_control.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_view_dialog.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_view_extent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/points_view_module.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/points_view_dialog.cpp0000744000175000017500000002242612737416176030362 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // point_cloud_viewer // // // //-------------------------------------------------------// // // // points_view_dialog.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "points_view_control.h" #include "points_view_extent.h" #include "points_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(CPoints_View_Dialog, CSGDI_Dialog) EVT_MOUSEWHEEL (CPoints_View_Dialog::On_Mouse_Wheel) EVT_BUTTON (wxID_ANY , CPoints_View_Dialog::On_Button) EVT_CHECKBOX (wxID_ANY , CPoints_View_Dialog::On_Update_Control) EVT_TEXT_ENTER (wxID_ANY , CPoints_View_Dialog::On_Update_Control) EVT_SLIDER (wxID_ANY , CPoints_View_Dialog::On_Update_Control) EVT_CHOICE (wxID_ANY , CPoints_View_Dialog::On_Update_Choices) END_EVENT_TABLE() //--------------------------------------------------------- CPoints_View_Dialog::CPoints_View_Dialog(CSG_PointCloud *pPoints) : CSGDI_Dialog(_TL("Point Cloud Viewer"), SGDI_DLG_STYLE_START_MAXIMISED) { SetWindowStyle(wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE); //----------------------------------------------------- m_Settings.Create(NULL, _TL("Point Cloud Viewer Settings"), _TL("")); m_pView = new CPoints_View_Control (this, pPoints, m_Settings); m_pExtent = new CPoints_View_Extent (this, pPoints, m_Settings, wxSize(200, 200)); //----------------------------------------------------- wxArrayString Attributes; for(int i=0; iGet_Field_Count(); i++) { Attributes.Add(pPoints->Get_Field_Name(i)); } //----------------------------------------------------- Add_Button(_TL("Close"), wxID_OK); m_pBtn_Prop = Add_Button (_TL("Advanced Settings") , wxID_ANY); Add_Spacer(); m_pField_Z = Add_Choice (_TL("Z Attribute") , Attributes, m_pView->m_zField); m_pField_Color = Add_Choice (_TL("Color Attribute") , Attributes, m_pView->m_cField); Add_Spacer(); m_pCheck_Central = Add_CheckBox (_TL("Central Projection") , m_pView->m_bCentral); m_pCheck_Stereo = Add_CheckBox (_TL("Anaglyph") , m_pView->m_bStereo); m_pCheck_Scale = Add_CheckBox (_TL("Scale Point Size") , m_pView->m_bScale); Add_Spacer(); m_pSlide_xRotate = Add_Slider (_TL("X-Rotation") , m_pView->m_xRotate * M_RAD_TO_DEG, -180.0, 180.0); m_pSlide_yRotate = Add_Slider (_TL("Y-Rotation") , m_pView->m_yRotate * M_RAD_TO_DEG, -180.0, 180.0); m_pSlide_zRotate = Add_Slider (_TL("Z-Rotation") , m_pView->m_zRotate * M_RAD_TO_DEG, -180.0, 180.0); m_pSlide_Central = Add_Slider (_TL("Eye Distance") , m_pView->m_dCentral, 1.0, 2000.0); m_pSlide_Detail = Add_Slider (_TL("Level of Detail") , m_pView->m_Detail, 0.0, 1.0); // Add_Spacer(); // m_pParameters = Add_TextCtrl (_TL("Function Parameters"), wxTE_MULTILINE|wxTE_READONLY); Add_Spacer(); Add_CustomCtrl(_TL("Extent"), m_pExtent); Add_Output(m_pView); } //--------------------------------------------------------- void CPoints_View_Dialog::On_Mouse_Wheel(wxMouseEvent &event) { m_pView->On_Mouse_Wheel(event); } //--------------------------------------------------------- void CPoints_View_Dialog::On_Update_Control(wxCommandEvent &event) { if( event.GetEventObject() == m_pCheck_Central ) { m_pView->m_bCentral = m_pCheck_Central ->GetValue() == 1 ? 1 : 0; } else if( event.GetEventObject() == m_pCheck_Stereo ) { m_pView->m_bStereo = m_pCheck_Stereo ->GetValue() == 1 ? 1 : 0; } else if( event.GetEventObject() == m_pCheck_Scale ) { m_pView->m_bScale = m_pCheck_Scale ->GetValue() == 1 ? 1 : 0; } else if( event.GetEventObject() == m_pSlide_xRotate ) { m_pView->m_xRotate = m_pSlide_xRotate ->Get_Value() * M_DEG_TO_RAD; } else if( event.GetEventObject() == m_pSlide_yRotate ) { m_pView->m_yRotate = m_pSlide_yRotate ->Get_Value() * M_DEG_TO_RAD; } else if( event.GetEventObject() == m_pSlide_zRotate ) { m_pView->m_zRotate = m_pSlide_zRotate ->Get_Value() * M_DEG_TO_RAD; } else if( event.GetEventObject() == m_pSlide_Central ) { m_pView->m_dCentral = m_pSlide_Central ->Get_Value(); } else if( event.GetEventObject() == m_pSlide_Detail ) { m_pView->m_Detail = m_pSlide_Detail ->Get_Value(); } else { return; } m_pView->Update_View(); } //--------------------------------------------------------- void CPoints_View_Dialog::On_Update_Choices(wxCommandEvent &event) { if( event.GetEventObject() == m_pField_Z ) { m_pView ->m_zField = m_pField_Z ->GetSelection(); m_pView ->Update_View(); } else if( event.GetEventObject() == m_pField_Color ) { m_Settings("C_RANGE")->asRange()->Set_Range(0.0, 0.0); m_pExtent ->m_cField = m_pField_Color->GetSelection(); m_pView ->m_cField = m_pField_Color->GetSelection(); m_pExtent ->Update_View(); m_pView ->Update_Extent(m_pExtent->Get_Extent()); } else { return; } } //--------------------------------------------------------- void CPoints_View_Dialog::On_Button(wxCommandEvent &event) { if( event.GetEventObject() == m_pBtn_Prop ) { if( SG_UI_Dlg_Parameters(&m_Settings, m_Settings.Get_Name()) ) { m_pExtent ->Update_View(); m_pView ->Update_View(); } } else { event.Skip(); } } //--------------------------------------------------------- void CPoints_View_Dialog::Update_Extent(void) { m_pView->Update_Extent(m_pExtent->Get_Extent()); } //--------------------------------------------------------- void CPoints_View_Dialog::Update_Rotation(void) { double d; d = fmod(M_RAD_TO_DEG * m_pView->m_xRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0; m_pSlide_xRotate->Set_Value(d); d = fmod(M_RAD_TO_DEG * m_pView->m_yRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0; m_pSlide_yRotate->Set_Value(d); d = fmod(M_RAD_TO_DEG * m_pView->m_zRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0; m_pSlide_zRotate->Set_Value(d); m_pCheck_Scale ->SetValue(m_pView->m_bScale); m_pCheck_Stereo ->SetValue(m_pView->m_bStereo); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/points_view_extent.h0000744000175000017500000001263612737416176030101 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // SAGA_GUI_API // // // //-------------------------------------------------------// // // // points_view_extent.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_view_extent_H #define HEADER_INCLUDED__points_view_extent_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_View_Extent : public wxPanel { public: CPoints_View_Extent(wxWindow *pParent, CSG_PointCloud *pPoints, CSG_Parameters &Settings, wxSize Size); int m_cField; void Update_View (void); void On_Size (wxSizeEvent &event); void On_EraseBackGround (wxEraseEvent &event); void On_Paint (wxPaintEvent &event); void On_Mouse_LDown (wxMouseEvent &event); void On_Mouse_LUp (wxMouseEvent &event); void On_Mouse_RDown (wxMouseEvent &event); void On_Mouse_RUp (wxMouseEvent &event); void On_Mouse_Motion (wxMouseEvent &event); TSG_Rect Get_Extent (void); private: CSG_Rect m_Extent; CSG_Matrix m_Image_Value, m_Image_Count; CSG_PointCloud *m_pPoints; CSG_Parameters *m_pSettings; wxPoint m_Mouse_Down, m_Mouse_Move; wxRect m_Select; wxImage m_Image; bool _Draw_Image (void); void _Draw_Pixel (int x, int y, int color); void _Draw_Inverse (wxPoint pa, wxPoint pb); DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_view_extent_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/Makefile.am0000744000175000017500000000157212737416176026024 0ustar00oconradoconrad00000000000000if DEBUG DBGFLAGS = -g -DDEBUG endif DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libpointcloud_viewer.la libpointcloud_viewer_la_SOURCES =\ MLB_Interface.cpp\ points_view_control.cpp\ points_view_dialog.cpp\ points_view_extent.cpp\ points_view_module.cpp\ MLB_Interface.h\ points_view_control.h\ points_view_dialog.h\ points_view_extent.h\ points_view_module.h libpointcloud_viewer_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la $(ADD_MLBS) saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/points_view_control.cpp0000744000175000017500000005621012737416176030601 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // SAGA_GUI_API // // // //-------------------------------------------------------// // // // points_view_control.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #ifdef __BORLANDC__ #pragma hdrstop #endif #include #include #include #include //--------------------------------------------------------- #include "points_view_control.h" #include "points_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define m_Settings (*m_pSettings) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(CPoints_View_Control, wxPanel) EVT_SIZE (CPoints_View_Control::On_Size) EVT_PAINT (CPoints_View_Control::On_Paint) EVT_KEY_DOWN (CPoints_View_Control::On_Key_Down) EVT_LEFT_DOWN (CPoints_View_Control::On_Mouse_LDown) EVT_LEFT_UP (CPoints_View_Control::On_Mouse_LUp) EVT_RIGHT_DOWN (CPoints_View_Control::On_Mouse_RDown) EVT_RIGHT_UP (CPoints_View_Control::On_Mouse_RUp) EVT_MIDDLE_DOWN (CPoints_View_Control::On_Mouse_MDown) EVT_MIDDLE_UP (CPoints_View_Control::On_Mouse_MUp) EVT_MOTION (CPoints_View_Control::On_Mouse_Motion) EVT_MOUSEWHEEL (CPoints_View_Control::On_Mouse_Wheel) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_View_Control::CPoints_View_Control(wxWindow *pParent, CSG_PointCloud *pPoints, CSG_Parameters &Settings) : wxPanel(pParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxSUNKEN_BORDER|wxNO_FULL_REPAINT_ON_RESIZE) { m_pPoints = pPoints; m_pSettings = &Settings; m_zField = 2; m_cField = 2; m_xRotate = 0.0; m_yRotate = 0.0; m_zRotate = 0.0; m_xShift = 0.0; m_yShift = 0.0; m_zShift = 1000.0; m_bCentral = true; m_bStereo = false; m_bScale = false; m_dCentral = 500.0; m_Detail = 1.0; //----------------------------------------------------- CSG_Parameter *pNode = m_pSettings->Add_Node(NULL, "NODE_CONTROL", _TL("3D View"), _TL("")); m_pSettings->Add_Colors( pNode , "COLORS" , _TL("Colors"), _TL("") ); m_pSettings->Add_Value( pNode , "BGCOLOR" , _TL("Background Color"), _TL(""), PARAMETER_TYPE_Color, 0 ); m_pSettings->Add_Range( pNode , "C_RANGE" , _TL("Colors Value Range"), _TL("") ); m_pSettings->Add_Value( pNode , "C_AS_RGB" , _TL("Value as RGB Code"), _TL(""), PARAMETER_TYPE_Bool, false ); m_pSettings->Add_Value( pNode , "SIZE_DEF" , _TL("Point Size: Default"), _TL(""), PARAMETER_TYPE_Int, 0, 0, true ); m_pSettings->Add_Value( pNode , "SIZE_SCALE" , _TL("Point Size: Scaling"), _TL(""), PARAMETER_TYPE_Double, 250.0, 1.0, true ); m_pSettings->Add_Value( pNode , "EXAGGERATION" , _TL("Exaggeration"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); m_pSettings->Add_Value( pNode , "STEREO_DIST" , _TL("Stereo Eye Distance [Degree]"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); pNode = m_pSettings->Add_Value( pNode , "DIM" , _TL("Dim Colours"), _TL(""), PARAMETER_TYPE_Bool, false ); pNode = m_pSettings->Add_Range( pNode , "DIM_RANGE" , _TL("Dim Range"), _TL(""), 0.0, 1.0, 0.0, true ); //----------------------------------------------------- m_pSelection = (int *)SG_Malloc(m_pPoints->Get_Count() * sizeof(int)); Update_Extent(m_pPoints->Get_Extent()); } //--------------------------------------------------------- CPoints_View_Control::~CPoints_View_Control(void) { if( m_pSelection ) { SG_Free(m_pSelection); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_View_Control::On_Size(wxSizeEvent &event) { _Set_Size(); event.Skip(); } //--------------------------------------------------------- void CPoints_View_Control::On_Paint(wxPaintEvent &WXUNUSED(event)) { if( m_Image.IsOk() && m_Image.GetWidth() > 0 && m_Image.GetHeight() > 0 ) { wxPaintDC dc(this); dc.DrawBitmap(wxBitmap(m_Image), 0, 0, false); } } //--------------------------------------------------------- void CPoints_View_Control::Update_View(void) { if( _Draw_Image() ) { wxClientDC dc(this); dc.DrawBitmap(wxBitmap(m_Image), 0, 0, false); } } //--------------------------------------------------------- void CPoints_View_Control::Update_Extent(CSG_Rect Extent) { m_Extent.Assign(Extent); m_zStats.Invalidate(); m_cStats.Invalidate(); m_nSelection = 0; for(int i=0; iGet_Count(); i++) { m_pPoints->Set_Cursor(i); TSG_Point_Z p = m_pPoints->Get_Point(); if( m_Extent.Contains(p.x, p.y) ) { m_pSelection[m_nSelection++] = i; m_zStats.Add_Value(m_pPoints->Get_Value(m_zField)); m_cStats.Add_Value(m_pPoints->Get_Value(m_cField)); } } m_Settings("C_RANGE")->asRange()->Set_Range( m_cStats.Get_Mean() - 1.5 * m_cStats.Get_StdDev(), m_cStats.Get_Mean() + 1.5 * m_cStats.Get_StdDev() ); Update_View(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_View_Control::On_Key_Down(wxKeyEvent &event) { switch( event.GetKeyCode() ) { default: event.Skip(); return; case WXK_NUMPAD_ADD: case WXK_ADD: m_xRotate -= 4.0 * M_DEG_TO_RAD; break; case WXK_NUMPAD_SUBTRACT: case WXK_SUBTRACT: m_xRotate += 4.0 * M_DEG_TO_RAD; break; case WXK_F3: m_yRotate -= 4.0 * M_DEG_TO_RAD; break; case WXK_F4: m_yRotate += 4.0 * M_DEG_TO_RAD; break; case WXK_NUMPAD_MULTIPLY: case WXK_MULTIPLY: m_zRotate -= 4.0 * M_DEG_TO_RAD; break; case WXK_NUMPAD_DIVIDE: case WXK_DIVIDE: m_zRotate += 4.0 * M_DEG_TO_RAD; break; case WXK_INSERT: m_xShift -= 10.0; break; case WXK_DELETE: m_xShift += 10.0; break; case WXK_HOME: m_yShift -= 10.0; break; case WXK_END: m_yShift += 10.0; break; case WXK_PAGEUP: m_zShift -= 10.0; break; case WXK_PAGEDOWN: m_zShift += 10.0; break; case 'A': m_bStereo = !m_bStereo; break; case 'S': m_bScale = !m_bScale; break; case 'C': m_Settings("C_AS_RGB") ->Set_Value(m_Settings("C_AS_RGB")->asBool() ? 0.0 : 1.0); break; case WXK_F1: m_Settings("EXAGGERATION")->Set_Value(m_Settings("EXAGGERATION")->asDouble() + 0.5); break; case WXK_F2: m_Settings("EXAGGERATION")->Set_Value(m_Settings("EXAGGERATION")->asDouble() - 0.5); break; case WXK_F5: m_Settings("SIZE_DEF") ->Set_Value(m_Settings("SIZE_DEF") ->asDouble() - 1.0); break; case WXK_F6: m_Settings("SIZE_DEF") ->Set_Value(m_Settings("SIZE_DEF") ->asDouble() + 1.0); break; case WXK_F7: m_Settings("SIZE_SCALE") ->Set_Value(m_Settings("SIZE_SCALE") ->asDouble() - 10.0); break; case WXK_F8: m_Settings("SIZE_SCALE") ->Set_Value(m_Settings("SIZE_SCALE") ->asDouble() + 10.0); break; } Update_View(); ((CPoints_View_Dialog *)GetParent())->Update_Rotation(); } //--------------------------------------------------------- #define GET_MOUSE_X_RELDIFF ((double)(m_Mouse_Down.x - event.GetX()) / (double)GetClientSize().x) #define GET_MOUSE_Y_RELDIFF ((double)(m_Mouse_Down.y - event.GetY()) / (double)GetClientSize().y) //--------------------------------------------------------- void CPoints_View_Control::On_Mouse_LDown(wxMouseEvent &event) { SetFocus(); m_Mouse_Down = event.GetPosition(); m_xDown = m_zRotate; m_yDown = m_xRotate; if( !HasCapture() ) { CaptureMouse(); } } void CPoints_View_Control::On_Mouse_LUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } if( m_Mouse_Down.x != event.GetX() || m_Mouse_Down.y != event.GetY() ) { m_zRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_xRotate = m_yDown + GET_MOUSE_Y_RELDIFF * M_PI_180; Update_View(); ((CPoints_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CPoints_View_Control::On_Mouse_RDown(wxMouseEvent &event) { SetFocus(); m_Mouse_Down = event.GetPosition(); m_xDown = m_xShift; m_yDown = m_yShift; if( !HasCapture() ) { CaptureMouse(); } } void CPoints_View_Control::On_Mouse_RUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } if( m_Mouse_Down.x != event.GetX() || m_Mouse_Down.y != event.GetY() ) { m_xShift = m_xDown - GET_MOUSE_X_RELDIFF * 1000.0; m_yShift = m_yDown - GET_MOUSE_Y_RELDIFF * 1000.0; Update_View(); ((CPoints_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CPoints_View_Control::On_Mouse_MDown(wxMouseEvent &event) { SetFocus(); m_Mouse_Down = event.GetPosition(); m_xDown = m_yRotate; m_yDown = m_zShift; if( !HasCapture() ) { CaptureMouse(); } } void CPoints_View_Control::On_Mouse_MUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } if( m_Mouse_Down.x != event.GetX() || m_Mouse_Down.y != event.GetY() ) { m_yRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_zShift = m_yDown + GET_MOUSE_Y_RELDIFF * 1000.0; Update_View(); ((CPoints_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CPoints_View_Control::On_Mouse_Motion(wxMouseEvent &event) { if( HasCapture() && event.Dragging() ) { if( event.LeftIsDown() ) { m_zRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_xRotate = m_yDown + GET_MOUSE_Y_RELDIFF * M_PI_180; } else if( event.RightIsDown() ) { m_xShift = m_xDown - GET_MOUSE_X_RELDIFF * 1000.0; m_yShift = m_yDown - GET_MOUSE_Y_RELDIFF * 1000.0; } else if( event.MiddleIsDown() ) { m_yRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_zShift = m_yDown + GET_MOUSE_Y_RELDIFF * 1000.0; } else { return; } Update_View(); ((CPoints_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CPoints_View_Control::On_Mouse_Wheel(wxMouseEvent &event) { if( event.GetWheelRotation() ) { m_zShift += 0.5 * event.GetWheelRotation(); Update_View(); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPoints_View_Control::_Set_Size(void) { Update_View(); } //--------------------------------------------------------- bool CPoints_View_Control::_Draw_Image(void) { wxSize dcSize = GetClientSize(); if( m_pPoints->Get_Count() <= 0 || dcSize.x <= 0 || dcSize.y <= 0 || m_Extent.Get_XRange() <= 0.0 || m_Extent.Get_YRange() <= 0.0 || m_zField < 0 || m_zField >= m_pPoints->Get_Field_Count() || m_cField < 0 || m_cField >= m_pPoints->Get_Field_Count() || m_zStats.Get_Range() <= 0.0 ) { return( false ); } //------------------------------------------------- if( !m_Image.IsOk() || dcSize.x != m_Image.GetWidth() || dcSize.y != m_Image.GetHeight() ) { m_Image .Create(dcSize.x, dcSize.y); m_Image_zMax.Create(dcSize.x, dcSize.y); } //------------------------------------------------- if( m_Settings("C_RANGE")->asRange()->Get_LoVal() >= m_Settings("C_RANGE")->asRange()->Get_HiVal() ) { m_Settings("C_RANGE")->asRange()->Set_Range( m_cStats.Get_Mean() - 1.5 * m_pPoints->Get_StdDev(m_cField), m_cStats.Get_Mean() + 1.5 * m_pPoints->Get_StdDev(m_cField) ); } m_pColors = m_Settings("COLORS")->asColors(); m_cMin = m_Settings("C_RANGE")->asRange()->Get_LoVal(); m_cScale = m_pColors->Get_Count() / (m_Settings("C_RANGE")->asRange()->Get_HiVal() - m_cMin); m_BGColor = m_Settings("BGCOLOR")->asColor(); //------------------------------------------------- if( (dcSize.x / (double)dcSize.y) > (m_Extent.Get_XRange() / m_Extent.Get_YRange()) ) { r_Scale = m_Image.GetWidth() / m_Extent.Get_XRange(); } else { r_Scale = m_Image.GetHeight() / m_Extent.Get_YRange(); } r_sin_x = sin(m_xRotate - M_PI_180); r_cos_x = cos(m_xRotate - M_PI_180); r_sin_y = sin(m_yRotate); r_cos_y = cos(m_yRotate); r_sin_z = sin(m_zRotate); r_cos_z = cos(m_zRotate); r_xc = m_Extent.Get_XCenter(); r_yc = m_Extent.Get_YCenter(); r_zc = m_zStats.Get_Minimum() + 0.5 * m_zStats.Get_Range(); r_Scale_z = r_Scale * m_Settings("EXAGGERATION")->asDouble(); //------------------------------------------------- // guess zmin, zmax TSG_Point_Z p; p.x = m_Extent.Get_XMin(); p.y = m_Extent.Get_YMin(); p.z = m_pPoints->Get_Value(m_zStats.Get_Minimum()); p = _Get_Projection(p); m_zMin = m_zMax = p.z; p.x = m_Extent.Get_XMin(); p.y = m_Extent.Get_YMin(); p.z = m_pPoints->Get_Value(m_zStats.Get_Maximum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMax(); p.y = m_Extent.Get_YMin(); p.z = m_pPoints->Get_Value(m_zStats.Get_Minimum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMax(); p.y = m_Extent.Get_YMin(); p.z = m_pPoints->Get_Value(m_zStats.Get_Maximum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMin(); p.y = m_Extent.Get_YMax(); p.z = m_pPoints->Get_Value(m_zStats.Get_Minimum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMin(); p.y = m_Extent.Get_YMax(); p.z = m_pPoints->Get_Value(m_zStats.Get_Maximum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMax(); p.y = m_Extent.Get_YMax(); p.z = m_pPoints->Get_Value(m_zStats.Get_Minimum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; p.x = m_Extent.Get_XMax(); p.y = m_Extent.Get_YMax(); p.z = m_pPoints->Get_Value(m_zStats.Get_Maximum()); p = _Get_Projection(p); if( m_zMin > p.z ) m_zMin = p.z; else if( m_zMax < p.z ) m_zMax = p.z; //------------------------------------------------- m_Size_Def = m_Settings("SIZE_DEF")->asInt(); m_Size_Scale = 1.0 / m_Settings("SIZE_SCALE")->asDouble(); m_bColorAsRGB = m_Settings("C_AS_RGB")->asBool(); m_bDim = m_Settings("DIM")->asBool(); m_Dim_A = m_zMin + m_Settings("DIM_RANGE")->asRange()->Get_LoVal() * (m_zMax - m_zMin); m_Dim_B = m_zMin + m_Settings("DIM_RANGE")->asRange()->Get_HiVal() * (m_zMax - m_zMin); int iSelection; int nSkip = 1 + (int)(0.001 * m_pPoints->Get_Count() * SG_Get_Square(1.0 - m_Detail)); _Draw_Background(); //------------------------------------------------- if( m_bStereo == false ) { m_Image_zMax.Assign(999999.0); m_Color_Mode = COLOR_MODE_RGB; for(iSelection=0; iSelectionasDouble() / 2.0; m_Image_zMax.Assign(999999.0); r_sin_y = sin(m_yRotate - d * M_DEG_TO_RAD); r_cos_y = cos(m_yRotate - d * M_DEG_TO_RAD); m_Color_Mode = COLOR_MODE_RED; for(iSelection=0; iSelectionSet_Cursor(iPoint); p = m_pPoints->Get_Point(); p.z = m_pPoints->Get_Value(m_zField); p = _Get_Projection(p); p.x = (int)(p.x + 0.5 * m_Image.GetWidth()); p.y = (int)(p.y + 0.5 * m_Image.GetHeight()); if( !m_bColorAsRGB ) { iColor = (int)(m_cScale * (m_pPoints->Get_Value(m_cField) - m_cMin)); iColor = m_pColors->Get_Color(iColor < 0 ? 0 : (iColor >= m_pColors->Get_Count() ? m_pColors->Get_Count() - 1 : iColor)); } else { iColor = (int)m_pPoints->Get_Value(m_cField); } if( m_bDim ) { double dim = 1.0 - (p.z - m_Dim_A) / (m_Dim_B - m_Dim_A); if( dim < 1.0 ) { if( dim <= 0.1 ) { dim = 0.1; } iColor = SG_GET_RGB( SG_GET_R(m_BGColor) + (int)((SG_GET_R(iColor) - SG_GET_R(m_BGColor)) * dim), SG_GET_G(m_BGColor) + (int)((SG_GET_G(iColor) - SG_GET_G(m_BGColor)) * dim), SG_GET_B(m_BGColor) + (int)((SG_GET_B(iColor) - SG_GET_B(m_BGColor)) * dim) ); } } _Draw_Point(p.x, p.y, p.z, iColor, m_Size_Def + (!m_bScale ? 0 : (int)(20.0 * exp(-m_Size_Scale * p.z)))); } //--------------------------------------------------------- inline void CPoints_View_Control::_Draw_Point(int x, int y, double z, int color, int Size) { if( z > 0.0 ) { _Draw_Pixel(x, y, z, color); if( Size > 0 && Size < 50 ) { for(int iy=1; iy<=Size; iy++) { for(int ix=0; ix<=Size; ix++) { if( ix*ix + iy*iy <= Size*Size ) { _Draw_Pixel(x + ix, y + iy, z, color); _Draw_Pixel(x + iy, y - ix, z, color); _Draw_Pixel(x - ix, y - iy, z, color); _Draw_Pixel(x - iy, y + ix, z, color); } } } } } } //--------------------------------------------------------- inline void CPoints_View_Control::_Draw_Pixel(int x, int y, double z, int color) { if( x >= 0 && x < m_Image.GetWidth() && y >= 0 && y < m_Image.GetHeight() && z < m_Image_zMax[y][x] ) { BYTE *pRGB = m_Image.GetData() + 3 * (y * m_Image.GetWidth() + x); switch( m_Color_Mode ) { case COLOR_MODE_RGB: *pRGB = SG_GET_R(color); pRGB++; *pRGB = SG_GET_G(color); pRGB++; *pRGB = SG_GET_B(color); break; case COLOR_MODE_RED: *pRGB = ((SG_GET_R(color) + SG_GET_G(color) + SG_GET_B(color)) / 3); break; case COLOR_MODE_BLUE: *(pRGB + 1) = ((SG_GET_R(color) + SG_GET_G(color) + SG_GET_B(color)) / 3); *(pRGB + 2) = ((SG_GET_R(color) + SG_GET_G(color) + SG_GET_B(color)) / 3); break; } m_Image_zMax[y][x] = z; } } //--------------------------------------------------------- inline TSG_Point_Z CPoints_View_Control::_Get_Projection(TSG_Point_Z p) { TSG_Point_Z q; p.x = (p.x - r_xc) * r_Scale; p.y = (p.y - r_yc) * r_Scale; p.z = (p.z - r_zc) * r_Scale_z; double a = (r_cos_y * p.z + r_sin_y * (r_sin_z * p.y + r_cos_z * p.x)); double b = (r_cos_z * p.y - r_sin_z * p.x); q.x = r_cos_y * (r_sin_z * p.y + r_cos_z * p.x) - r_sin_y * p.z; q.y = r_sin_x * a + r_cos_x * b; q.z = r_cos_x * a - r_sin_x * b; q.x += m_xShift; q.y += m_yShift; q.z += m_zShift; if( m_bCentral ) { q.x *= m_dCentral / q.z; q.y *= m_dCentral / q.z; } else { double z = m_dCentral / m_zShift; q.x *= z; q.y *= z; // q.z = -q.z; } return( q ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/MLB_Interface.h0000744000175000017500000000752112737416176026533 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_viewer // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pointcloud_viewer_mlb_H #define HEADER_INCLUDED__pointcloud_viewer_mlb_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef pointcloud_viewer_EXPORTS #define pointcloud_viewer_EXPORT _SAGA_DLL_EXPORT #else #define pointcloud_viewer_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pointcloud_viewer_mlb_H saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/points_view_control.h0000744000175000017500000001506312737416176030247 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // SAGA_GUI_API // // // //-------------------------------------------------------// // // // points_view_control.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__points_view_control_H #define HEADER_INCLUDED__points_view_control_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { COLOR_MODE_RGB, COLOR_MODE_RED, COLOR_MODE_BLUE }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPoints_View_Control : public wxPanel { public: CPoints_View_Control(wxWindow *pParent, CSG_PointCloud *pPoints, CSG_Parameters &Settings); virtual ~CPoints_View_Control(void); bool m_bCentral, m_bStereo, m_bScale; int m_zField, m_cField; double m_xRotate, m_yRotate, m_zRotate, m_xShift, m_yShift, m_zShift, m_dCentral, m_Detail; void Update_View (void); void Update_Extent (CSG_Rect Extent); void On_Size (wxSizeEvent &event); void On_Paint (wxPaintEvent &event); void On_Key_Down (wxKeyEvent &event); void On_Mouse_LDown (wxMouseEvent &event); void On_Mouse_LUp (wxMouseEvent &event); void On_Mouse_RDown (wxMouseEvent &event); void On_Mouse_RUp (wxMouseEvent &event); void On_Mouse_MDown (wxMouseEvent &event); void On_Mouse_MUp (wxMouseEvent &event); void On_Mouse_Motion (wxMouseEvent &event); void On_Mouse_Wheel (wxMouseEvent &event); private: bool m_bColorAsRGB, m_bDim; int m_nSelection, *m_pSelection, m_Color_Mode, m_Size_Def, m_BGColor; double m_xDown, m_yDown, m_cMin, m_cScale, m_Size_Scale, m_Dim_A, m_Dim_B, m_zMin, m_zMax; double r_sin_x, r_sin_y, r_sin_z, r_cos_x, r_cos_y, r_cos_z, r_xc, r_yc, r_zc, r_Scale, r_Scale_z; CSG_Rect m_Extent; CSG_Matrix m_Image_zMax; CSG_Simple_Statistics m_zStats, m_cStats; CSG_Parameters *m_pSettings; CSG_Colors *m_pColors; CSG_PointCloud *m_pPoints; wxPoint m_Mouse_Down; wxImage m_Image; void _Set_Size (void); bool _Draw_Image (void); void _Draw_Background (void); void _Draw_Point (int iPoint); void _Draw_Point (int x, int y, double z, int color, int Size); void _Draw_Pixel (int x, int y, double z, int color); TSG_Point_Z _Get_Projection (TSG_Point_Z p); DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_view_control_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/MLB_Interface.cpp0000744000175000017500000001070312737416176027062 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_viewer // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Point Clouds Viewer") ); case MLB_INFO_Category: return( _TL("Visualization") ); case MLB_INFO_Author: return( SG_T("O.Conrad (c) 2009") ); case MLB_INFO_Description: return( _TL("Point clouds viewer." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Visualization|3D Viewer" )); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "points_view_module.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CPoints_View_Module ); default: return( NULL ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/pointcloud/pointcloud_viewer/points_view_module.cpp0000744000175000017500000001240512737416176030404 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // points_view_module // // // //-------------------------------------------------------// // // // points_view_module.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "points_view_module.h" #include "points_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPoints_View_Module::CPoints_View_Module(void) { //----------------------------------------------------- Set_Name (_TL("[deprecated] Point Cloud Viewer")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "This module is a 3D viewer for SAGA Point Clouds. Amongst others, " "the viewer supports attribute based coloring, a map view to control " "the area-of-interest, point size scaling based on distance, level " "of detail control and an anaglyph modus (to use with red/blue or " "red/green glasses).\n\n" "Module development was supported by " "http://Laserdata GmbH, Austria\n" "and " "http://alpS GmbH, Austria\n" )); //----------------------------------------------------- Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPoints_View_Module::On_Execute(void) { if( !SG_UI_Get_Window_Main() ) { Message_Add(_TL("point cloud viewer can only be run from graphical user interface")); return( false ); } CSG_PointCloud *pPoints = Parameters("POINTS")->asPointCloud(); if( pPoints->Get_Count() <= 0 ) { Message_Add(_TL("point cloud viewer will not be started, because point cloud has no points")); return( false ); } CPoints_View_Dialog dlg(pPoints); dlg.ShowModal(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/0000775000175000017500000000000012737740010016620 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/tin/tin_tools/0000775000175000017500000000000012737740010020632 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/tin/tin_tools/TIN_To_Shapes.cpp0000744000175000017500000002305212737416217023747 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_To_Shapes.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "TIN_To_Shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTIN_To_Shapes::CTIN_To_Shapes(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name(_TL("TIN to Shapes")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description( _TL("Converts a TIN data set to shapes layers.\n\n") ); //----------------------------------------------------- pNode = Parameters.Add_TIN( NULL , "TIN" , _TL("TIN"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "CENTER" , _TL("Center of Triangles"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "EDGES" , _TL("Edges"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "TRIANGLES" , _TL("Triangles"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "POLYGONS" , _TL("Polygons"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); } //--------------------------------------------------------- CTIN_To_Shapes::~CTIN_To_Shapes(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_To_Shapes::On_Execute(void) { int i, j; CSG_TIN_Node *pPoint; CSG_TIN_Edge *pEdge; CSG_TIN_Triangle *pTriangle; CSG_TIN *pTIN; CSG_Shape *pShape; CSG_Shapes *pShapes; //----------------------------------------------------- pTIN = Parameters("TIN") ->asTIN(); //----------------------------------------------------- pShapes = Parameters("POINTS") ->asShapes(); pShapes->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), _TL("TIN"), pTIN->Get_Name())); pShapes->Add_Field("POINT_ID", SG_DATATYPE_Int); for(j=0; jGet_Field_Count(); j++) { pShapes->Add_Field(pTIN->Get_Field_Name(j), pTIN->Get_Field_Type(j)); } for(i=0; iGet_Node_Count() && Set_Progress(i, pTIN->Get_Node_Count()); i++) { pPoint = pTIN->Get_Node(i); pShape = pShapes->Add_Shape(); pShape->Add_Point(pPoint->Get_Point()); pShape->Set_Value(0, 1 + i); for(j=0; jGet_Field_Count(); j++) { pShape->Set_Value(j + 1, pPoint->asString(j)); } } //----------------------------------------------------- pShapes = Parameters("EDGES") ->asShapes(); pShapes->Create(SHAPE_TYPE_Line, CSG_String::Format(SG_T("%s [%s]"), _TL("TIN Edges"), pTIN->Get_Name())); pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("POINT_ID_A" , SG_DATATYPE_Int); pShapes->Add_Field("POINT_ID_B" , SG_DATATYPE_Int); for(i=0; iGet_Edge_Count() && Set_Progress(i, pTIN->Get_Edge_Count()); i++) { pEdge = pTIN->Get_Edge(i); pShape = pShapes->Add_Shape(); pShape->Add_Point(pEdge->Get_Node(0)->Get_Point()); pShape->Add_Point(pEdge->Get_Node(1)->Get_Point()); pShape->Set_Value(0, 1 + i); pShape->Set_Value(1, 1 + pEdge->Get_Node(0)->Get_ID()); pShape->Set_Value(2, 1 + pEdge->Get_Node(1)->Get_ID()); } //----------------------------------------------------- pShapes = Parameters("TRIANGLES") ->asShapes(); pShapes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), _TL("TIN Triangles"), pTIN->Get_Name())); pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("POINT_ID_A" , SG_DATATYPE_Int); pShapes->Add_Field("POINT_ID_B" , SG_DATATYPE_Int); pShapes->Add_Field("POINT_ID_C" , SG_DATATYPE_Int); for(i=0; iGet_Triangle_Count() && Set_Progress(i, pTIN->Get_Triangle_Count()); i++) { pTriangle = pTIN->Get_Triangle(i); pShape = pShapes->Add_Shape(); pShape->Add_Point(pTriangle->Get_Node(0)->Get_Point()); pShape->Add_Point(pTriangle->Get_Node(1)->Get_Point()); pShape->Add_Point(pTriangle->Get_Node(2)->Get_Point()); pShape->Set_Value(0, 1 + i); pShape->Set_Value(1, 1 + pTriangle->Get_Node(0)->Get_ID()); pShape->Set_Value(2, 1 + pTriangle->Get_Node(1)->Get_ID()); pShape->Set_Value(3, 1 + pTriangle->Get_Node(2)->Get_ID()); } //----------------------------------------------------- pShapes = Parameters("CENTER") ->asShapes(); pShapes->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), _TL("TIN Centroids"), pTIN->Get_Name())); pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("POINT_ID_A" , SG_DATATYPE_Int); pShapes->Add_Field("POINT_ID_B" , SG_DATATYPE_Int); pShapes->Add_Field("POINT_ID_C" , SG_DATATYPE_Int); for(i=0; iGet_Triangle_Count() && Set_Progress(i, pTIN->Get_Triangle_Count()); i++) { pTriangle = pTIN->Get_Triangle(i); pShape = pShapes->Add_Shape(); pShape->Add_Point(pTriangle->Get_CircumCircle_Point()); pShape->Set_Value(0, 1 + i); pShape->Set_Value(1, 1 + pTriangle->Get_Node(0)->Get_Index()); pShape->Set_Value(2, 1 + pTriangle->Get_Node(1)->Get_Index()); pShape->Set_Value(3, 1 + pTriangle->Get_Node(2)->Get_Index()); } //----------------------------------------------------- CSG_Points Points; pShapes = Parameters("POLYGONS") ->asShapes(); pShapes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), _TL("TIN Voronoi"), pTIN->Get_Name())); pShapes->Add_Field("POINT_ID", SG_DATATYPE_Int); for(j=0; jGet_Field_Count(); j++) { pShapes->Add_Field(pTIN->Get_Field_Name(j), pTIN->Get_Field_Type(j)); } for(i=0; iGet_Node_Count() && Set_Progress(i, pTIN->Get_Node_Count()); i++) { pPoint = pTIN->Get_Node(i); if( pPoint->Get_Polygon(Points) ) { pShape = pShapes->Add_Shape(); for(j=0; jAdd_Point(Points[j]); } pShape->Set_Value(0, 1 + i); for(j=0; jGet_Field_Count(); j++) { pShape->Set_Value(j + 1, pPoint->asString(j)); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_tools/TIN_From_Grid_Specific_Points.cpp0000744000175000017500000003507312737416217027101 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_From_Grid_Specific_Points.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "TIN_From_Grid_Specific_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTIN_From_Grid_Specific_Points::CTIN_From_Grid_Specific_Points(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Grid to TIN (Surface Specific Points)")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description (_TW( "Creates a TIN by identifying (surface) specific points of a grid." )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "VALUES" , _TL("Values"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_TIN( NULL , "TIN" , _TL("TIN"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL("The method used to identify surface specific points."), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("Mark Highest Neighbour"), _TL("Opposite Neighbours"), _TL("Flow Direction"), _TL("Flow Direction (up and down)"), _TL("Peucker & Douglas") ), 1 ); pNode = Parameters.Add_Node(NULL, "THRESHOLDS", _TL("Thresholds"), _TL("")); Parameters.Add_Value( pNode , "HIGH" , _TL("Mark Highest Neighbour"), _TL(""), PARAMETER_TYPE_Int , 4, 1, true, 4, true ); Parameters.Add_Range( pNode , "FLOW" , _TL("Flow Direction"), _TL(""), 0, 3, 0, true, 8, true ); Parameters.Add_Value( pNode , "PEUCKER" , _TL("Peucker & Douglas"), _TL(""), PARAMETER_TYPE_Double , 2 ); } //--------------------------------------------------------- CTIN_From_Grid_Specific_Points::~CTIN_From_Grid_Specific_Points(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_From_Grid_Specific_Points::On_Execute(void) { bool bResult; int x, y, i; CSG_TIN *pTIN; CSG_Grid *pGrid, Grid; CSG_Parameter_Grid_List *pValues; CSG_Shape *pPoint; CSG_Shapes Points; //----------------------------------------------------- pGrid = Parameters("GRID")->asGrid(); Grid.Create(pGrid, SG_DATATYPE_Byte); //----------------------------------------------------- switch( Parameters("METHOD")->asInt() ) { default: bResult = false; break; case 0: bResult = Get_MarkHighestNB (&Grid, pGrid); break; case 1: bResult = Get_OppositeNB (&Grid, pGrid, Parameters("HIGH")->asInt()); break; case 2: bResult = Get_FlowDirection (&Grid, pGrid, (int)Parameters("FLOW")->asRange()->Get_LoVal(), (int)Parameters("FLOW")->asRange()->Get_HiVal() ); break; case 3: bResult = Get_FlowDirection2(&Grid, pGrid, (int)Parameters("FLOW")->asRange()->Get_HiVal() ); break; case 4: bResult = Get_Peucker (&Grid, pGrid, Parameters("PEUCKER")->asDouble()); break; } //----------------------------------------------------- if( bResult ) { pValues = Parameters("VALUES")->asGridList(); Points.Create(SHAPE_TYPE_Point); Points.Add_Field(_TL("VALUE"), SG_DATATYPE_Double); for(i=0; iGet_Count(); i++) { Points.Add_Field(pValues->asGrid(i)->Get_Name(), SG_DATATYPE_Double); } for(y=0; yAdd_Point( Get_XMin() + Get_Cellsize() * x, Get_YMin() + Get_Cellsize() * y ); pPoint->Set_Value(0, pGrid->asDouble(x, y)); for(i=0; iGet_Count(); i++) { pPoint->Set_Value(1 + i, pValues->asGrid(i)->asDouble(x, y)); } } } } //------------------------------------------------- if( Points.Get_Count() >= 3 ) { pTIN = Parameters("TIN")->asTIN(); pTIN->Create(&Points); pTIN->Set_Name(pGrid->Get_Name()); } } return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_From_Grid_Specific_Points::Get_MarkHighestNB(CSG_Grid *pResult, CSG_Grid *pGrid) // Band & Lammers... { int i, x, y, ix, iy, xlo, ylo, xhi, yhi; double lo, hi, z; CSG_Grid *clo, *chi; clo = SG_Create_Grid(pGrid, SG_DATATYPE_Char); chi = SG_Create_Grid(pGrid, SG_DATATYPE_Char); // Pass 1: Auszaehlen... for(y=0; yasDouble(x,y); xhi = xlo = x; yhi = ylo = y; for(i=0; i<4; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( is_InGrid(ix,iy) ) { z = pGrid->asDouble(ix,iy); if( z > hi ) { hi = z; xhi = ix; yhi = iy; } else if( z < lo ) { lo = z; xlo = ix; ylo = iy; } } } clo->Add_Value(xlo,ylo,1); chi->Add_Value(xhi,yhi,1); } } // Pass 2: Setzen... for(y=0; yasChar(x,y) ) { if( !clo->asChar(x,y) ) pResult->Set_Value(x,y, 2); // Sattel else pResult->Set_Value(x,y, 1); // Tiefenlinie } else if( !clo->asChar(x,y) ) pResult->Set_Value(x,y, -1); // Wasserscheide else pResult->Set_Value(x,y, 0); // Nichts... } } delete(clo); delete(chi); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_From_Grid_Specific_Points::Get_OppositeNB(CSG_Grid *pResult, CSG_Grid *pGrid, int Threshold) { int i, x, y, ix, iy, jx, jy; double z, iz, jz; CSG_Grid *clo, *chi; clo = SG_Create_Grid(pGrid, SG_DATATYPE_Char); chi = SG_Create_Grid(pGrid, SG_DATATYPE_Char); // Pass 1: Auszaehlen... for(y=0; yasDouble(x,y); for(i=0; i<4; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( is_InGrid(ix,iy) ) { jx = Get_xFrom(i,x); jy = Get_yFrom(i,y); if( is_InGrid(jx,jy) ) { iz = pGrid->asDouble(ix,iy); jz = pGrid->asDouble(jx,jy); if( iz>z && jz>z ) chi->Add_Value(x,y,1); else if( izAdd_Value(x,y,1); } } } } } // Pass 2: Setzen... for(y=0; yasChar(x,y) ) { if( clo->asChar(x,y) ) pResult->Set_Value(x,y, 5); // Sattel else pResult->Set_Value(x,y, chi->asChar(x,y) ); // Tiefenlinie } else if( clo->asChar(x,y) ) pResult->Set_Value(x,y, - clo->asChar(x,y) ); // Wasserscheide else pResult->Set_Value(x,y, 0); // Nichts... pResult->Set_Value(x, y, abs(pResult->asInt(x, y)) >= Threshold ? 1 : 0); } } delete(clo); delete(chi); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_From_Grid_Specific_Points::Get_FlowDirection(CSG_Grid *pResult, CSG_Grid *pGrid, int Min, int Max) { bool bLower; int x, y, i, ix, iy, xLow, yLow; double z, iz, zLow; pResult->Assign(); for(y=0; yasDouble(x,y); bLower = false; for(i=0; i<8; i++) { ix = Get_xTo(i,x); iy = Get_yTo(i,y); if( is_InGrid(ix,iy) ) { iz = pGrid->asDouble(ix,iy); if(izAdd_Value(xLow, yLow, 1); } } } for(y=0; yasInt(x, y); if( i <= Min ) { pResult->Set_Value(x, y, -1); } else if( i >= Max ) { pResult->Set_Value(x, y, 1); } else { pResult->Set_Value(x, y, 0); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_From_Grid_Specific_Points::Get_FlowDirection2(CSG_Grid *pResult, CSG_Grid *pGrid, int Threshold) { CSG_Grid Grid(*pGrid), Result(*pResult); Get_FlowDirection(pResult, &Grid, -1, Threshold); Grid.Invert(); Get_FlowDirection(&Result, &Grid, -1, Threshold); for(sLong n=0; n 0 ) { pResult->Set_Value(n, 1); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_From_Grid_Specific_Points::Get_Peucker(CSG_Grid *pResult, CSG_Grid *pGrid, double Threshold) { bool wasPlus; int x, y, i, ix, iy, nSgn; double d, dPlus, dMinus, z, alt[8]; for(y=0; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++) { for(x=0; xGet_NX(); x++) { z = pGrid->asDouble(x,y); for(i=0; i<8; i++) { ix = pGrid->Get_System().Get_xTo(i,x); iy = pGrid->Get_System().Get_yTo(i,y); if( pGrid->is_InGrid(ix,iy) ) alt[i] = pGrid->asDouble(ix,iy); else alt[i] = z; } dPlus = dMinus = 0; nSgn = 0; wasPlus = (alt[7] - z > 0) ? true : false; for(i=0; i<8; i++) { d = alt[i] - z; if(d>0) { dPlus += d; if(!wasPlus) { nSgn++; wasPlus = true; } } else if(d<0) { dMinus -= d; if(wasPlus) { nSgn++; wasPlus = false; } } } i = 0; if(!dPlus) // Peak... i = 9; else if(!dMinus) // Pit i = -9; else if(nSgn==4) // Pass i = 1; else if(nSgn==2) { i = nSgn = 0; if(alt[7]>z) { while(alt[i++]>z); do nSgn++; while(alt[i++]z); } i = 0; if(nSgn==4) { if(dMinus-dPlus > Threshold) // convex break... i = 2; else if(dPlus-dMinus > Threshold) // concave break... i = -2; } else // lines: { if(dMinus-dPlus>0) // Ridge i = 7; else // Channel i = -7; } } pResult->Set_Value(x, y, i == 0 ? 0 : 1); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_tools/TIN_Flow_Parallel.h0000744000175000017500000001024012737416217024245 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_Flow_Parallel.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__TIN_Flow_Parallel_H #define HEADER_INCLUDED__TIN_Flow_Parallel_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTIN_Flow_Parallel : public CSG_Module { public: CTIN_Flow_Parallel(void); virtual ~CTIN_Flow_Parallel(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Terrain Analysis") ); } protected: virtual bool On_Execute (void); private: int m_iHeight, m_iArea, m_iFlow, m_iSpecific; CSG_TIN *m_pFlow; void Let_it_flow_single (CSG_TIN_Node *pPoint); void Let_it_flow_multiple (CSG_TIN_Node *pPoint); }; #endif // #ifndef HEADER_INCLUDED__TIN_Flow_Parallel_H saga-2.3.1/src/modules/tin/tin_tools/TIN_Flow_Trace.cpp0000744000175000017500000001647312737416217024120 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_Flow_Trace.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "TIN_Flow_Trace.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTIN_Flow_Trace::CTIN_Flow_Trace(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Flow Accumulation (Trace)")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description (_TW( "Calculates the catchment area based on the selected elevation values.\n\n" )); //----------------------------------------------------- pNode = Parameters.Add_TIN( NULL , "DEM" , _TL("TIN"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ZFIELD" , _TL("Z Values"), _TL("") ); pNode = Parameters.Add_TIN( NULL , "FLOW" , _TL("Flow Accumulation"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CTIN_Flow_Trace::~CTIN_Flow_Trace(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_Flow_Trace::On_Execute(void) { int iPoint; CSG_TIN_Node *pPoint; CSG_TIN *pDEM; //----------------------------------------------------- pDEM = Parameters("DEM") ->asTIN(); m_iHeight = Parameters("ZFIELD") ->asInt(); m_pFlow = Parameters("FLOW") ->asTIN(); m_pFlow->Create(*pDEM); m_iDir = m_pFlow->Get_Field_Count(); m_pFlow->Add_Field("DIRECTION" , SG_DATATYPE_Double); m_iArea = m_pFlow->Get_Field_Count(); m_pFlow->Add_Field("AREA" , SG_DATATYPE_Double); m_iFlow = m_pFlow->Get_Field_Count(); m_pFlow->Add_Field("FLOW" , SG_DATATYPE_Double); m_iSpecific = m_pFlow->Get_Field_Count(); m_pFlow->Add_Field("Specific" , SG_DATATYPE_Double); //----------------------------------------------------- for(iPoint=0; iPointGet_Node_Count(); iPoint++) { pPoint = m_pFlow->Get_Node(iPoint); pPoint->Set_Value(m_iDir , Get_Lowest_Neighbor(pPoint)); pPoint->Set_Value(m_iArea , pPoint->Get_Polygon_Area()); } //----------------------------------------------------- for(iPoint=0; iPointGet_Node_Count() && Set_Progress(iPoint, m_pFlow->Get_Node_Count()); iPoint++) { pPoint = m_pFlow->Get_Node(iPoint); if( pPoint->asDouble(m_iArea) > 0.0 ) { Trace(pPoint, pPoint->asDouble(m_iArea)); } } //----------------------------------------------------- for(iPoint=0; iPointGet_Node_Count() && Set_Progress(iPoint, m_pFlow->Get_Node_Count()); iPoint++) { pPoint = m_pFlow->Get_Node(iPoint); pPoint->Set_Value(m_iSpecific, pPoint->asDouble(m_iArea) > 0.0 ? 1.0 / pPoint->asDouble(m_iArea) : -1.0 ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CTIN_Flow_Trace::Get_Lowest_Neighbor(CSG_TIN_Node *pPoint) { int i, iMin; double dz, dzMin; for(i=0, iMin=-1, dzMin=0.0; iGet_Neighbor_Count(); i++) { if( (dz = pPoint->Get_Gradient(i, m_iHeight)) > dzMin ) { dzMin = dz; iMin = i; } } return( iMin ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTIN_Flow_Trace::Trace(CSG_TIN_Node *pPoint, double Area) { CSG_TIN_Node *pNeighbor; if( (pNeighbor = pPoint->Get_Neighbor(pPoint->asInt(m_iDir))) != NULL ) { pNeighbor->Add_Value(m_iFlow, Area); Trace(pNeighbor, Area); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_tools/TIN_Flow_Parallel.cpp0000744000175000017500000001756212737416217024616 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_Flow_Parallel.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "TIN_Flow_Parallel.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTIN_Flow_Parallel::CTIN_Flow_Parallel(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Flow Accumulation (Parallel)")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description (_TW( "Calculates the catchment area based on the selected elevation values.\n\n" )); //----------------------------------------------------- pNode = Parameters.Add_TIN( NULL , "DEM" , _TL("TIN"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ZFIELD" , _TL("Z Values"), _TL("") ); Parameters.Add_TIN( NULL , "FLOW" , _TL("Flow Accumulation"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Single Flow Direction"), _TL("Multiple Flow Direction") ) ); } //--------------------------------------------------------- CTIN_Flow_Parallel::~CTIN_Flow_Parallel(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_Flow_Parallel::On_Execute(void) { int iPoint; CSG_TIN *pDEM; //----------------------------------------------------- pDEM = Parameters("DEM") ->asTIN(); m_iHeight = Parameters("ZFIELD") ->asInt(); m_pFlow = Parameters("FLOW") ->asTIN(); m_pFlow->Create(*pDEM); m_iArea = m_pFlow->Get_Field_Count(); m_pFlow->Add_Field(_TL("AREA") , SG_DATATYPE_Double); m_iFlow = m_pFlow->Get_Field_Count(); m_pFlow->Add_Field(_TL("FLOW") , SG_DATATYPE_Double); m_iSpecific = m_pFlow->Get_Field_Count(); m_pFlow->Add_Field(_TL("SPECIFIC") , SG_DATATYPE_Double); //----------------------------------------------------- m_pFlow->Set_Index(m_iHeight, TABLE_INDEX_Descending); for(iPoint=0; iPointGet_Node_Count() && Set_Progress(iPoint, m_pFlow->Get_Node_Count()); iPoint++) { switch( Parameters("METHOD")->asInt() ) { case 0: default: Let_it_flow_single (m_pFlow->Get_Node(m_pFlow->Get_Record_byIndex(iPoint)->Get_Index())); break; case 1: Let_it_flow_multiple (m_pFlow->Get_Node(m_pFlow->Get_Record_byIndex(iPoint)->Get_Index())); break; } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTIN_Flow_Parallel::Let_it_flow_single(CSG_TIN_Node *pPoint) { int i, iMin; double dz, dzMin, Area; Area = pPoint->Get_Polygon_Area(); pPoint->Set_Value(m_iArea, Area); pPoint->Add_Value(m_iFlow, Area); for(i=0, iMin=-1, dzMin=0.0; iGet_Neighbor_Count(); i++) { if( (dz = pPoint->Get_Gradient(i, m_iHeight)) > dzMin ) { dzMin = dz; iMin = i; } } if( iMin >= 0 ) { pPoint->Get_Neighbor(iMin)->Add_Value(m_iFlow, pPoint->asDouble(m_iFlow)); } pPoint->Set_Value(m_iSpecific, Area > 0.0 ? 1.0 / Area : -1.0); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTIN_Flow_Parallel::Let_it_flow_multiple(CSG_TIN_Node *pPoint) { int i; double d, dzSum, *dz, Area; Area = pPoint->Get_Polygon_Area(); pPoint->Set_Value(m_iArea, Area); pPoint->Add_Value(m_iFlow, Area); if( pPoint->Get_Neighbor_Count() > 0 ) { dz = (double *)SG_Malloc(pPoint->Get_Neighbor_Count() * sizeof(double)); for(i=0, dzSum=0.0; iGet_Neighbor_Count(); i++) { if( (d = pPoint->Get_Gradient(i, m_iHeight)) > 0.0 ) { dzSum += (dz[i] = d); } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { d = pPoint->asDouble(m_iFlow); for(i=0; iGet_Neighbor_Count(); i++) { if( dz[i] > 0.0 ) { pPoint->Get_Neighbor(i)->Add_Value( m_iFlow, d * dz[i] / dzSum); } } } SG_Free(dz); } pPoint->Set_Value(m_iSpecific, Area > 0.0 ? 1.0 / Area : -1.0); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_tools/TIN_Gradient.h0000744000175000017500000000766712737416217023302 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_Gradient.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__TIN_Gradient_H #define HEADER_INCLUDED__TIN_Gradient_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTIN_Gradient : public CSG_Module { public: CTIN_Gradient(void); virtual ~CTIN_Gradient(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Terrain Analysis") ); } protected: virtual bool On_Execute (void); }; #endif // #ifndef HEADER_INCLUDED__TIN_Gradient_H saga-2.3.1/src/modules/tin/tin_tools/TIN_From_Grid_Specific_Points.h0000744000175000017500000001066412737416217026545 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_From_Grid_Specific_Points.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__TIN_From_Grid_Specific_Points_H #define HEADER_INCLUDED__TIN_From_Grid_Specific_Points_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTIN_From_Grid_Specific_Points : public CSG_Module_Grid { public: CTIN_From_Grid_Specific_Points(void); virtual ~CTIN_From_Grid_Specific_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Conversion") ); } protected: virtual bool On_Execute (void); private: bool Get_MarkHighestNB (CSG_Grid *pResult, CSG_Grid *pGrid); bool Get_OppositeNB (CSG_Grid *pResult, CSG_Grid *pGrid, int Threshold); bool Get_FlowDirection (CSG_Grid *pResult, CSG_Grid *pGrid, int Min, int Max); bool Get_FlowDirection2 (CSG_Grid *pResult, CSG_Grid *pGrid, int Threshold); bool Get_Peucker (CSG_Grid *pResult, CSG_Grid *pGrid, double Threshold); }; #endif // #ifndef HEADER_INCLUDED__TIN_From_Grid_Specific_Points_H saga-2.3.1/src/modules/tin/tin_tools/TIN_From_Shapes.cpp0000744000175000017500000001145412737416217024273 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_From_Shapes.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "TIN_From_Shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTIN_From_Shapes::CTIN_From_Shapes(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name(_TL("Shapes to TIN")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description( _TL("Convert a shapes layer to a TIN\n\n") ); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); pNode = Parameters.Add_TIN( NULL , "TIN" , _TL("TIN"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CTIN_From_Shapes::~CTIN_From_Shapes(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_From_Shapes::On_Execute(void) { CSG_TIN *pTIN; CSG_Shapes *pShapes; pShapes = Parameters("SHAPES") ->asShapes(); pTIN = Parameters("TIN") ->asTIN(); return( pTIN->Create(pShapes) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_tools/TIN_To_Shapes.h0000744000175000017500000000766712737416217023432 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_To_Shapes.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__TIN_To_Shapes_H #define HEADER_INCLUDED__TIN_To_Shapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTIN_To_Shapes : public CSG_Module { public: CTIN_To_Shapes(void); virtual ~CTIN_To_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Conversion") ); } protected: virtual bool On_Execute (void); }; #endif // #ifndef HEADER_INCLUDED__TIN_To_Shapes_H saga-2.3.1/src/modules/tin/tin_tools/TIN_Gradient.cpp0000744000175000017500000001472512737416217023626 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_Gradient.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "TIN_Gradient.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTIN_Gradient::CTIN_Gradient(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name(_TL("Gradient")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description( _TL("Calculates the gradient based on the values of each triangle's points.\n\n") ); //----------------------------------------------------- pNode = Parameters.Add_TIN( NULL , "TIN" , _TL("TIN"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ZFIELD" , _TL("Z Values"), _TL("") ); Parameters.Add_Shapes( NULL , "GRADIENT" , _TL("TIN_Gradient"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Choice( NULL , "DEGREE" , _TL("Output Unit"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Radians"), _TL("Degree") ), 1 ); } //--------------------------------------------------------- CTIN_Gradient::~CTIN_Gradient(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_Gradient::On_Execute(void) { bool bDegree; int iTriangle, zField; double a, b; CSG_TIN_Triangle *pTriangle; CSG_TIN *pTIN; CSG_Shape *pShape; CSG_Shapes *pShapes; //----------------------------------------------------- pTIN = Parameters("TIN") ->asTIN(); zField = Parameters("ZFIELD") ->asInt(); pShapes = Parameters("GRADIENT") ->asShapes(); bDegree = Parameters("DEGREE") ->asInt() == 1; //----------------------------------------------------- pShapes->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s], %s [%s]"), _TL("TIN_Gradient"), pTIN->Get_Field_Name(zField), _TL("TIN"), pTIN->Get_Name())); pShapes->Add_Field(_TL("ID") , SG_DATATYPE_Int); pShapes->Add_Field(_TL("AREA") , SG_DATATYPE_Double); pShapes->Add_Field(_TL("DECLINE"), SG_DATATYPE_Double); pShapes->Add_Field(_TL("AZIMUTH"), SG_DATATYPE_Double); //----------------------------------------------------- for(iTriangle=0; iTriangleGet_Triangle_Count() && Set_Progress(iTriangle, pTIN->Get_Triangle_Count()); iTriangle++) { pTriangle = pTIN->Get_Triangle(iTriangle); if( pTriangle->Get_Gradient(zField, a, b) ) { if( bDegree ) { a *= M_RAD_TO_DEG; b *= M_RAD_TO_DEG; } pShape = pShapes->Add_Shape(); pShape->Add_Point(pTriangle->Get_Node(0)->Get_Point()); pShape->Add_Point(pTriangle->Get_Node(1)->Get_Point()); pShape->Add_Point(pTriangle->Get_Node(2)->Get_Point()); pShape->Set_Value(0, iTriangle + 1); pShape->Set_Value(1, pTriangle->Get_Area()); pShape->Set_Value(2, a); pShape->Set_Value(3, b); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_tools/TIN_From_Grid.cpp0000744000175000017500000001375012737416217023736 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_From_Grid.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "TIN_From_Grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTIN_From_Grid::CTIN_From_Grid(void) { //----------------------------------------------------- Set_Name (_TL("Grid to TIN")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description (_TW( "Creates a TIN from grid points. No data values will be ignored.\n\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "VALUES" , _TL("Values"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_TIN( NULL , "TIN" , _TL("TIN"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CTIN_From_Grid::~CTIN_From_Grid(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_From_Grid::On_Execute(void) { int x, y, i; CSG_TIN *pTIN; CSG_Grid *pGrid; CSG_Parameter_Grid_List *pValues; CSG_Shape *pPoint; CSG_Shapes Points; //----------------------------------------------------- pGrid = Parameters("GRID") ->asGrid(); pValues = Parameters("VALUES") ->asGridList(); Points.Create(SHAPE_TYPE_Point); Points.Add_Field("VALUE", SG_DATATYPE_Double); for(i=0; iGet_Count(); i++) { Points.Add_Field(pValues->asGrid(i)->Get_Name(), SG_DATATYPE_Double); } //----------------------------------------------------- for(y=0; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++) { for(x=0; xGet_NX(); x++) { if( !pGrid->is_NoData(x, y) ) { pPoint = Points.Add_Shape(); pPoint->Add_Point( pGrid->Get_XMin() + pGrid->Get_Cellsize() * x, pGrid->Get_YMin() + pGrid->Get_Cellsize() * y ); pPoint->Set_Value(0, pGrid->asDouble(x, y)); for(i=0; iGet_Count(); i++) { pPoint->Set_Value(1 + i, pValues->asGrid(i)->asDouble(x, y)); } } } } //----------------------------------------------------- if( Points.Get_Count() >= 3 ) { pTIN = Parameters("TIN")->asTIN(); pTIN->Create(&Points); pTIN->Set_Name(pGrid->Get_Name()); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_tools/Makefile.in0000664000175000017500000005661212737447620022724 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/tin/tin_tools ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libtin_tools_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libtin_tools_la_OBJECTS = MLB_Interface.lo TIN_Flow_Parallel.lo \ TIN_Flow_Trace.lo TIN_From_Grid.lo \ TIN_From_Grid_Specific_Points.lo TIN_From_Shapes.lo \ TIN_Gradient.lo TIN_To_Shapes.lo libtin_tools_la_OBJECTS = $(am_libtin_tools_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libtin_tools_la_SOURCES) DIST_SOURCES = $(libtin_tools_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id$ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libtin_tools.la libtin_tools_la_SOURCES = \ MLB_Interface.cpp\ TIN_Flow_Parallel.cpp\ TIN_Flow_Trace.cpp\ TIN_From_Grid.cpp\ TIN_From_Grid_Specific_Points.cpp\ TIN_From_Shapes.cpp\ TIN_Gradient.cpp\ TIN_To_Shapes.cpp\ MLB_Interface.h\ TIN_Flow_Parallel.h\ TIN_Flow_Trace.h\ TIN_From_Grid.h\ TIN_From_Grid_Specific_Points.h\ TIN_From_Shapes.h\ TIN_Gradient.h\ TIN_To_Shapes.h libtin_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/tin/tin_tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/tin/tin_tools/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libtin_tools.la: $(libtin_tools_la_OBJECTS) $(libtin_tools_la_DEPENDENCIES) $(EXTRA_libtin_tools_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libtin_tools_la_OBJECTS) $(libtin_tools_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TIN_Flow_Parallel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TIN_Flow_Trace.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TIN_From_Grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TIN_From_Grid_Specific_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TIN_From_Shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TIN_Gradient.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TIN_To_Shapes.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/tin/tin_tools/TIN_Flow_Trace.h0000744000175000017500000001022312737416217023550 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_Flow_Trace.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__TIN_Flow_Trace_H #define HEADER_INCLUDED__TIN_Flow_Trace_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTIN_Flow_Trace : public CSG_Module { public: CTIN_Flow_Trace(void); virtual ~CTIN_Flow_Trace(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Terrain Analysis") ); } protected: virtual bool On_Execute (void); private: int m_iHeight, m_iDir, m_iArea, m_iFlow, m_iSpecific; CSG_TIN *m_pFlow; int Get_Lowest_Neighbor(CSG_TIN_Node *pPoint); void Trace(CSG_TIN_Node *pPoint, double Area); }; #endif // #ifndef HEADER_INCLUDED__TIN_Flow_Trace_H saga-2.3.1/src/modules/tin/tin_tools/Makefile.am0000744000175000017500000000142012737416217022673 0ustar00oconradoconrad00000000000000# # $Id$ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libtin_tools.la libtin_tools_la_SOURCES =\ MLB_Interface.cpp\ TIN_Flow_Parallel.cpp\ TIN_Flow_Trace.cpp\ TIN_From_Grid.cpp\ TIN_From_Grid_Specific_Points.cpp\ TIN_From_Shapes.cpp\ TIN_Gradient.cpp\ TIN_To_Shapes.cpp\ MLB_Interface.h\ TIN_Flow_Parallel.h\ TIN_Flow_Trace.h\ TIN_From_Grid.h\ TIN_From_Grid_Specific_Points.h\ TIN_From_Shapes.h\ TIN_Gradient.h\ TIN_To_Shapes.h libtin_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/tin/tin_tools/TIN_From_Shapes.h0000744000175000017500000000770312737416217023742 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_From_Shapes.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__TIN_From_Shapes_H #define HEADER_INCLUDED__TIN_From_Shapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTIN_From_Shapes : public CSG_Module { public: CTIN_From_Shapes(void); virtual ~CTIN_From_Shapes(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Conversion") ); } protected: virtual bool On_Execute (void); }; #endif // #ifndef HEADER_INCLUDED__TIN_From_Shapes_H saga-2.3.1/src/modules/tin/tin_tools/TIN_From_Grid.h0000744000175000017500000000767212737416217023411 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // TIN_From_Grid.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__TIN_From_Grid_H #define HEADER_INCLUDED__TIN_From_Grid //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTIN_From_Grid : public CSG_Module_Grid { public: CTIN_From_Grid(void); virtual ~CTIN_From_Grid(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Conversion") ); } protected: virtual bool On_Execute (void); }; #endif // #ifndef HEADER_INCLUDED__TIN_From_Grid_H saga-2.3.1/src/modules/tin/tin_tools/MLB_Interface.h0000744000175000017500000000761512737416217023416 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Terrain_Analysis // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__tin_tools_H #define HEADER_INCLUDED__tin_tools_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef tin_tools_EXPORTS #define tin_tools_EXPORT _SAGA_DLL_EXPORT #else #define tin_tools_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__tin_tools_H saga-2.3.1/src/modules/tin/tin_tools/MLB_Interface.cpp0000744000175000017500000001161512737416217023744 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // TIN_Tools // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Tools") ); case MLB_INFO_Category: return( _TL("TIN") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2004") ); case MLB_INFO_Description: return( _TL("Tools for Triangulated Irregular Network (TIN) processing.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("TIN") ); } } //--------------------------------------------------------- #include "TIN_From_Grid.h" #include "TIN_From_Grid_Specific_Points.h" #include "TIN_From_Shapes.h" #include "TIN_To_Shapes.h" #include "TIN_Gradient.h" #include "TIN_Flow_Trace.h" #include "TIN_Flow_Parallel.h" //--------------------------------------------------------- CSG_Module * Create_Module(int i) { CSG_Module *pModule; switch( i ) { case 0: pModule = new CTIN_From_Grid; break; case 1: pModule = new CTIN_From_Grid_Specific_Points; break; case 2: pModule = new CTIN_From_Shapes; break; case 3: pModule = new CTIN_To_Shapes; break; case 4: pModule = new CTIN_Gradient; break; case 5: pModule = new CTIN_Flow_Trace; break; case 6: pModule = new CTIN_Flow_Parallel; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/tin/tin_viewer/0000775000175000017500000000000012737740010020773 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/tin/tin_viewer/tin_view_dialog.h0000744000175000017500000001240312737416217024317 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: tin_view_dialog.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // tin_viewer // // // //-------------------------------------------------------// // // // tin_view_dialog.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__tin_view_dialog_H #define HEADER_INCLUDED__tin_view_dialog_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTIN_View_Dialog : public CSGDI_Dialog { public: CTIN_View_Dialog(CSG_TIN *pTIN, int Field_Z, int Field_Color, CSG_Grid *pRGB); void Update_Rotation (void); private: wxButton *m_pBtn_Prop; wxCheckBox *m_pCheck_Central, *m_pCheck_Stereo, *m_pCheck_Frame, *m_pCheck_RGB; wxChoice *m_pField_Color, *m_pField_Z, *m_pStyle, *m_pShading; wxTextCtrl *m_pFormula, *m_pParameters; CSGDI_Slider *m_pSlide_xRotate, *m_pSlide_yRotate, *m_pSlide_zRotate, *m_pSlide_Central, *m_pSlide_Light_Hgt, *m_pSlide_Light_Dir; class CTIN_View_Control *m_pView; CSG_Parameters m_Settings; void On_Update_Control (wxCommandEvent &event); void On_Update_Choices (wxCommandEvent &event); void On_Button (wxCommandEvent &event); void On_Mouse_Wheel (wxMouseEvent &event); DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__tin_view_dialog_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_viewer/tin_view_dialog.cpp0000744000175000017500000002404212737416217024654 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: tin_view_dialog.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // tin_viewer // // // //-------------------------------------------------------// // // // tin_view_dialog.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "tin_view_control.h" #include "tin_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(CTIN_View_Dialog, CSGDI_Dialog) EVT_MOUSEWHEEL (CTIN_View_Dialog::On_Mouse_Wheel) EVT_BUTTON (wxID_ANY , CTIN_View_Dialog::On_Button) EVT_CHECKBOX (wxID_ANY , CTIN_View_Dialog::On_Update_Control) EVT_TEXT_ENTER (wxID_ANY , CTIN_View_Dialog::On_Update_Control) EVT_SLIDER (wxID_ANY , CTIN_View_Dialog::On_Update_Control) EVT_CHOICE (wxID_ANY , CTIN_View_Dialog::On_Update_Choices) END_EVENT_TABLE() //--------------------------------------------------------- CTIN_View_Dialog::CTIN_View_Dialog(CSG_TIN *pTIN, int Field_Z, int Field_Color, CSG_Grid *pRGB) : CSGDI_Dialog(_TL("TIN Viewer"), SGDI_DLG_STYLE_START_MAXIMISED) { SetWindowStyle(wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE); //----------------------------------------------------- m_Settings.Create(NULL, _TL("TIN Viewer Settings"), _TL("")); m_pView = new CTIN_View_Control (this, pTIN, Field_Z, Field_Color, m_Settings, pRGB); //----------------------------------------------------- wxArrayString Attributes, Styles, Shadings; for(int i=0; iGet_Field_Count(); i++) { Attributes.Add(pTIN->Get_Field_Name(i)); } Styles .Add(_TL("faces and wire")); Styles .Add(_TL("faces")); Styles .Add(_TL("wire")); Shadings.Add(_TL("none")); Shadings.Add(_TL("shading")); Shadings.Add(_TL("shading (fixed light source)")); //----------------------------------------------------- Add_Button(_TL("Close"), wxID_OK); m_pBtn_Prop = Add_Button (_TL("Advanced Settings") , wxID_ANY); Add_Spacer(); m_pField_Z = Add_Choice (_TL("Z Attribute") , Attributes, m_pView->m_zField); m_pField_Color = Add_Choice (_TL("Color Attribute") , Attributes, m_pView->m_cField); m_pStyle = Add_Choice (_TL("Draw Style") , Styles , m_pView->m_Style); m_pShading = Add_Choice (_TL("Shading") , Shadings , m_pView->m_Shading); Add_Spacer(); m_pCheck_Central = Add_CheckBox (_TL("Central Projection") , m_pView->m_bCentral); m_pCheck_Stereo = Add_CheckBox (_TL("Anaglyph") , m_pView->m_bStereo); m_pCheck_Frame = Add_CheckBox (_TL("Bounding Box") , m_pView->m_bFrame); m_pCheck_RGB = pRGB == NULL ? NULL : Add_CheckBox (_TL("Drape Map") , m_pView->m_bRGB); Add_Spacer(); m_pSlide_xRotate = Add_Slider (_TL("X-Rotation") , m_pView->m_xRotate * M_RAD_TO_DEG, -180.0, 180.0); m_pSlide_yRotate = Add_Slider (_TL("Y-Rotation") , m_pView->m_yRotate * M_RAD_TO_DEG, -180.0, 180.0); m_pSlide_zRotate = Add_Slider (_TL("Z-Rotation") , m_pView->m_zRotate * M_RAD_TO_DEG, -180.0, 180.0); m_pSlide_Central = Add_Slider (_TL("Eye Distance") , m_pView->m_dCentral, 1.0, 2000.0); m_pSlide_Light_Hgt = Add_Slider (_TL("Light Source A") , m_pView->m_Light_Hgt, -M_PI_090, M_PI_090); m_pSlide_Light_Dir = Add_Slider (_TL("Light Source B") , m_pView->m_Light_Dir, -M_PI_360, M_PI_360); // Add_Spacer(); // m_pParameters = Add_TextCtrl (_TL("Function Parameters"), wxTE_MULTILINE|wxTE_READONLY); Add_Output(m_pView); } //--------------------------------------------------------- void CTIN_View_Dialog::On_Mouse_Wheel(wxMouseEvent &event) { m_pView->On_Mouse_Wheel(event); } //--------------------------------------------------------- void CTIN_View_Dialog::On_Update_Control(wxCommandEvent &event) { if( event.GetEventObject() == m_pCheck_Central ) { m_pView->m_bCentral = m_pCheck_Central ->GetValue() == 1 ? 1 : 0; } else if( event.GetEventObject() == m_pCheck_Stereo ) { m_pView->m_bStereo = m_pCheck_Stereo ->GetValue() == 1 ? 1 : 0; } else if( event.GetEventObject() == m_pCheck_Frame ) { m_pView->m_bFrame = m_pCheck_Frame ->GetValue() == 1 ? 1 : 0; } else if( event.GetEventObject() == m_pCheck_RGB ) { m_pView->m_bRGB = m_pCheck_RGB ->GetValue() == 1 ? 1 : 0; } else if( event.GetEventObject() == m_pSlide_xRotate ) { m_pView->m_xRotate = m_pSlide_xRotate ->Get_Value() * M_DEG_TO_RAD; } else if( event.GetEventObject() == m_pSlide_yRotate ) { m_pView->m_yRotate = m_pSlide_yRotate ->Get_Value() * M_DEG_TO_RAD; } else if( event.GetEventObject() == m_pSlide_zRotate ) { m_pView->m_zRotate = m_pSlide_zRotate ->Get_Value() * M_DEG_TO_RAD; } else if( event.GetEventObject() == m_pSlide_Central ) { m_pView->m_dCentral = m_pSlide_Central ->Get_Value(); } else if( event.GetEventObject() == m_pSlide_Light_Dir ) { m_pView->m_Light_Dir = m_pSlide_Light_Dir->Get_Value(); } else if( event.GetEventObject() == m_pSlide_Light_Hgt ) { m_pView->m_Light_Hgt = m_pSlide_Light_Hgt->Get_Value(); } else { return; } m_pView->Update_View(); } //--------------------------------------------------------- void CTIN_View_Dialog::On_Update_Choices(wxCommandEvent &event) { if( event.GetEventObject() == m_pField_Z ) { m_pView ->m_zField = m_pField_Z ->GetSelection(); m_pView ->Update_View(); } else if( event.GetEventObject() == m_pField_Color ) { m_Settings("C_RANGE")->asRange()->Set_Range(0.0, 0.0); m_pView ->m_cField = m_pField_Color->GetSelection(); m_pView ->Update_Extent(); } else if( event.GetEventObject() == m_pStyle ) { m_pView ->m_Style = m_pStyle->GetSelection(); m_pView ->Update_View(); } else if( event.GetEventObject() == m_pShading ) { m_pView ->m_Shading = m_pShading->GetSelection(); m_pView ->Update_View(); } else { return; } } //--------------------------------------------------------- void CTIN_View_Dialog::On_Button(wxCommandEvent &event) { if( event.GetEventObject() == m_pBtn_Prop ) { if( SG_UI_Dlg_Parameters(&m_Settings, m_Settings.Get_Name()) ) { m_pView ->Update_View(); } } else { event.Skip(); } } //--------------------------------------------------------- void CTIN_View_Dialog::Update_Rotation(void) { double d; d = fmod(M_RAD_TO_DEG * m_pView->m_xRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0; m_pSlide_xRotate->Set_Value(d); d = fmod(M_RAD_TO_DEG * m_pView->m_yRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0; m_pSlide_yRotate->Set_Value(d); d = fmod(M_RAD_TO_DEG * m_pView->m_zRotate, 360.0); if( d < -180.0 ) d += 360.0; else if( d > 180.0 ) d -= 360.0; m_pSlide_zRotate->Set_Value(d); m_pCheck_Stereo ->SetValue(m_pView->m_bStereo); m_pCheck_Frame ->SetValue(m_pView->m_bFrame); if( m_pCheck_RGB ) { m_pCheck_RGB->SetValue(m_pView->m_bRGB); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_viewer/tin_view_control.cpp0000744000175000017500000007324212737416217025103 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: tin_view_control.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // tin_viewer // // // //-------------------------------------------------------// // // // tin_view_control.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include #include #include #include //--------------------------------------------------------- #include "tin_view_control.h" #include "tin_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define m_Settings (*m_pSettings) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(CTIN_View_Control, wxPanel) EVT_SIZE (CTIN_View_Control::On_Size) EVT_PAINT (CTIN_View_Control::On_Paint) EVT_KEY_DOWN (CTIN_View_Control::On_Key_Down) EVT_LEFT_DOWN (CTIN_View_Control::On_Mouse_LDown) EVT_LEFT_UP (CTIN_View_Control::On_Mouse_LUp) EVT_RIGHT_DOWN (CTIN_View_Control::On_Mouse_RDown) EVT_RIGHT_UP (CTIN_View_Control::On_Mouse_RUp) EVT_MIDDLE_DOWN (CTIN_View_Control::On_Mouse_MDown) EVT_MIDDLE_UP (CTIN_View_Control::On_Mouse_MUp) EVT_MOTION (CTIN_View_Control::On_Mouse_Motion) EVT_MOUSEWHEEL (CTIN_View_Control::On_Mouse_Wheel) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTIN_View_Control::CTIN_View_Control(wxWindow *pParent, CSG_TIN *pTIN, int Field_Z, int Field_Color, CSG_Parameters &Settings, CSG_Grid *pRGB) : wxPanel(pParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxSUNKEN_BORDER|wxNO_FULL_REPAINT_ON_RESIZE) { m_pTIN = pTIN; m_pRGB = pRGB; m_bRGB = pRGB != NULL; m_pSettings = &Settings; m_zField = Field_Z; m_cField = Field_Color; m_Shading = 1; m_Style = 1; m_cWire = SG_GET_RGB(150, 150, 150); m_xRotate = 0.0; m_yRotate = 0.0; m_zRotate = 0.0; m_xShift = 0.0; m_yShift = 0.0; m_zShift = 1000.0; m_bCentral = true; m_bStereo = false; m_bFrame = true; m_Light_Hgt = 45.0 * M_DEG_TO_RAD; m_Light_Dir = 90.0 * M_DEG_TO_RAD; m_dCentral = 500.0; //----------------------------------------------------- CSG_Parameter *pNode = m_pSettings->Add_Node(NULL, "NODE_CONTROL", _TL("3D View"), _TL("")); m_pSettings->Add_Colors( pNode , "COLORS" , _TL("Colors"), _TL("") ); m_pSettings->Add_Value( pNode , "BGCOLOR" , _TL("Background Color"), _TL(""), PARAMETER_TYPE_Color, 0 ); m_pSettings->Add_Range( pNode , "C_RANGE" , _TL("Colors Value Range"), _TL("") ); m_pSettings->Add_Value( pNode , "COLOR_WIRE" , _TL("Wire Frame Color"), _TL(""), PARAMETER_TYPE_Color, m_cWire ); m_pSettings->Add_Value( pNode , "SIZE_DEF" , _TL("Point Size: Default"), _TL(""), PARAMETER_TYPE_Int, 0, 0, true ); m_pSettings->Add_Value( pNode , "SIZE_SCALE" , _TL("Point Size: Scaling"), _TL(""), PARAMETER_TYPE_Double, 250.0, 1.0, true ); m_pSettings->Add_Value( pNode , "EXAGGERATION" , _TL("Exaggeration"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); m_pSettings->Add_Value( pNode , "STEREO_DIST" , _TL("Stereo Eye Distance [Degree]"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); if( m_pRGB ) { m_pSettings->Add_Choice( pNode , "RGB_INTERPOL" , _TL("Map Draping Interpolation"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 0 ); } //----------------------------------------------------- Update_Extent(); } //--------------------------------------------------------- CTIN_View_Control::~CTIN_View_Control(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTIN_View_Control::On_Size(wxSizeEvent &event) { _Set_Size(); event.Skip(); } //--------------------------------------------------------- void CTIN_View_Control::On_Paint(wxPaintEvent &WXUNUSED(event)) { if( m_Image.IsOk() && m_Image.GetWidth() > 0 && m_Image.GetHeight() > 0 ) { wxPaintDC dc(this); dc.DrawBitmap(wxBitmap(m_Image), 0, 0, false); } } //--------------------------------------------------------- void CTIN_View_Control::Update_View(void) { if( _Draw_Image() ) { wxClientDC dc(this); dc.DrawBitmap(wxBitmap(m_Image), 0, 0, false); } } //--------------------------------------------------------- void CTIN_View_Control::Update_Extent(void) { m_Extent.Assign(m_pTIN->Get_Extent()); m_zStats.Invalidate(); m_cStats.Invalidate(); for(int i=0; iGet_Node_Count(); i++) { CSG_TIN_Node *pNode = m_pTIN->Get_Node(i); m_zStats.Add_Value(pNode->asDouble(m_zField)); m_cStats.Add_Value(pNode->asDouble(m_cField)); } m_Settings("C_RANGE")->asRange()->Set_Range( m_cStats.Get_Mean() - 1.5 * m_cStats.Get_StdDev(), m_cStats.Get_Mean() + 1.5 * m_cStats.Get_StdDev() ); Update_View(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTIN_View_Control::On_Key_Down(wxKeyEvent &event) { switch( event.GetKeyCode() ) { default: event.Skip(); return; case WXK_NUMPAD_ADD: case WXK_ADD: m_xRotate -= 4.0 * M_DEG_TO_RAD; break; case WXK_NUMPAD_SUBTRACT: case WXK_SUBTRACT: m_xRotate += 4.0 * M_DEG_TO_RAD; break; case WXK_F3: m_yRotate -= 4.0 * M_DEG_TO_RAD; break; case WXK_F4: m_yRotate += 4.0 * M_DEG_TO_RAD; break; case WXK_NUMPAD_MULTIPLY: case WXK_MULTIPLY: m_zRotate -= 4.0 * M_DEG_TO_RAD; break; case WXK_NUMPAD_DIVIDE: case WXK_DIVIDE: m_zRotate += 4.0 * M_DEG_TO_RAD; break; case WXK_INSERT: m_xShift -= 10.0; break; case WXK_DELETE: m_xShift += 10.0; break; case WXK_HOME: m_yShift -= 10.0; break; case WXK_END: m_yShift += 10.0; break; case WXK_PAGEUP: m_zShift -= 10.0; break; case WXK_PAGEDOWN: m_zShift += 10.0; break; case 'A': m_bStereo = !m_bStereo; break; case WXK_F1: m_Settings("EXAGGERATION")->Set_Value(m_Settings("EXAGGERATION")->asDouble() + 0.5); break; case WXK_F2: m_Settings("EXAGGERATION")->Set_Value(m_Settings("EXAGGERATION")->asDouble() - 0.5); break; case WXK_F5: m_Settings("SIZE_DEF") ->Set_Value(m_Settings("SIZE_DEF") ->asDouble() - 1.0); break; case WXK_F6: m_Settings("SIZE_DEF") ->Set_Value(m_Settings("SIZE_DEF") ->asDouble() + 1.0); break; case WXK_F7: m_Settings("SIZE_SCALE") ->Set_Value(m_Settings("SIZE_SCALE") ->asDouble() - 10.0); break; case WXK_F8: m_Settings("SIZE_SCALE") ->Set_Value(m_Settings("SIZE_SCALE") ->asDouble() + 10.0); break; } Update_View(); ((CTIN_View_Dialog *)GetParent())->Update_Rotation(); } //--------------------------------------------------------- #define GET_MOUSE_X_RELDIFF ((double)(m_Mouse_Down.x - event.GetX()) / (double)GetClientSize().x) #define GET_MOUSE_Y_RELDIFF ((double)(m_Mouse_Down.y - event.GetY()) / (double)GetClientSize().y) //--------------------------------------------------------- void CTIN_View_Control::On_Mouse_LDown(wxMouseEvent &event) { SetFocus(); m_Mouse_Down = event.GetPosition(); m_xDown = m_zRotate; m_yDown = m_xRotate; CaptureMouse(); } void CTIN_View_Control::On_Mouse_LUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } if( m_Mouse_Down.x != event.GetX() || m_Mouse_Down.y != event.GetY() ) { m_zRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_xRotate = m_yDown + GET_MOUSE_Y_RELDIFF * M_PI_180; Update_View(); ((CTIN_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CTIN_View_Control::On_Mouse_RDown(wxMouseEvent &event) { SetFocus(); m_Mouse_Down = event.GetPosition(); m_xDown = m_xShift; m_yDown = m_yShift; CaptureMouse(); } void CTIN_View_Control::On_Mouse_RUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } if( m_Mouse_Down.x != event.GetX() || m_Mouse_Down.y != event.GetY() ) { m_xShift = m_xDown - GET_MOUSE_X_RELDIFF * 1000.0; m_yShift = m_yDown - GET_MOUSE_Y_RELDIFF * 1000.0; Update_View(); ((CTIN_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CTIN_View_Control::On_Mouse_MDown(wxMouseEvent &event) { SetFocus(); m_Mouse_Down = event.GetPosition(); m_xDown = m_yRotate; m_yDown = m_zShift; CaptureMouse(); } void CTIN_View_Control::On_Mouse_MUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } if( m_Mouse_Down.x != event.GetX() || m_Mouse_Down.y != event.GetY() ) { m_yRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_zShift = m_yDown + GET_MOUSE_Y_RELDIFF * 1000.0; Update_View(); ((CTIN_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CTIN_View_Control::On_Mouse_Motion(wxMouseEvent &event) { if( HasCapture() && event.Dragging() ) { if( event.LeftIsDown() ) { m_zRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_xRotate = m_yDown + GET_MOUSE_Y_RELDIFF * M_PI_180; } else if( event.RightIsDown() ) { m_xShift = m_xDown - GET_MOUSE_X_RELDIFF * 1000.0; m_yShift = m_yDown - GET_MOUSE_Y_RELDIFF * 1000.0; } else if( event.MiddleIsDown() ) { m_yRotate = m_xDown + GET_MOUSE_X_RELDIFF * M_PI_180; m_zShift = m_yDown + GET_MOUSE_Y_RELDIFF * 1000.0; } else { return; } Update_View(); ((CTIN_View_Dialog *)GetParent())->Update_Rotation(); } } //--------------------------------------------------------- void CTIN_View_Control::On_Mouse_Wheel(wxMouseEvent &event) { if( event.GetWheelRotation() ) { m_zShift += 0.5 * event.GetWheelRotation(); Update_View(); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTIN_View_Control::_Set_Size(void) { Update_View(); } //--------------------------------------------------------- bool CTIN_View_Control::_Draw_Image(void) { wxSize dcSize = GetClientSize(); if( m_pTIN->Get_Count() <= 0 || dcSize.x <= 0 || dcSize.y <= 0 || m_Extent.Get_XRange() <= 0.0 || m_Extent.Get_YRange() <= 0.0 || m_zField < 0 || m_zField >= m_pTIN->Get_Field_Count() || m_cField < 0 || m_cField >= m_pTIN->Get_Field_Count() || m_zStats.Get_Range() <= 0.0 ) { return( false ); } //------------------------------------------------- if( !m_Image.IsOk() || dcSize.x != m_Image.GetWidth() || dcSize.y != m_Image.GetHeight() ) { m_Image .Create(dcSize.x, dcSize.y); m_Image_zMax.Create(dcSize.x, dcSize.y); } //------------------------------------------------- if( m_Settings("C_RANGE")->asRange()->Get_LoVal() >= m_Settings("C_RANGE")->asRange()->Get_HiVal() ) { m_Settings("C_RANGE")->asRange()->Set_Range( m_cStats.Get_Mean() - 1.5 * m_pTIN->Get_StdDev(m_cField), m_cStats.Get_Mean() + 1.5 * m_pTIN->Get_StdDev(m_cField) ); } m_pColors = m_Settings("COLORS")->asColors(); m_cMin = m_Settings("C_RANGE")->asRange()->Get_LoVal(); m_cScale = m_pColors->Get_Count() / (m_Settings("C_RANGE")->asRange()->Get_HiVal() - m_cMin); m_cWire = m_Settings("COLOR_WIRE")->asColor(); if( m_bRGB ) { switch( m_Settings("RGB_INTERPOL")->asInt() ) { default: m_Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: m_Resampling = GRID_RESAMPLING_Bilinear; break; case 2: m_Resampling = GRID_RESAMPLING_BicubicSpline; break; case 3: m_Resampling = GRID_RESAMPLING_BSpline; break; } } //------------------------------------------------- r_Scale = (m_Image.GetWidth() / (double)m_Image.GetHeight()) > (m_Extent.Get_XRange() / m_Extent.Get_YRange()) ? m_Image.GetWidth () / m_Extent.Get_XRange() : m_Image.GetHeight() / m_Extent.Get_YRange(); r_sin_x = sin(m_xRotate - M_PI_180); r_cos_x = cos(m_xRotate - M_PI_180); r_sin_y = sin(m_yRotate); r_cos_y = cos(m_yRotate); r_sin_z = sin(m_zRotate); r_cos_z = cos(m_zRotate); r_xc = m_Extent.Get_XCenter(); r_yc = m_Extent.Get_YCenter(); r_zc = m_zStats.Get_Minimum() + 0.5 * m_zStats.Get_Range(); r_Scale_z = r_Scale * m_Settings("EXAGGERATION")->asDouble(); //------------------------------------------------- m_Size_Def = m_Settings("SIZE_DEF")->asInt(); m_Size_Scale = 1.0 / m_Settings("SIZE_SCALE")->asDouble(); _Draw_Background(); //------------------------------------------------- if( m_bStereo == false ) { m_Image_zMax.Assign(999999.0); m_Color_Mode = COLOR_MODE_RGB; for(int i=0; iGet_Triangle_Count(); i++) { _Draw_Triangle(m_pTIN->Get_Triangle(i)); } _Draw_Frame(); } //------------------------------------------------- else { int i; double d = m_Settings("STEREO_DIST")->asDouble() / 2.0; m_Image_zMax.Assign(999999.0); r_sin_y = sin(m_yRotate - d * M_DEG_TO_RAD); r_cos_y = cos(m_yRotate - d * M_DEG_TO_RAD); m_Color_Mode = COLOR_MODE_RED; for(i=0; iGet_Triangle_Count(); i++) { _Draw_Triangle(m_pTIN->Get_Triangle(i)); } _Draw_Frame(); m_Image_zMax.Assign(999999.0); r_sin_y = sin(m_yRotate + d * M_DEG_TO_RAD); r_cos_y = cos(m_yRotate + d * M_DEG_TO_RAD); m_Color_Mode = COLOR_MODE_BLUE; for(i=0; iGet_Triangle_Count(); i++) { _Draw_Triangle(m_pTIN->Get_Triangle(i)); } _Draw_Frame(); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CTIN_View_Control::_Draw_Point(int iPoint) { TNode p; CSG_TIN_Node *pNode = m_pTIN->Get_Node(iPoint); p.x = pNode->Get_Point().x; p.y = pNode->Get_Point().y; p.z = pNode->asDouble(m_zField); p.c = pNode->asDouble(m_cField); _Get_Projection(p); bool m_bScale = true; _Draw_Point((int)p.x, (int)p.y, p.z, p.c, m_Size_Def + (!m_bScale ? 0 : (int)(20.0 * exp(-m_Size_Scale * p.z)))); } //--------------------------------------------------------- inline void CTIN_View_Control::_Draw_Point(int x, int y, double z, int color, int size) { if( z > 0.0 ) { _Draw_Pixel(x, y, z, color); if( size > 0 && size < 50 ) { for(int iy=1; iy<=size; iy++) { for(int ix=0; ix<=size; ix++) { if( ix*ix + iy*iy <= size*size ) { _Draw_Pixel(x + ix, y + iy, z, color); _Draw_Pixel(x + iy, y - ix, z, color); _Draw_Pixel(x - ix, y - iy, z, color); _Draw_Pixel(x - iy, y + ix, z, color); } } } } } } //--------------------------------------------------------- inline void CTIN_View_Control::_Draw_Line(TNode a, TNode b, int Color) { if( (a.x < 0 && b.x < 0) || (a.x >= m_Image.GetWidth () && b.x >= m_Image.GetWidth ()) || (a.y < 0 && b.y < 0) || (a.y >= m_Image.GetHeight() && b.y >= m_Image.GetHeight()) ) { return; } double i, n, dx, dy, dz; dx = b.x - a.x; dy = b.y - a.y; dz = b.z - a.z; if( b.z < 0.0 || a.z < 0.0 ) return; if( fabs(dx) > fabs(dy) && fabs(dx) > 0.0 ) { n = fabs(dx); dx = dx < 0 ? -1 : 1; dy /= n; dz /= n; } else if( fabs(dy) > 0.0 ) { n = fabs(dy); dx /= n; dy = dy < 0 ? -1 : 1; dz /= n; } else { _Draw_Pixel((int)a.x, (int)a.y, a.z, Color); return; } //----------------------------------------------------- for(i=0; i<=n; i++, a.x+=dx, a.y+=dy, a.z+=dz) { _Draw_Pixel((int)a.x, (int)a.y, a.z, Color); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CTIN_View_Control::_Draw_Triangle(CSG_TIN_Triangle *pTriangle) { TNode t[3]; for(int iNode=0; iNode<3; iNode++) { CSG_TIN_Node *pNode = pTriangle->Get_Node(iNode); t[iNode].x = pNode->Get_Point().x; t[iNode].y = pNode->Get_Point().y; t[iNode].z = pNode->asDouble(m_zField); if( m_bRGB ) { t[iNode].c = pNode->Get_Point().x; t[iNode].d = pNode->Get_Point().y; } else { t[iNode].c = pNode->asDouble(m_cField); } _Get_Projection(t[iNode]); } //----------------------------------------------------- double dim; switch( m_Shading ) { case 0: default: dim = -1.0; break; case 1: { double s, a, A, B, C; A = t[0].z * (t[1].x - t[2].x) + t[1].z * (t[2].x - t[0].x) + t[2].z * (t[0].x - t[1].x); B = t[0].y * (t[1].z - t[2].z) + t[1].y * (t[2].z - t[0].z) + t[2].y * (t[0].z - t[1].z); C = t[0].x * (t[1].y - t[2].y) + t[1].x * (t[2].y - t[0].y) + t[2].x * (t[0].y - t[1].y); if( C != 0.0 ) { A = - A / C; B = - B / C; s = atan(sqrt(A*A + B*B)); if( A != 0.0 ) a = M_PI_180 + atan2(B, A); else a = B > 0.0 ? M_PI_270 : (B < 0.0 ? M_PI_090 : -1.0); } s = M_PI_090 - s; dim = (acos(sin(s) * sin(m_Light_Hgt) + cos(s) * cos(m_Light_Hgt) * cos(a - m_Light_Dir))) / M_PI_090; } break; case 2: { double s, a; pTriangle->Get_Gradient(m_zField, s, a); s = M_PI_090 - s; dim = (acos(sin(s) * sin(m_Light_Hgt) + cos(s) * cos(m_Light_Hgt) * cos(a - m_Light_Dir))) / M_PI_090; } break; } //----------------------------------------------------- if( m_Style == 0 || m_Style == 1 ) { _Draw_Triangle(t, dim); } if( m_Style == 0 || m_Style == 2 ) { _Draw_Line(t[0], t[1], m_cWire); _Draw_Line(t[1], t[2], m_cWire); _Draw_Line(t[2], t[0], m_cWire); } if( 0 ) { _Draw_Point(t[0].x, t[0].y, t[0].z, SG_GET_RGB(111, 111, 111), 5); _Draw_Point(t[1].x, t[1].y, t[1].z, SG_GET_RGB(111, 111, 111), 5); _Draw_Point(t[2].x, t[2].y, t[2].z, SG_GET_RGB(111, 111, 111), 5); } } //--------------------------------------------------------- inline void CTIN_View_Control::_Draw_Triangle(TNode p[3], double dim) { if( p[0].z < 0.0 || p[1].z < 0.0 || p[2].z < 0.0 ) return; //----------------------------------------------------- if( p[1].y < p[0].y ) { TNode pp = p[1]; p[1] = p[0]; p[0] = pp; } if( p[2].y < p[0].y ) { TNode pp = p[2]; p[2] = p[0]; p[0] = pp; } if( p[2].y < p[1].y ) { TNode pp = p[2]; p[2] = p[1]; p[1] = pp; } //----------------------------------------------------- TSG_Rect r; r.yMin = p[0].y; r.yMax = p[2].y; r.xMin = p[0].x < p[1].x ? (p[0].x < p[2].x ? p[0].x : p[2].x) : (p[1].x < p[2].x ? p[1].x : p[2].x); r.xMax = p[0].x > p[1].x ? (p[0].x > p[2].x ? p[0].x : p[2].x) : (p[1].x > p[2].x ? p[1].x : p[2].x); if( r.yMin >= r.yMax || r.xMin >= r.xMax ) { return; // no area } if( (r.yMin < 0.0 && r.yMax < 0.0) || (r.yMin >= m_Image.GetHeight() && r.yMax >= m_Image.GetHeight()) || (r.xMin < 0.0 && r.xMax < 0.0) || (r.xMin >= m_Image.GetWidth () && r.xMax >= m_Image.GetWidth ()) ) { return; // completely outside grid } //----------------------------------------------------- TNode d[3]; if( (d[0].y = p[2].y - p[0].y) > 0.0 ) { d[0].x = (p[2].x - p[0].x) / d[0].y; d[0].z = (p[2].z - p[0].z) / d[0].y; d[0].c = (p[2].c - p[0].c) / d[0].y; d[0].d = (p[2].d - p[0].d) / d[0].y; } if( (d[1].y = p[1].y - p[0].y) > 0.0 ) { d[1].x = (p[1].x - p[0].x) / d[1].y; d[1].z = (p[1].z - p[0].z) / d[1].y; d[1].c = (p[1].c - p[0].c) / d[1].y; d[1].d = (p[1].d - p[0].d) / d[1].y; } if( (d[2].y = p[2].y - p[1].y) > 0.0 ) { d[2].x = (p[2].x - p[1].x) / d[2].y; d[2].z = (p[2].z - p[1].z) / d[2].y; d[2].c = (p[2].c - p[1].c) / d[2].y; d[2].d = (p[2].d - p[1].d) / d[2].y; } //----------------------------------------------------- int ay = (int)r.yMin; if( ay < 0 ) ay = 0; if( ay < r.yMin ) ay++; int by = (int)r.yMax; if( by >= m_Image.GetHeight() ) by = m_Image.GetHeight() - 1; for(int y=ay; y<=by; y++) { if( y <= p[1].y && d[1].y > 0.0 ) { _Draw_Triangle_Line(y, p[0].x + (y - p[0].y) * d[0].x, p[0].x + (y - p[0].y) * d[1].x, p[0].z + (y - p[0].y) * d[0].z, p[0].z + (y - p[0].y) * d[1].z, p[0].c + (y - p[0].y) * d[0].c, p[0].c + (y - p[0].y) * d[1].c, p[0].d + (y - p[0].y) * d[0].d, p[0].d + (y - p[0].y) * d[1].d, dim ); } else if( d[2].y > 0.0 ) { _Draw_Triangle_Line(y, p[0].x + (y - p[0].y) * d[0].x, p[1].x + (y - p[1].y) * d[2].x, p[0].z + (y - p[0].y) * d[0].z, p[1].z + (y - p[1].y) * d[2].z, p[0].c + (y - p[0].y) * d[0].c, p[1].c + (y - p[1].y) * d[2].c, p[0].d + (y - p[0].y) * d[0].d, p[1].d + (y - p[1].y) * d[2].d, dim ); } } } //--------------------------------------------------------- inline void CTIN_View_Control::_Draw_Triangle_Line(int y, double xa, double xb, double za, double zb, double ca, double cb, double da, double db, double dim) { if( xb < xa ) { double d; d = xa; xa = xb; xb = d; d = za; za = zb; zb = d; d = ca; ca = cb; cb = d; d = da; da = db; db = d; } if( xb > xa ) { double dz = (zb - za) / (xb - xa); double dc = (cb - ca) / (xb - xa); double dd = (db - da) / (xb - xa); int ax = (int)xa; if( ax < 0 ) ax = 0; if( ax < xa ) ax++; int bx = (int)xb; if( bx >= m_Image.GetWidth() ) bx = m_Image.GetWidth() - 1; for(int x=ax; x<=bx; x++) { double z = za + dz * (x - xa); double c = ca + dc * (x - xa); double d = da + dd * (x - xa); if( m_bRGB ) { if( m_pRGB->Get_Value(c, d, c, m_Resampling, false, true) ) { _Draw_Pixel(x, y, z, _Dim_Color(c, dim)); } } else { _Draw_Pixel(x, y, z, _Get_Color(c, dim)); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTIN_View_Control::_Draw_Background(void) { BYTE r, g, b, *pRGB; int i, n, color; color = m_Settings("BGCOLOR")->asColor(); if( m_bStereo ) { color = (int)((SG_GET_R(color) + SG_GET_G(color) + SG_GET_B(color)) / 3.0); color = SG_GET_RGB(color, color, color); } r = SG_GET_R(color); g = SG_GET_G(color); b = SG_GET_B(color); n = m_Image.GetWidth() * m_Image.GetHeight(); for(i=0, pRGB=m_Image.GetData(); iasColor(); color = SG_GET_RGB(SG_GET_R(color) + 128, SG_GET_G(color) + 128, SG_GET_B(color) + 128); for(int i=0; i<2; i++) { p[i][0].x = r.Get_XMin(); p[i][0].y = r.Get_YMin(); p[i][1].x = r.Get_XMax(); p[i][1].y = r.Get_YMin(); p[i][2].x = r.Get_XMax(); p[i][2].y = r.Get_YMax(); p[i][3].x = r.Get_XMin(); p[i][3].y = r.Get_YMax(); p[i][0].z = p[i][1].z = p[i][2].z = p[i][3].z = i == 0 ? m_zStats.Get_Minimum() - buffer * m_zStats.Get_Range() / 100.0 : m_zStats.Get_Maximum() + buffer * m_zStats.Get_Range() / 100.0; for(int j=0; j<4; j++) { _Get_Projection(p[i][j]); } _Draw_Line(p[i][0], p[i][1], color); _Draw_Line(p[i][1], p[i][2], color); _Draw_Line(p[i][2], p[i][3], color); _Draw_Line(p[i][3], p[i][0], color); } _Draw_Line(p[0][0], p[1][0], color); _Draw_Line(p[0][1], p[1][1], color); _Draw_Line(p[0][2], p[1][2], color); _Draw_Line(p[0][3], p[1][3], color); } //--------------------------------------------------------- inline void CTIN_View_Control::_Draw_Pixel(int x, int y, double z, int color) { if( x >= 0 && x < m_Image.GetWidth() && y >= 0 && y < m_Image.GetHeight() && z < m_Image_zMax[y][x] ) { BYTE *RGB = m_Image.GetData() + 3 * (y * m_Image.GetWidth() + x); switch( m_Color_Mode ) { case COLOR_MODE_RGB: RGB[0] = SG_GET_R(color); RGB[1] = SG_GET_G(color); RGB[2] = SG_GET_B(color); break; case COLOR_MODE_RED: RGB[0] = (SG_GET_R(color) + SG_GET_G(color) + SG_GET_B(color)) / 3; break; case COLOR_MODE_BLUE: RGB[1] = RGB[2] = (SG_GET_R(color) + SG_GET_G(color) + SG_GET_B(color)) / 3; break; } m_Image_zMax[y][x] = z; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline int CTIN_View_Control::_Dim_Color(int Color, double dim) { if( dim >= 0.0 ) { int r = (int)(dim * SG_GET_R(Color)); if( r < 0 ) r = 0; else if( r > 255 ) r = 255; int g = (int)(dim * SG_GET_G(Color)); if( g < 0 ) g = 0; else if( g > 255 ) g = 255; int b = (int)(dim * SG_GET_B(Color)); if( b < 0 ) b = 0; else if( b > 255 ) b = 255; Color = SG_GET_RGB(r, g, b); } return( Color ); } //--------------------------------------------------------- inline int CTIN_View_Control::_Get_Color(double value, double dim) { int Color = (int)(m_cScale * (value - m_cMin)); Color = m_pColors->Get_Color(Color < 0 ? 0 : (Color >= m_pColors->Get_Count() ? m_pColors->Get_Count() - 1 : Color)); return( _Dim_Color(Color, dim) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CTIN_View_Control::_Get_Projection(TNode &p) { TSG_Point_Z q; p.x = (p.x - r_xc) * r_Scale; p.y = (p.y - r_yc) * r_Scale; p.z = (p.z - r_zc) * r_Scale_z; double a = (r_cos_y * p.z + r_sin_y * (r_sin_z * p.y + r_cos_z * p.x)); double b = (r_cos_z * p.y - r_sin_z * p.x); q.x = r_cos_y * (r_sin_z * p.y + r_cos_z * p.x) - r_sin_y * p.z; q.y = r_sin_x * a + r_cos_x * b; q.z = r_cos_x * a - r_sin_x * b; q.x += m_xShift; q.y += m_yShift; q.z += m_zShift; if( m_bCentral ) { q.x *= m_dCentral / q.z; q.y *= m_dCentral / q.z; } else { double z = m_dCentral / m_zShift; q.x *= z; q.y *= z; // q.z = -q.z; } p.x = q.x + 0.5 * m_Image.GetWidth (); p.y = q.y + 0.5 * m_Image.GetHeight(); p.z = q.z; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_viewer/tin_view_module.h0000744000175000017500000001015612737416220024342 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_view_module.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // tin_viewer // // // //-------------------------------------------------------// // // // tin_view_module.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__tin_view_module_H #define HEADER_INCLUDED__tin_view_module_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTIN_View_Module : public CSG_Module { public: CTIN_View_Module(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__points_view_module_H saga-2.3.1/src/modules/tin/tin_viewer/Makefile.in0000664000175000017500000005610412737447620023061 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/tin/tin_viewer ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libtin_viewer_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la \ $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la am_libtin_viewer_la_OBJECTS = MLB_Interface.lo tin_view_control.lo \ tin_view_dialog.lo tin_view_module.lo libtin_viewer_la_OBJECTS = $(am_libtin_viewer_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libtin_viewer_la_SOURCES) DIST_SOURCES = $(libtin_viewer_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libtin_viewer.la libtin_viewer_la_SOURCES = \ MLB_Interface.cpp\ tin_view_control.cpp\ tin_view_dialog.cpp\ tin_view_module.cpp\ MLB_Interface.h\ tin_view_control.h\ tin_view_dialog.h\ tin_view_module.h libtin_viewer_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la $(ADD_MLBS) all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/tin/tin_viewer/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/tin/tin_viewer/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libtin_viewer.la: $(libtin_viewer_la_OBJECTS) $(libtin_viewer_la_DEPENDENCIES) $(EXTRA_libtin_viewer_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libtin_viewer_la_OBJECTS) $(libtin_viewer_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tin_view_control.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tin_view_dialog.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tin_view_module.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/tin/tin_viewer/tin_view_module.cpp0000744000175000017500000001246312737416217024706 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: points_view_module.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // tin_view_module // // // //-------------------------------------------------------// // // // tin_view_module.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "tin_view_module.h" #include "tin_view_dialog.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTIN_View_Module::CTIN_View_Module(void) { //----------------------------------------------------- Set_Name (_TL("[deprecated] TIN Viewer")); Set_Author (SG_T("O. Conrad (c) 2011")); Set_Description (_TW( "This module is a 3D viewer for SAGA TINs. Amongst others, " "the viewer supports attribute based coloring, a map view to control " "the area-of-interest, point size scaling based on distance, level " "of detail control and an anaglyph modus (to use with red/blue or " "red/green glasses).\n\n" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_TIN( NULL , "TIN" , _TL("TIN"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "HEIGHT" , _TL("Elevation"), _TL("") ); Parameters.Add_Table_Field( pNode , "COLOR" , _TL("Color"), _TL("") ); Parameters.Add_Grid( NULL , "RGB" , _TL("Map"), _TL("rgb coded raster map to be draped"), PARAMETER_INPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTIN_View_Module::On_Execute(void) { CSG_TIN *pTIN = Parameters("TIN")->asTIN(); if( pTIN->Get_Count() <= 0 ) { Message_Add(_TL("point cloud viewer will not be started, because point cloud has no points")); return( false ); } CTIN_View_Dialog dlg(pTIN, Parameters("HEIGHT")->asInt(), Parameters("COLOR")->asInt(), Parameters("RGB")->asGrid()); dlg.ShowModal(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_viewer/Makefile.am0000744000175000017500000000144512737416217023043 0ustar00oconradoconrad00000000000000if DEBUG DBGFLAGS = -g -DDEBUG endif DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libtin_viewer.la libtin_viewer_la_SOURCES =\ MLB_Interface.cpp\ tin_view_control.cpp\ tin_view_dialog.cpp\ tin_view_module.cpp\ MLB_Interface.h\ tin_view_control.h\ tin_view_dialog.h\ tin_view_module.h libtin_viewer_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la $(ADD_MLBS) saga-2.3.1/src/modules/tin/tin_viewer/MLB_Interface.h0000744000175000017500000000760512737416217023556 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pointcloud_viewer // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pointcloud_viewer_mlb_H #define HEADER_INCLUDED__pointcloud_viewer_mlb_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef pointcloud_viewer_EXPORTS #define pointcloud_viewer_EXPORT _SAGA_DLL_EXPORT #else #define pointcloud_viewer_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pointcloud_viewer_mlb_H saga-2.3.1/src/modules/tin/tin_viewer/tin_view_control.h0000744000175000017500000001624712737416217024552 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: tin_view_control.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // tin_viewer // // // //-------------------------------------------------------// // // // tin_view_control.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: SAGA User Group Association // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__tin_view_control_H #define HEADER_INCLUDED__tin_view_control_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { COLOR_MODE_RGB, COLOR_MODE_RED, COLOR_MODE_BLUE }; //--------------------------------------------------------- typedef struct SNode { double x, y, z, c, d; } TNode; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTIN_View_Control : public wxPanel { public: CTIN_View_Control(wxWindow *pParent, CSG_TIN *pTIN, int Field_Z, int Field_Color, CSG_Parameters &Settings, CSG_Grid *pRGB); virtual ~CTIN_View_Control(void); bool m_bCentral, m_bStereo, m_bFrame, m_bRGB; int m_zField, m_cField, m_Style, m_Shading; double m_xRotate, m_yRotate, m_zRotate, m_xShift, m_yShift, m_zShift, m_dCentral, m_Light_Hgt, m_Light_Dir; void Update_View (void); void Update_Extent (void); void On_Size (wxSizeEvent &event); void On_Paint (wxPaintEvent &event); void On_Key_Down (wxKeyEvent &event); void On_Mouse_LDown (wxMouseEvent &event); void On_Mouse_LUp (wxMouseEvent &event); void On_Mouse_RDown (wxMouseEvent &event); void On_Mouse_RUp (wxMouseEvent &event); void On_Mouse_MDown (wxMouseEvent &event); void On_Mouse_MUp (wxMouseEvent &event); void On_Mouse_Motion (wxMouseEvent &event); void On_Mouse_Wheel (wxMouseEvent &event); private: int m_Color_Mode, m_Size_Def, m_cWire; double m_xDown, m_yDown, m_cMin, m_cScale, m_Size_Scale; double r_sin_x, r_sin_y, r_sin_z, r_cos_x, r_cos_y, r_cos_z, r_xc, r_yc, r_zc, r_Scale, r_Scale_z; TSG_Grid_Resampling m_Resampling; CSG_Rect m_Extent; CSG_Matrix m_Image_zMax; CSG_Simple_Statistics m_zStats, m_cStats; CSG_Parameters *m_pSettings; CSG_Colors *m_pColors; CSG_Grid *m_pRGB; CSG_TIN *m_pTIN; wxPoint m_Mouse_Down; wxImage m_Image; void _Set_Size (void); bool _Draw_Image (void); void _Draw_Point (int iPoint); void _Draw_Point (int x, int y, double z, int color, int Size); void _Draw_Line (TNode a, TNode b, int Color); void _Draw_Triangle (CSG_TIN_Triangle *pTriangle); void _Draw_Triangle (TNode p[3], double dim); void _Draw_Triangle_Line (int y, double xa, double xb, double za, double zb, double ca, double cb, double da, double db, double dim); void _Draw_Background (void); void _Draw_Frame (void); void _Draw_Pixel (int x, int y, double z, int color); int _Dim_Color (int Color, double dim); int _Get_Color (double value, double dim = -1.0); void _Get_Projection (TNode &p); DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__tin_view_control_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/tin/tin_viewer/MLB_Interface.cpp0000744000175000017500000001073212737416217024104 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // tin_viewer // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Visualization") ); case MLB_INFO_Category: return( _TL("TIN") ); case MLB_INFO_Author: return( SG_T("O.Conrad (c) 2011") ); case MLB_INFO_Description: return( _TL("TIN viewer." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Visualization|3D Viewer" )); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "tin_view_module.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CTIN_View_Module ); default: return( NULL ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/tin/Makefile.in0000664000175000017500000004662212737447620020712 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/tin ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = tin_tools tin_viewer am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @WITH_GUI_FALSE@SUBDIRS = tin_tools @WITH_GUI_TRUE@SUBDIRS = tin_tools tin_viewer all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/tin/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/tin/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/tin/Makefile.am0000744000175000017500000000011712737416217020663 0ustar00oconradoconrad00000000000000if WITH_GUI SUBDIRS = tin_tools tin_viewer else SUBDIRS = tin_tools endif saga-2.3.1/src/modules/db/0000775000175000017500000000000012737740003016415 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/db/db_pgsql/0000775000175000017500000000000012737740003020210 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/db/db_pgsql/db_pgsql.h0000744000175000017500000002605012737416155022166 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: db_pgsql.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // db_pgsql.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__db_pgsql_H #define HEADER_INCLUDED__db_pgsql_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SG_PG_PRIMARY_KEY 0x01 #define SG_PG_NOT_NULL 0x02 #define SG_PG_UNIQUE 0x04 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class db_pgsql_EXPORT CSG_PG_Connection { friend class CSG_PG_Connections; public: CSG_PG_Connection (void); CSG_PG_Connection (const CSG_String &Host, int Port, const CSG_String &Name, const CSG_String &User, const CSG_String &Password, bool bAutoCommit = false); bool Create (const CSG_String &Host, int Port, const CSG_String &Name, const CSG_String &User, const CSG_String &Password, bool bAutoCommit = false); virtual ~CSG_PG_Connection(void); bool Destroy (void); static CSG_String Get_Type_To_SQL (TSG_Data_Type Type, int Size = 0); static TSG_Data_Type Get_Type_From_SQL (int Type); static CSG_String Get_Raster_Type_To_SQL (TSG_Data_Type Type); void GUI_Update (void) const; bool is_Connected (void) const { return( m_pConnection != NULL ); } CSG_String Get_Connection (int Style = 0) const; CSG_String Get_Host (void) const; CSG_String Get_Port (void) const; CSG_String Get_User (void) const; CSG_String Get_DBName (void) const; CSG_String Get_Version (void) const; bool has_Version (int Major, int Minor = 0, int Revision = 0) const; CSG_String Get_PostGIS (void) const; bool has_PostGIS (double minVersion = 0.0); int Get_Tables (CSG_Strings &Tables) const; CSG_String Get_Tables (void) const; CSG_String Get_Field_Names (const CSG_String &Table_Name) const; CSG_Table Get_Field_Desc (const CSG_String &Table_Name) const; bool Execute (const CSG_String &SQL, CSG_Table *pTable = NULL); bool Begin (const CSG_String &SavePoint = ""); bool Rollback (const CSG_String &SavePoint = ""); bool Commit (const CSG_String &SavePoint = ""); bool is_Transaction (void) const { return( is_Connected() && m_bTransaction ); } CSG_MetaData & Add_MetaData (CSG_Data_Object &Object, const CSG_String &Table, const CSG_String &Select = ""); bool Table_Exists (const CSG_String &Table_Name) const; bool Table_Create (const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags = 0, bool bCommit = true); bool Table_Drop (const CSG_String &Table_Name , bool bCommit = true); bool Table_Insert (const CSG_String &Table_Name, const CSG_Table &Table , bool bCommit = true); bool Table_Save (const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags = 0, bool bCommit = true); bool Table_Load (CSG_Table &Data, const CSG_String &Table ); bool Table_Load (CSG_Table &Data, const CSG_String &Tables, const CSG_String &Fields, const CSG_String &Where = "", const CSG_String &Group = "", const CSG_String &Having = "", const CSG_String &Order = "", bool bDistinct = false); bool Shapes_Load (CSG_Shapes *pShapes, const CSG_String &Table); bool Shapes_Load (CSG_Shapes *pShapes, const CSG_String &Name, const CSG_String &Select, const CSG_String &Geometry_Field, bool bBinary, int SRID = -1); bool Raster_Load (CSG_Parameter_Grid_List *pGrids , const CSG_String &Table, const CSG_String &Where = "", const CSG_String &Order = ""); bool Raster_Load (CSG_Grid *pGrid , const CSG_String &Table, const CSG_String &Where = ""); bool Raster_Save (CSG_Grid *pGrid, int SRID, const CSG_String &Table, const CSG_String &Field); private: void *m_pConnection; bool m_bTransaction; bool _Table_Load (CSG_Table &Data, const CSG_String &Select, const CSG_String &Name = "") const; bool _Table_Load (CSG_Table &Data, void *pResult) const; bool _Raster_Open (CSG_Table &Info, const CSG_String &Table, const CSG_String &Where = "", const CSG_String &Order = "", bool bBinary = true); bool _Raster_Load (CSG_Grid *pGrid, bool bFirst, bool bBinary = true); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class db_pgsql_EXPORT CSG_PG_Connections { public: CSG_PG_Connections(void); virtual ~CSG_PG_Connections(void); bool Create (void); bool Destroy (void); int Get_Servers (CSG_String &Servers); int Get_Servers (CSG_Strings &Servers); CSG_Strings Get_Servers (void); int Get_Connections (CSG_String &Connections); CSG_Strings Get_Connections (void); int Get_Count (void) { return( m_nConnections ); } CSG_PG_Connection * Get_Connection (int Index) { return( Index >= 0 && Index < m_nConnections ? m_pConnections[Index] : NULL ); } CSG_PG_Connection * Get_Connection (const CSG_String &Name); CSG_PG_Connection * Add_Connection (const CSG_String &Name, const CSG_String &User, const CSG_String &Password, const CSG_String &Host = "localhost", int Port = 5432); bool Del_Connection (int Index , bool bCommit); bool Del_Connection (const CSG_String &Name , bool bCommit); bool Del_Connection (CSG_PG_Connection *pConnection, bool bCommit); private: int m_nConnections; CSG_PG_Connection **m_pConnections; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class db_pgsql_EXPORT CSG_PG_Module : public CSG_Module { public: CSG_PG_Module(void); protected: virtual bool On_Before_Execution (void); virtual bool On_After_Execution (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual void On_Connection_Changed (CSG_Parameters *pParameters) {} CSG_PG_Connection * Get_Connection (void) { return( m_pConnection ); } bool Add_SRID_Picker (CSG_Parameters *pParameters = NULL); bool Set_SRID_Picker_Enabled (CSG_Parameters *pParameters, bool bEnable = true); bool Set_SRID (CSG_Parameters *pParameters, int SRID); int Get_SRID (CSG_Parameters *pParameters = NULL); static bool Set_Constraints (CSG_Parameters *pParameters, const CSG_String &Identifier); static CSG_Buffer Get_Constraints (CSG_Parameters *pParameters, const CSG_String &Identifier); private: CSG_PG_Connection *m_pConnection; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- db_pgsql_EXPORT CSG_PG_Connections & SG_PG_Get_Connection_Manager (void); //--------------------------------------------------------- db_pgsql_EXPORT bool SG_PG_is_Supported (void); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__db_pgsql_H saga-2.3.1/src/modules/db/db_pgsql/table.cpp0000744000175000017500000003265112737416155022021 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table.cpp 1508 2012-11-01 16:13:43Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // Table.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "get_connection.h" #include "table.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_List::CTable_List(void) { Set_Name (_TL("List Tables")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Lists all tables of an PostgreSQL data source." )); Parameters.Add_Table( NULL , "TABLES" , _TL("Tables"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- bool CTable_List::On_Execute(void) { CSG_Strings Tables; CSG_Table *pTables = Parameters("TABLES")->asTable(); pTables->Destroy(); pTables->Set_Name(Get_Connection()->Get_Connection() + " [" + _TL("Tables") + "]"); pTables->Add_Field(_TL("Table"), SG_DATATYPE_String); pTables->Add_Field(_TL("Type" ), SG_DATATYPE_String); if( Get_Connection()->Get_Tables(Tables) ) { CSG_Table t; for(int i=0; iAdd_Record(); pTable->Set_Value(0, Tables[i]); if( Get_Connection()->Table_Load(t, "geometry_columns", "type", CSG_String::Format(SG_T("f_table_name='%s'"), Tables[i].c_str())) && t.Get_Count() == 1 ) { pTable->Set_Value(1, t[0][0].asString()); } else if( Get_Connection()->Table_Load(t, "raster_columns", "*", CSG_String::Format(SG_T("r_table_name='%s'"), Tables[i].c_str())) && t.Get_Count() == 1 ) { pTable->Set_Value(1, "RASTER"); } else { pTable->Set_Value(1, "TABLE"); } } } return( pTables->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Info::CTable_Info(void) { Set_Name (_TL("List Table Fields")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Loads table information from PostgreSQL data source." )); Parameters.Add_Table( NULL , "TABLE" , _TL("Field Description"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); } //--------------------------------------------------------- void CTable_Info::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_Parameter *pParameter = pParameters->Get_Parameter("TABLES"); pParameter->asChoice()->Set_Items(Get_Connection()->Get_Tables()); pParameter->Set_Value(pParameter->asString()); } //--------------------------------------------------------- bool CTable_Info::On_Execute(void) { CSG_String Table = Parameters("TABLES")->asString(); CSG_Table *pTable = Parameters("TABLE" )->asTable(); CSG_Table tab = Get_Connection()->Get_Field_Desc(Table); pTable->Assign(&tab); pTable->Set_Name(Table + " [" + _TL("Field Description") + "]"); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Load::CTable_Load(void) { Set_Name (_TL("Import Table")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Imports a table from a PostgreSQL database." )); Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); } //--------------------------------------------------------- void CTable_Load::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_Parameter *pParameter = pParameters->Get_Parameter("TABLES"); pParameter->asChoice()->Set_Items(Get_Connection()->Get_Tables()); pParameter->Set_Value(pParameter->asString()); } //--------------------------------------------------------- bool CTable_Load::On_Execute(void) { CSG_Table *pTable = Parameters("TABLE")->asTable(); return( Get_Connection()->Table_Load(*pTable, Parameters("TABLES")->asString()) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Save::CTable_Save(void) { Set_Name (_TL("Export Table")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Exports a table to a PostgreSQL database." )); Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Set_Constraints(&Parameters, "TABLE"); Parameters.Add_String( NULL , "NAME" , _TL("Table Name"), _TL(""), SG_T("") ); Parameters.Add_Choice( NULL , "EXISTS" , _TL("If table exists..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("abort export"), _TL("replace existing table"), _TL("append records, if table structure allows") ), 0 ); } //--------------------------------------------------------- int CTable_Save::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("TABLE")) ) { pParameters->Get_Parameter("NAME")->Set_Value(pParameter->asTable() ? pParameter->asTable()->Get_Name() : SG_T("")); } return( CSG_PG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- bool CTable_Save::On_Execute(void) { bool bResult = false; CSG_Table *pTable = Parameters("TABLE")->asTable(); CSG_String Name = Parameters("NAME" )->asString(); if( Name.Length() == 0 ) Name = pTable->Get_Name(); //----------------------------------------------------- CSG_String SavePoint; Get_Connection()->Begin(SavePoint = Get_Connection()->is_Transaction() ? "SHAPES_SAVE" : ""); //----------------------------------------------------- if( Get_Connection()->Table_Exists(Name) ) { Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("table already exists"), Name.c_str())); switch( Parameters("EXISTS")->asInt() ) { case 0: // abort export break; case 1: // replace existing table Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("dropping table"), Name.c_str())); if( !Get_Connection()->Table_Drop(Name, false) ) { Message_Add(CSG_String::Format(SG_T(" ...%s!"), _TL("failed"))); } else { bResult = Get_Connection()->Table_Save(Name, *pTable, Get_Constraints(&Parameters, "TABLE")); } break; case 2: // append records, if table structure allows Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("appending to existing table"), Name.c_str())); if( !(bResult = Get_Connection()->Table_Insert(Name, *pTable)) ) { Message_Add(CSG_String::Format(SG_T(" ...%s!"), _TL("failed"))); } break; } } else { bResult = Get_Connection()->Table_Save(Name, *pTable, Get_Constraints(&Parameters, "TABLE")); } //----------------------------------------------------- if( !bResult ) { Get_Connection()->Rollback(SavePoint); } else { Get_Connection()->Commit(SavePoint); Get_Connection()->GUI_Update(); } return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Drop::CTable_Drop(void) { Set_Name (_TL("Drop Table")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Deletes a table from a PostgreSQL database." )); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); } //--------------------------------------------------------- void CTable_Drop::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_Parameter *pParameter = pParameters->Get_Parameter("TABLES"); pParameter->asChoice()->Set_Items(Get_Connection()->Get_Tables()); pParameter->Set_Value(pParameter->asString()); } //--------------------------------------------------------- bool CTable_Drop::On_Execute(void) { if( Get_Connection()->Table_Drop(Parameters("TABLES")->asChoice()->asString()) ) { Get_Connection()->GUI_Update(); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Query::CTable_Query(void) { CSG_Parameter *pNode; Set_Name (_TL("Import Table from SQL Query")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Import a SQL table from a PostgreSQL database." )); Parameters.Add_Table( NULL , "TABLE" , _TL("Table from SQL Query"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_String( NULL , "TABLES" , _TL("Tables"), _TL(""), SG_T("") ); Parameters.Add_String( NULL , "FIELDS" , _TL("Fields"), _TL(""), SG_T("*") ); Parameters.Add_String( NULL , "WHERE" , _TL("Where"), _TL(""), SG_T("") ); pNode = Parameters.Add_String( NULL , "GROUP" , _TL("Group by"), _TL(""), SG_T("") ); Parameters.Add_String( pNode , "HAVING" , _TL("Having"), _TL(""), SG_T("") ); Parameters.Add_String( NULL , "ORDER" , _TL("Order by"), _TL(""), SG_T("") ); Parameters.Add_Value( NULL , "DISTINCT" , _TL("Distinct"), _TL(""), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------- bool CTable_Query::On_Execute(void) { CSG_Table *pTable = Parameters("TABLE" )->asTable (); CSG_String Tables = Parameters("TABLES" )->asString(); CSG_String Fields = Parameters("FIELDS" )->asString(); CSG_String Where = Parameters("WHERE" )->asString(); CSG_String Group = Parameters("GROUP" )->asString(); CSG_String Having = Parameters("HAVING" )->asString(); CSG_String Order = Parameters("ORDER" )->asString(); bool bDistinct = Parameters("DISTINCT")->asBool (); return( Get_Connection()->Table_Load(*pTable, Tables, Fields, Where, Group, Having, Order, bDistinct) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/db/db_pgsql/pgis_raster.h0000744000175000017500000001365612737416155022725 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pgis_raster.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // pgis_raster.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pgis_raster_H #define HEADER_INCLUDED__pgis_raster_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CRaster_Load : public CSG_PG_Module { public: CRaster_Load(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Raster") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CRaster_Load_Band : public CSG_PG_Module { public: CRaster_Load_Band(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Raster") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CRaster_Save : public CSG_PG_Module { public: CRaster_Save(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Raster") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CRaster_SRID_Update : public CSG_PG_Module { public: CRaster_SRID_Update(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Raster") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pgis_raster_H saga-2.3.1/src/modules/db/db_pgsql/pgis_shapes.h0000744000175000017500000001243512737416155022702 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pgis_shapes.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // PGIS_Shapes.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PGIS_Shapes_H #define HEADER_INCLUDED__PGIS_Shapes_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Load : public CSG_PG_Module { public: CShapes_Load(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Shapes") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_Save : public CSG_PG_Module { public: CShapes_Save(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Shapes") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CShapes_SRID_Update : public CSG_PG_Module { public: CShapes_SRID_Update(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Shapes") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PGIS_Shapes_H saga-2.3.1/src/modules/db/db_pgsql/get_connection.cpp0000744000175000017500000004703112737416155023726 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: get_connection.cpp 1509 2012-11-01 16:39:43Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // Get_Connection.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "get_connection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGet_Connections::CGet_Connections(void) { Set_Name (_TL("List PostgreSQL Connections")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Lists all PostgreSQL sources." )); Parameters.Add_Table( NULL , "CONNECTIONS" , _TL("Connections"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- bool CGet_Connections::On_Execute(void) { CSG_Table *pConnections = Parameters("CONNECTIONS")->asTable(); pConnections->Destroy(); pConnections->Set_Name(_TL("PostgreSQL Connections")); pConnections->Add_Field(_TL("Name" ), SG_DATATYPE_String); pConnections->Add_Field(_TL("Host" ), SG_DATATYPE_String); pConnections->Add_Field(_TL("Port" ), SG_DATATYPE_Int); pConnections->Add_Field(_TL("Database"), SG_DATATYPE_String); pConnections->Add_Field(_TL("Version" ), SG_DATATYPE_String); pConnections->Add_Field(_TL("PostGIS" ), SG_DATATYPE_String); for(int i=0; iAdd_Record(); pRecord->Set_Value(0, pConnection->Get_Connection()); pRecord->Set_Value(1, pConnection->Get_Host()); pRecord->Set_Value(2, pConnection->Get_Port()); pRecord->Set_Value(3, pConnection->Get_DBName()); pRecord->Set_Value(4, pConnection->Get_Version()); pRecord->Set_Value(5, pConnection->Get_PostGIS()); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGet_Connection::CGet_Connection(void) { Set_Name (_TL("Connect to PostgreSQL")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Connect to PostgreSQL data source." )); Parameters.Add_String( NULL , "PG_HOST" , _TL("Host"), _TL("Password"), "localhost" ); Parameters.Add_Value( NULL , "PG_PORT" , _TL("Port"), _TL(""), PARAMETER_TYPE_Int, 5432, 0, true ); Parameters.Add_String( NULL , "PG_NAME" , _TL("Database"), _TL("Database Name"), "geo_test" ); Parameters.Add_String( NULL , "PG_USER" , _TL("User"), _TL("User Name"), "postgres" ); Parameters.Add_String( NULL , "PG_PWD" , _TL("Password"), _TL("Password"), "postgres", false, true ); } //--------------------------------------------------------- bool CGet_Connection::On_Execute(void) { CSG_String Connection = CSG_String::Format(SG_T("%s [%s:%d]"), Parameters("PG_NAME")->asString(), Parameters("PG_HOST")->asString(), Parameters("PG_PORT")->asInt() ); if( SG_PG_Get_Connection_Manager().Get_Connection(Connection) ) { Message_Add(Connection + ": " + _TL("PostgreSQL source is already connected")); return( false ); } CSG_PG_Connection *pConnection = SG_PG_Get_Connection_Manager().Add_Connection( Parameters("PG_NAME")->asString(), Parameters("PG_USER")->asString(), Parameters("PG_PWD" )->asString(), Parameters("PG_HOST")->asString(), Parameters("PG_PORT")->asInt() ); if( pConnection ) { Message_Add(Connection + ": " + _TL("PostgreSQL source connected")); pConnection->GUI_Update(); return( true ); } Message_Add(Connection + ": " + _TL("could not connect to PostgreSQL source")); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDel_Connection::CDel_Connection(void) { Set_Name (_TL("Disconnect from PostgreSQL")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Disconnect PostgreSQL data source." )); Parameters.Add_Choice( NULL , "TRANSACT" , _TL("Transactions"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("rollback"), _TL("commit") ), 1 ); } //--------------------------------------------------------- bool CDel_Connection::On_Execute(void) { CSG_String Connection = Get_Connection()->Get_Connection(); if( SG_PG_Get_Connection_Manager().Del_Connection(Get_Connection(), Parameters("TRANSACT")->asInt() == 1) ) { Message_Add(Connection + ": " + _TL("PostgreSQL source disconnected")); SG_UI_ODBC_Update(Connection); return( true ); } Message_Add(Connection + ": " + _TL("could not disconnect PostgreSQL source")); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDel_Connections::CDel_Connections(void) { Set_Name (_TL("Disconnect All")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Disconnects all PostgreSQL connections." )); Parameters.Add_Choice( NULL , "TRANSACT" , _TL("Transactions"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("rollback"), _TL("commit") ), 1 ); } //--------------------------------------------------------- bool CDel_Connections::On_Before_Execution(void) { if( SG_PG_Get_Connection_Manager().Get_Count() > 0 ) { return( true ); } Message_Dlg( _TL("No PostgreSQL connection available!"), _TL("PostgreSQL Database Connection Error") ); return( false ); } //--------------------------------------------------------- bool CDel_Connections::On_Execute(void) { bool bCommit = Parameters("TRANSACT")->asInt() == 1; CSG_PG_Connections &Manager = SG_PG_Get_Connection_Manager(); for(int i=Manager.Get_Count()-1; i>=0; i--) { Manager.Del_Connection(i, bCommit); } SG_UI_ODBC_Update(""); return( Manager.Get_Count() == 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTransaction_Start::CTransaction_Start(void) { Set_Name (_TL("Begin Transaction")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Begins a transaction, which will be finished later with a commit or rollback. " "Tries to add a save point, if already in transaction mode. " )); Parameters.Add_String( NULL , "SAVEPOINT" , _TL("Save Point"), _TL(""), "SAVEPOINT_01" ); } //--------------------------------------------------------- void CTransaction_Start::On_Connection_Changed(CSG_Parameters *pParameters) { pParameters->Get_Parameter("SAVEPOINT")->Set_Enabled(Get_Connection()->is_Transaction()); } //--------------------------------------------------------- bool CTransaction_Start::On_Execute(void) { if( !Get_Connection()->is_Transaction() ) { if( Get_Connection()->Begin() ) { Message_Add(Get_Connection()->Get_Connection() + ": " + _TL("transaction started")); return( true ); } Message_Add(Get_Connection()->Get_Connection() + ": " + _TL("could not start transaction")); } else { if( Get_Connection()->Begin(Parameters("SAVEPOINT")->asString()) ) { Message_Add(Get_Connection()->Get_Connection() + ": " + _TL("save point added")); return( true ); } Message_Add(Get_Connection()->Get_Connection() + ": " + _TL("could not add save point")); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTransaction_Stop::CTransaction_Stop(void) { Set_Name (_TL("Commit/Rollback Transaction")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Execute a commit or rollback on open transactions with PostgreSQL source." )); Parameters.Add_Choice( NULL , "TRANSACT" , _TL("Transactions"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("rollback"), _TL("commit") ), 1 ); Parameters.Add_String( NULL , "SAVEPOINT" , _TL("Save Point"), _TL(""), "" ); } //--------------------------------------------------------- bool CTransaction_Stop::On_Execute(void) { if( !Get_Connection()->is_Transaction() ) { Message_Add(Get_Connection()->Get_Connection() + ": " + _TL("not in transaction")); return( false ); } if( Parameters("TRANSACT")->asInt() == 1 ) { if( Get_Connection()->Commit(Parameters("SAVEPOINT")->asString()) ) { Message_Add(Get_Connection()->Get_Connection() + ": " + _TL("open transactions committed")); SG_UI_ODBC_Update(Get_Connection()->Get_Connection()); return( true ); } } else { if( Get_Connection()->Rollback(Parameters("SAVEPOINT")->asString()) ) { Message_Add(Get_Connection()->Get_Connection() + ": " + _TL("open transactions rolled back")); SG_UI_ODBC_Update(Get_Connection()->Get_Connection()); return( true ); } } Message_Add(Get_Connection()->Get_Connection() + ": " + _TL("could not commit/rollback transactions.")); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExecute_SQL::CExecute_SQL(void) { Set_Name (_TL("Execute SQL")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Execute SQL commands on a connected PostgreSQL source. " "Separate different commands with a semicolon (\';\'). " )); Parameters.Add_String( NULL , "SQL" , _TL("SQL Statement"), _TL(""), SG_T("CREATE TABLE myTable1 (Col1 VARCHAR(255) PRIMARY KEY, Col2 INTEGER);\n") SG_T("INSERT INTO myTable1 (Col1, Col2) VALUES(\'First Value\', 1);\n") SG_T("DROP TABLE myTable1;\n"), true ); Parameters.Add_Value( NULL , "OUTPUT" , _TL("Show Results"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "STOP" , _TL("Stop on Error"), _TL(""), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------- bool CExecute_SQL::On_Execute(void) { //----------------------------------------------------- bool bOutput = Parameters("OUTPUT")->asBool (); bool bStop = Parameters("STOP" )->asBool (); CSG_String SQL = Parameters("SQL" )->asString(); //----------------------------------------------------- if( SQL.Find(SG_T(';')) < 0 ) { return( Get_Connection()->Execute(SQL) ); } //----------------------------------------------------- int nSuccess = 0, nErrors = 0; SQL += SG_T(';'); do { CSG_String s = SQL.BeforeFirst(SG_T(';')); s.Trim(); if( s.Length() > 0 ) { CSG_Table Table, *pTable; pTable = bOutput ? &Table : NULL; Message_Add(s); if( Get_Connection()->Execute(s, pTable) ) { nSuccess++; Message_Add(CSG_String::Format(SG_T("...%s!"), _TL("okay")), false); if( pTable && pTable->Get_Count() ) { int iField, iRecord; s = "\n"; for(iField=0; iFieldGet_Field_Count(); iField++) { s += iField > 0 ? "\t" : "\n"; s += pTable->Get_Field_Name(iField); } s = "\n___"; for(iRecord=0; iRecordGet_Count(); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); for(iField=0; iFieldGet_Field_Count(); iField++) { s += iField > 0 ? "\t" : "\n"; s += pRecord->asString(iField); } Message_Add(s, false); s.Clear(); } Message_Add("\n", false); } } else { nErrors++; Message_Add(CSG_String::Format(SG_T("...%s!"), _TL("failed"))); if( bStop ) { return( false ); } } } SQL = SQL.AfterFirst(SG_T(';')); } while( SQL.Length() > 0 ); return( nErrors == 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDatabase_Create::CDatabase_Create(void) { Set_Name (_TL("Create Database")); Set_Author (SG_T("O.Conrad (c) 2015")); Set_Description (_TW( "Creates a new PostgreSQL Database." )); Parameters.Add_String( NULL , "PG_HOST" , _TL("Host"), _TL("Password"), "localhost" ); Parameters.Add_Value( NULL , "PG_PORT" , _TL("Port"), _TL(""), PARAMETER_TYPE_Int, 5432, 0, true ); Parameters.Add_String( NULL , "PG_NAME" , _TL("Database"), _TL("Database Name"), "geo_test" ); Parameters.Add_String( NULL , "PG_USER" , _TL("User"), _TL("User Name"), "postgres" ); Parameters.Add_String( NULL , "PG_PWD" , _TL("Password"), _TL("Password"), "postgres", false, true ); } //--------------------------------------------------------- bool CDatabase_Create::On_Execute(void) { const SG_Char *Host, *Name, *User, *Password; Host = Parameters("PG_HOST")->asString(); int Port = Parameters("PG_PORT")->asInt(); Name = Parameters("PG_NAME")->asString(), User = Parameters("PG_USER")->asString(); Password = Parameters("PG_PWD" )->asString(); if( SG_PG_Get_Connection_Manager().Get_Connection(CSG_String::Format("%s [%s:%d]", Name, Host, Port)) ) { Message_Add(CSG_String::Format("%s [%s:%d]: %s", Name, Host, Port, _TL("PostgreSQL database is already connected"))); return( false ); } CSG_PG_Connection Connection; if( Connection.Create(Host, Port, "", User, Password) && Connection.Execute(CSG_String::Format("CREATE DATABASE %s", Name)) ) { CSG_PG_Connection *pConnection = SG_PG_Get_Connection_Manager().Add_Connection(Name, User, Password, Host, Port); if( pConnection ) { if( pConnection->Execute("CREATE EXTENSION postgis") ) { Message_Add(CSG_String::Format("%s [%s:%d]: %s", Name, Host, Port, _TL("PostGIS extension added"))); } pConnection->GUI_Update(); return( true ); } } Message_Add(CSG_String::Format("%s [%s:%d]: %s", Name, Host, Port, _TL("could not create new PostgreSQL database"))); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDatabase_Destroy::CDatabase_Destroy(void) { Set_Name (_TL("Drop Database")); Set_Author (SG_T("O.Conrad (c) 2015")); Set_Description (_TW( "Deletes a PostgreSQL Database." )); Parameters.Add_String( NULL , "PG_HOST" , _TL("Host"), _TL("Password"), "localhost" ); Parameters.Add_Value( NULL , "PG_PORT" , _TL("Port"), _TL(""), PARAMETER_TYPE_Int, 5432, 0, true ); Parameters.Add_String( NULL , "PG_NAME" , _TL("Database"), _TL("Database Name"), "geo_test" ); Parameters.Add_String( NULL , "PG_USER" , _TL("User"), _TL("User Name"), "postgres" ); Parameters.Add_String( NULL , "PG_PWD" , _TL("Password"), _TL("Password"), "postgres", false, true ); } //--------------------------------------------------------- bool CDatabase_Destroy::On_Execute(void) { const SG_Char *Host, *Name, *User, *Password; Host = Parameters("PG_HOST")->asString(); int Port = Parameters("PG_PORT")->asInt(); Name = Parameters("PG_NAME")->asString(), User = Parameters("PG_USER")->asString(); Password = Parameters("PG_PWD" )->asString(); if( SG_PG_Get_Connection_Manager().Get_Connection(CSG_String::Format("%s [%s:%d]", Name, Host, Port)) ) { if( !SG_PG_Get_Connection_Manager().Del_Connection(CSG_String::Format("%s [%s:%d]", Name, Host, Port), false) ) { Message_Add(CSG_String::Format("%s [%s:%d]: %s", Name, Host, Port, _TL("could not disconnect and drop PostgreSQL database"))); return( false ); } } CSG_PG_Connection Connection; if( Connection.Create(Host, Port, "", User, Password) && Connection.Execute(CSG_String::Format("DROP DATABASE IF EXISTS %s", Name)) ) { SG_UI_ODBC_Update(""); return( true ); } Message_Add(CSG_String::Format("%s [%s:%d]: %s", Name, Host, Port, _TL("could not drop PostgreSQL database"))); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/db/db_pgsql/pgis_raster.cpp0000744000175000017500000003436612737416155023261 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pgis_raster.cpp 1646 2013-04-10 16:29:00Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // pgis_raster.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pgis_raster.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CRaster_Load::CRaster_Load(void) { Set_Name (_TL("Import Raster from PostGIS")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Imports grids from a PostGIS database." )); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); Parameters.Add_String( NULL , "WHERE" , _TL("Where"), _TL(""), "" ); } //--------------------------------------------------------- void CRaster_Load::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_String s; CSG_Table t; if( Get_Connection()->Table_Load(t, SG_T("raster_columns")) ) { for(int i=0; iGet_Parameter("TABLES")->asChoice()->Set_Items(s); } //--------------------------------------------------------- bool CRaster_Load::On_Execute(void) { CSG_String Table = Parameters("TABLES")->asString(); CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); pGrids->Del_Items(); if( !Get_Connection()->Raster_Load(pGrids, Table, Parameters("WHERE")->asString()) ) { return( false ); } return( pGrids->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CRaster_Load_Band::CRaster_Load_Band(void) { Set_Name (_TL("Import Single Raster Band from PostGIS")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "Imports grids from a PostGIS database." )); Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); Parameters.Add_Choice( NULL , "BANDS" , _TL("Bands"), _TL(""), "" )->Set_UseInCMD(false); Parameters.Add_String( NULL , "RID" , _TL("Raster Band Identifier"), _TL(""), "" )->Set_UseInGUI(false); } //--------------------------------------------------------- void CRaster_Load_Band::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_String s; CSG_Table t; SG_UI_Progress_Lock(true); SG_UI_Msg_Lock(true); if( Get_Connection()->Table_Load(t, "raster_columns") ) { for(int i=0; iGet_Parameter("TABLES")->asChoice()->Set_Items(s); On_Parameter_Changed(pParameters, pParameters->Get_Parameter("TABLES")); } //--------------------------------------------------------- int CRaster_Load_Band::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TABLES") ) { CSG_String s; CSG_Table t; SG_UI_Progress_Lock(true); SG_UI_Msg_Lock(true); if( Get_Connection()->Table_Load(t, pParameter->asString(), "rid, name") ) { for(int i=0; iGet_Parameter("BANDS")->asChoice()->Set_Items(s); } return( CSG_PG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- bool CRaster_Load_Band::On_Execute(void) { CSG_String Table = Parameters("TABLES")->asString(), Where; CSG_Grid *pGrid = SG_Create_Grid(); if( !SG_UI_Get_Window_Main() || *Parameters("RID")->asString() ) { Where.Printf("rid=%s", Parameters("RID")->asString()); } else { Where.Printf("rid=%s", Parameters("BANDS")->asChoice()->Get_Item_Data(Parameters("BANDS")->asInt()).c_str()); } if( !Get_Connection()->Raster_Load(pGrid, Table, Where) ) { Error_Fmt("%s: %s (%s)", _TL("could not load raster"), Table.c_str(), Where.c_str()); delete(pGrid); return( false ); } Parameters("GRID")->Set_Value(pGrid); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CRaster_Save::CRaster_Save(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Export Raster to PostGIS")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Exports grids to a PostGIS database." )); //----------------------------------------------------- pNode = Parameters.Add_Grid_System( NULL , "GRID_SYSTEM" , _TL("Grid System"), _TL("") ); Parameters.Add_Grid_List( pNode , "GRIDS" , _TL("Bands"), _TL(""), PARAMETER_INPUT ); pNode = Parameters.Add_Choice( NULL , "TABLE" , _TL("Add to Table"), _TL(""), "" ); Parameters.Add_String( pNode , "NAME" , _TL("Table Name"), _TL(""), "" ); Parameters.Add_Value( pNode , "GRID_NAME" , _TL("Band Name Field"), _TL(""), PARAMETER_TYPE_Bool, true ); Add_SRID_Picker(); } //--------------------------------------------------------- void CRaster_Save::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_String s; CSG_Table t; if( Get_Connection()->Table_Load(t, "raster_columns") ) { for(int i=0; i") + CSG_String("|"); pParameters->Get_Parameter("TABLE")->asChoice()->Set_Items(s); pParameters->Get_Parameter("TABLE")->Set_Value(t.Get_Count()); On_Parameter_Changed(pParameters, pParameters->Get_Parameter("TABLE")); On_Parameter_Changed(pParameters, pParameters->Get_Parameter("GRIDS")); } //--------------------------------------------------------- int CRaster_Save::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TABLE") ) { bool bCreate = pParameter->asInt() >= pParameter->asChoice()->Get_Count() - 1; pParameters->Set_Enabled("NAME" , bCreate); pParameters->Set_Enabled("GRID_NAME", bCreate); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "GRIDS") ) { for(int i=0; iasList()->Get_Count(); i++) { CSG_Projection p = pParameter->asGridList()->asGrid(i)->Get_Projection(); if( p.is_Okay() && p.Get_EPSG() > 0 ) { Set_SRID(pParameters, p.Get_EPSG()); break; } } } return( CSG_PG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- bool CRaster_Save::On_Execute(void) { if( !Get_Connection()->has_PostGIS(2.0) ) { Error_Set(_TL("PostGIS extension missing or too old")); return( false ); } //----------------------------------------------------- CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); CSG_String SavePoint, Table; Table = Parameters("TABLE")->asInt() < Parameters("TABLE")->asChoice()->Get_Count() - 1 ? Parameters("TABLE")->asString() : Parameters("NAME" )->asString(); if( Table.Length() == 0 ) { Error_Set(_TL("no name has been specified for new raster table")); return( false ); } //----------------------------------------------------- Get_Connection()->Begin(SavePoint = Get_Connection()->is_Transaction() ? "RASTER_SAVE" : ""); //----------------------------------------------------- if( !Get_Connection()->Table_Exists(Table) ) { CSG_String SQL = "CREATE TABLE \"" + Table + "\" (\"rid\" serial PRIMARY KEY, \"raster\" raster" + (Parameters("GRID_NAME")->asBool() ? ", \"name\" varchar(64))" : ")"); if( !Get_Connection()->Execute(SQL) ) { Get_Connection()->Rollback(SavePoint); return( false ); } } //----------------------------------------------------- for(int i=0; iGet_Count(); i++) { Process_Set_Text(CSG_String::Format("%s: %s [%d/%d]", _TL("export grid"), pGrids->asGrid(i)->Get_Name(), i + 1, pGrids->Get_Count())); if( !Get_Connection()->Raster_Save(pGrids->asGrid(i), Get_SRID(), Table, pGrids->asGrid(i)->Get_Name()) ) { Get_Connection()->Rollback(SavePoint); return( false ); } //{ // CSG_Bytes WKB; // if( CSG_Grid_OGIS_Converter::to_WKBinary(WKB, pGrids->asGrid(i), Get_SRID()) ) // { // CSG_String SQL = "INSERT INTO \"" + Table + "\" (\"raster\", \"name\") VALUES(" // + "ST_AddBand('" + WKB.toHexString() + "'::raster, '" // + CSG_PG_Connection::Get_Raster_Type_To_SQL(pGrids->asGrid(i)->Get_Type()) + "'::text, 0, NULL), '" // + pGrids->asGrid(i)->Get_Name() + "')"; // if( !Get_Connection()->Execute(SQL) ) // { // Get_Connection()->Rollback(SavePoint); // return( false ); // } // } //} } //----------------------------------------------------- Get_Connection()->Commit(SavePoint); Get_Connection()->GUI_Update(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CRaster_SRID_Update::CRaster_SRID_Update(void) { Set_Name (_TL("Update Raster SRID")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( " Change the SRID of all rasters in the user-specified column and table." )); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); Add_SRID_Picker(); } //--------------------------------------------------------- void CRaster_SRID_Update::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_String s; CSG_Table t; if( Get_Connection()->Table_Load(t, SG_T("raster_columns")) ) { for(int i=0; iGet_Parameter("TABLES")->asChoice()->Set_Items(s); } //--------------------------------------------------------- bool CRaster_SRID_Update::On_Execute(void) { if( !Get_Connection()->has_PostGIS(2.1) ) { Error_Set(_TL("not supported by PostGIS versions less than 2.1")); return( false ); } //----------------------------------------------------- CSG_String Select; CSG_Table Table; Select.Printf(SG_T("r_table_name='%s'"), Parameters("TABLES")->asString()); if( !Get_Connection()->Table_Load(Table, "raster_columns", "*", Select) || Table.Get_Count() != 1 ) { return( false ); } Select.Printf(SG_T("SELECT UpdateRasterSRID('%s', '%s', %d)"), Parameters("TABLES")->asString(), Table[0].asString("r_raster_column"), Get_SRID() ); //----------------------------------------------------- if( !Get_Connection()->Execute(Select) ) { return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/db/db_pgsql/db_pgsql.cpp0000744000175000017500000014576212737416155022535 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: db_pgsql.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // db_pgsql.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "db_pgsql.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_PG_Connections g_Connections; //--------------------------------------------------------- CSG_PG_Connections & SG_PG_Get_Connection_Manager(void) { return( g_Connections ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void _Error_Message(const CSG_String &Message, const CSG_String &Additional = "") { SG_UI_Msg_Add_Execution(Message, true, SG_UI_MSG_STYLE_FAILURE); CSG_String s(Message); if( Additional.Length() > 0 ) { s += ":\n"; s += Additional; s += "\n"; } SG_UI_Msg_Add_Error(s); } //--------------------------------------------------------- void _Error_Message(const CSG_String &Message, PGconn *pConnection) { CSG_String Error = PQerrorMessage(pConnection); _Error_Message(Message, Error); } //--------------------------------------------------------- void _Error_Message(PGconn *pConnection) { CSG_String Error = PQerrorMessage(pConnection); _Error_Message(Error); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define m_pgConnection ((PGconn *)m_pConnection) /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_PG_Connection::CSG_PG_Connection(void) { m_bTransaction = false; m_pConnection = NULL; } //--------------------------------------------------------- CSG_PG_Connection::CSG_PG_Connection(const CSG_String &Host, int Port, const CSG_String &Name, const CSG_String &User, const CSG_String &Password, bool bAutoCommit) { Create(Host, Port, Name, User, Password, bAutoCommit); } bool CSG_PG_Connection::Create(const CSG_String &Host, int Port, const CSG_String &Name, const CSG_String &User, const CSG_String &Password, bool bAutoCommit) { m_bTransaction = false; m_pConnection = Name.is_Empty() ? PQsetdbLogin(Host, CSG_String::Format("%d", Port), NULL, NULL, NULL, User, Password) : PQsetdbLogin(Host, CSG_String::Format("%d", Port), NULL, NULL, Name, User, Password); if( PQstatus(m_pgConnection) != CONNECTION_OK ) { _Error_Message((_TL("Connection to database failed"), m_pgConnection)); Destroy(); return( false ); } return( true ); } //--------------------------------------------------------- CSG_PG_Connection::~CSG_PG_Connection(void) { Destroy(); } bool CSG_PG_Connection::Destroy(void) { if( !is_Connected() ) { return( false ); } PQfinish(m_pgConnection); m_pConnection = NULL; return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SG_PG_BOOL 16 #define SG_PG_BYTEA 17 #define SG_PG_CHAR 18 #define SG_PG_NAME 19 #define SG_PG_INT8 20 #define SG_PG_INT2 21 #define SG_PG_INT4 23 #define SG_PG_TEXT 25 #define SG_PG_OID 26 #define SG_PG_DATE 1082 #define SG_PG_FLOAT4 700 #define SG_PG_FLOAT8 701 #define SG_PG_VARCHAR 1043 //--------------------------------------------------------- CSG_String CSG_PG_Connection::Get_Type_To_SQL(TSG_Data_Type Type, int Size) { switch( Type ) { case SG_DATATYPE_String: return( CSG_String::Format("varchar(%d)", Size > 0 ? Size : 1) ); case SG_DATATYPE_Date: return( "date" ); case SG_DATATYPE_Char: return( "char(1)" ); case SG_DATATYPE_Byte: return( "smallint" ); case SG_DATATYPE_Short: return( "smallint" ); case SG_DATATYPE_Int: return( "integer" ); case SG_DATATYPE_Long: return( "bigint" ); case SG_DATATYPE_Color: return( "integer" ); case SG_DATATYPE_Float: return( "real" ); case SG_DATATYPE_Double: return( "double precision" ); case SG_DATATYPE_Binary: return( "bytea" ); default: return( "text" ); } } //--------------------------------------------------------- TSG_Data_Type CSG_PG_Connection::Get_Type_From_SQL(int Type) { switch( Type ) { case SG_PG_VARCHAR: return( SG_DATATYPE_String ); case SG_PG_NAME : return( SG_DATATYPE_String ); case SG_PG_TEXT : return( SG_DATATYPE_String ); case SG_PG_INT2 : return( SG_DATATYPE_Short ); // 2 bytes integer case SG_PG_INT4 : return( SG_DATATYPE_Int ); // 4 bytes integer case SG_PG_INT8 : return( SG_DATATYPE_Long ); // 8 bytes integer case SG_PG_DATE : return( SG_DATATYPE_Date ); case SG_PG_FLOAT4 : return( SG_DATATYPE_Float ); // 4 bytes floating point, inexact case SG_PG_FLOAT8 : return( SG_DATATYPE_Double ); // 8 bytes floating point, inexact case SG_PG_BYTEA : return( SG_DATATYPE_Binary ); default : return( SG_DATATYPE_String ); } } //--------------------------------------------------------- CSG_String CSG_PG_Connection::Get_Raster_Type_To_SQL(TSG_Data_Type Type) { switch( Type ) { case SG_DATATYPE_Bit : return( "1BB" ); case SG_DATATYPE_Char : return( "8BSI" ); case SG_DATATYPE_Byte : return( "8BUI" ); case SG_DATATYPE_Short : return( "16BSI" ); case SG_DATATYPE_Word : return( "16BUI" ); case SG_DATATYPE_Int : return( "32BSI" ); case SG_DATATYPE_DWord : return( "32BUI" ); case SG_DATATYPE_Long : return( "32BSI" ); case SG_DATATYPE_Float : return( "32BF" ); case SG_DATATYPE_Double: return( "64BF" ); default : return( "64BF" ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSG_PG_Connection::GUI_Update(void) const { SG_UI_ODBC_Update(Get_Connection()); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CSG_PG_Connection::Get_Connection(int Style) const { switch( Style ) { default: return( Get_DBName() + " [" + Get_Host() + ":" + Get_Port() + "]" ); case 1: return( Get_DBName() ); case 2: return( "PGSQL:" + Get_Host() + ":" + Get_Port() + ":" + Get_DBName() ); } } //--------------------------------------------------------- CSG_String CSG_PG_Connection::Get_Host(void) const { return( PQhost(m_pgConnection) ); } //--------------------------------------------------------- CSG_String CSG_PG_Connection::Get_Port(void) const { return( PQport(m_pgConnection) ); } //--------------------------------------------------------- CSG_String CSG_PG_Connection::Get_User(void) const { return( PQuser(m_pgConnection) ); } //--------------------------------------------------------- CSG_String CSG_PG_Connection::Get_DBName(void) const { return( PQdb (m_pgConnection) ); } //--------------------------------------------------------- CSG_String CSG_PG_Connection::Get_Version(void) const { int Version = PQserverVersion(m_pgConnection); return( CSG_String::Format("%d.%d.%d", (Version / 100) / 100, (Version / 100) % 100, (Version % 100) )); } //--------------------------------------------------------- bool CSG_PG_Connection::has_Version(int Major, int Minor, int Revision) const { int Version = PQserverVersion(m_pgConnection); return( Version >= (Major * 10000 + Minor * 100 + Revision) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CSG_PG_Connection::Get_PostGIS(void) const { CSG_Table t; if( _Table_Load(t, "SELECT PostGIS_Lib_Version()", "") && t.Get_Count() == 1 && t.Get_Field_Count() == 1 ) { return( t[0][0].asString() ); } return( "" ); } //--------------------------------------------------------- bool CSG_PG_Connection::has_PostGIS(double minVersion) { CSG_Table t; return( _Table_Load(t, "SELECT PostGIS_Lib_Version()", "") && t.Get_Count() == 1 && t.Get_Field_Count() == 1 && t[0][0].asDouble() >= minVersion ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_MetaData & CSG_PG_Connection::Add_MetaData(CSG_Data_Object &Object, const CSG_String &Table, const CSG_String &Select) { CSG_String Name(Object.Get_Name()); Object.Set_File_Name(Get_Connection(2) + ":" + Table); Object.Set_Name(Name); CSG_MetaData &DB = Object.Get_MetaData_DB(); DB.Del_Children(); DB.Add_Child("DBMS" , "PostgreSQL"); DB.Add_Child("HOST" , Get_Host ()); DB.Add_Child("PORT" , Get_Port ()); DB.Add_Child("USER" , Get_User ()); DB.Add_Child("NAME" , Get_DBName ()); DB.Add_Child("TABLE", Table); if( !Select.is_Empty() ) { DB.Add_Child("SELECT", Select); } return( DB ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSG_PG_Connection::Get_Tables(CSG_Strings &Tables) const { Tables.Clear(); if( is_Connected() ) { PGresult *pResult = PQexec(m_pgConnection, "SELECT table_name FROM information_schema.tables WHERE table_schema='public' ORDER BY table_name" ); if( PQresultStatus(pResult) != PGRES_TUPLES_OK ) { _Error_Message(_TL("listing of database tables failed"), m_pgConnection); } else { for(int iRecord=0; iRecordSet_Value(iField, PQgetvalue(pResult, iRecord, iField)); } } } PQclear(pResult); } return( Fields ); } //--------------------------------------------------------- CSG_String CSG_PG_Connection::Get_Field_Names(const CSG_String &Table_Name) const { CSG_Table Fields = Get_Field_Desc(Table_Name); CSG_String Names; for(int i=0; iSet_Name(_TL("Query Result")); } else { bResult = true; PQclear(pResult); } break; } return( bResult ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_PG_Connection::Begin(const CSG_String &SavePoint) { CSG_String Command; if( SavePoint.is_Empty() ) { if( !is_Connected() ) { _Error_Message(_TL("no database connection")); return( false ); } if( is_Transaction() ) { _Error_Message(_TL("already in transaction")); return( false ); } Command = "BEGIN"; } else { if( !is_Transaction() ) { _Error_Message(_TL("not in transaction")); return( false ); } Command = "SAVEPOINT " + SavePoint; } PGresult *pResult = PQexec(m_pgConnection, Command); bool bResult = PQresultStatus(pResult) == PGRES_COMMAND_OK; if( bResult ) { m_bTransaction = true; } else if( SavePoint.is_Empty() ) { _Error_Message(_TL("begin transaction command failed"), m_pgConnection); } else { _Error_Message(_TL("could not add save point"), m_pgConnection); } PQclear(pResult); return( bResult ); } //--------------------------------------------------------- bool CSG_PG_Connection::Rollback(const CSG_String &SavePoint) { if( !is_Transaction() ) { _Error_Message(_TL("not in transaction")); return( false ); } CSG_String Command = "ROLLBACK"; if( !SavePoint.is_Empty() ) { Command += " TO SAVEPOINT " + SavePoint; } PGresult *pResult = PQexec(m_pgConnection, Command); if( PQresultStatus(pResult) != PGRES_COMMAND_OK ) { _Error_Message(_TL("rollback transaction command failed"), m_pgConnection); PQclear(pResult); return( false ); } if( SavePoint.is_Empty() ) { m_bTransaction = false; } PQclear(pResult); return( true ); } //--------------------------------------------------------- bool CSG_PG_Connection::Commit(const CSG_String &SavePoint) { if( !is_Transaction() ) { _Error_Message(_TL("not in transaction")); return( false ); } CSG_String Command; if( SavePoint.is_Empty() ) { Command = "COMMIT"; } else { Command = "RELEASE SAVEPOINT " + SavePoint; } PGresult *pResult = PQexec(m_pgConnection, Command); if( PQresultStatus(pResult) != PGRES_COMMAND_OK ) { _Error_Message(_TL("commit transaction command failed"), m_pgConnection); PQclear(pResult); return( false ); } m_bTransaction = false; PQclear(pResult); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_PG_Connection::Table_Create(const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags, bool bCommit) { if( Table.Get_Field_Count() <= 0 ) { _Error_Message(_TL("no attributes in table")); return( false ); } //----------------------------------------------------- int iField; CSG_String SQL; SQL.Printf("CREATE TABLE \"%s\"(", Table_Name.c_str()); //----------------------------------------------------- for(iField=0; iField 0 ) { SQL += ", "; } SQL += CSG_String::Format("%s %s", Table.Get_Field_Name(iField), s.c_str()); } //----------------------------------------------------- if( (int)Flags.Get_Size() == Table.Get_Field_Count() ) { CSG_String s; for(iField=0; iField 0 ) { SQL += s + ")"; } } //----------------------------------------------------- SQL += ")"; return( Execute(SQL) ); } //--------------------------------------------------------- bool CSG_PG_Connection::Table_Drop(const CSG_String &Table_Name, bool bCommit) { if( !Table_Exists(Table_Name) ) { _Error_Message(_TL("database table does not exist")); return( false ); } return( Execute(CSG_String::Format("DROP TABLE \"%s\"", Table_Name.c_str())) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_PG_Connection::Table_Insert(const CSG_String &Table_Name, const CSG_Table &Table, bool bCommit) { if( !is_Connected() ) { _Error_Message(_TL("no database connection")); return( false ); } //----------------------------------------------------- if( !Table_Exists(Table_Name) ) { return( false ); } if( Table.Get_Field_Count() <= 0 || Table.Get_Field_Count() != Get_Field_Desc(Table_Name).Get_Count() ) { return( false ); } //----------------------------------------------------- int iField, nFields = Table.Get_Field_Count(); char **Values = (char **)SG_Malloc(nFields * sizeof(char *)); char **paramValues = (char **)SG_Malloc(nFields * sizeof(char *)); int *paramLengths = (int *)SG_Malloc(nFields * sizeof(int )); int *paramFormats = (int *)SG_Malloc(nFields * sizeof(int )); // Oid *paramTypes = (Oid *)SG_Malloc(nFields * sizeof(Oid )); CSG_String Insert("INSERT INTO " + Table_Name + " VALUES("); for(iField=0; iFieldis_NoData(iField) ) { paramValues [iField] = NULL; } else if( Table.Get_Field_Type(iField) == SG_DATATYPE_Binary ) { paramValues [iField] = (char *)pRecord->Get_Value(iField)->asBinary().Get_Bytes(); paramLengths[iField] = pRecord->Get_Value(iField)->asBinary().Get_Count(); } else { CSG_String Value = pRecord->asString(iField); if( 0 && Table.Get_Field_Type(iField) == SG_DATATYPE_String ) { char *s = NULL; if( Value.to_ASCII(&s) && s && *s ) { sprintf(Values[iField], "%s", s); } else { Values[iField][0] = '\0'; } SG_FREE_SAFE(s); } else { sprintf(Values[iField], "%s", Value.b_str()); } paramValues [iField] = Values[iField]; } } PGresult *pResult = PQexecParams(m_pgConnection, Insert, nFields, NULL, paramValues, paramLengths, paramFormats, 0); if( PQresultStatus(pResult) != PGRES_COMMAND_OK ) { _Error_Message(_TL("SQL execution failed"), m_pgConnection); bResult = false; } PQclear(pResult); } //----------------------------------------------------- for(iField=0; iFieldSet_NoData(iField); } else switch( Table.Get_Field_Type(iField) ) { default: pRecord->Set_Value(iField, PQgetvalue(pResult, iRecord, iField)); break; case SG_DATATYPE_Binary: { CSG_Bytes Binary; Binary.fromHexString(PQgetvalue(pResult, iRecord, iField) + 2); pRecord->Set_Value(iField, Binary); } break; } } } //----------------------------------------------------- PQclear(pResult); return( true ); } //--------------------------------------------------------- bool CSG_PG_Connection::Table_Load(CSG_Table &Table, const CSG_String &Table_Name) { if( _Table_Load(Table, CSG_String::Format("SELECT * FROM \"%s\"", Table_Name.c_str()), Table_Name) ) { Add_MetaData(Table, Table_Name); return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_PG_Connection::Table_Load(CSG_Table &Table, const CSG_String &Tables, const CSG_String &Fields, const CSG_String &Where, const CSG_String &Group, const CSG_String &Having, const CSG_String &Order, bool bDistinct) { CSG_String Select; Select.Printf("SELECT %s %s FROM %s", bDistinct ? SG_T("DISTINCT") : SG_T("ALL"), Fields.c_str(), Tables.c_str()); if( Where.Length() ) { Select += " WHERE " + Where; } if( Group.Length() ) { Select += " GROUP BY " + Group; if( Having.Length() ) { Select += " HAVING " + Having; } } if( Order.Length() ) { Select += " ORDER BY " + Order; } if( _Table_Load(Table, Select, Table.Get_Name()) ) { Add_MetaData(Table, Table.Get_Name(), Select); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_PG_Connection::Shapes_Load(CSG_Shapes *pShapes, const CSG_String &Name) { CSG_Table Info; if( !Table_Load(Info, "geometry_columns", "*", "f_table_name='" + Name + "'") || Info.Get_Count() != 1 ) { _Error_Message(_TL("table has no geometry field")); return( false ); } int SRID = Info[0].asInt("srid"); CSG_String Fields, Geometry = Info[0].asString("f_geometry_column"); Info = Get_Field_Desc(Name); if( Info.Get_Count() == 0 ) { return( false ); } for(int i=0; iCreate(Type, Name); pShapes->Get_Projection().Create(SRID); for(iField=0; iFieldAdd_Field(PQfname(pResult, iField), Get_Type_From_SQL(PQftype(pResult, iField))); } } //----------------------------------------------------- for(iRecord=0; iRecordAdd_Shape(); if( bBinary ) { Binary.fromHexString(PQgetvalue(pResult, iRecord, gField) + 2); CSG_Shapes_OGIS_Converter::from_WKBinary(Binary, pRecord); } else { CSG_Shapes_OGIS_Converter::from_WKText(PQgetvalue(pResult, iRecord, gField), pRecord); } for(iField=0, jField=0; iFieldSet_NoData(jField++); } else switch( pShapes->Get_Field_Type(jField) ) { default: pRecord->Set_Value(jField++, PQgetvalue(pResult, iRecord, iField)); break; case SG_DATATYPE_Binary: Binary.fromHexString(PQgetvalue(pResult, iRecord, iField) + 2); pRecord->Set_Value(jField++, Binary); break; } } } } //----------------------------------------------------- PQclear(pResult); Add_MetaData(*pShapes, Name, Select); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_PG_Connection::_Raster_Open(CSG_Table &Info, const CSG_String &Table, const CSG_String &Where, const CSG_String &Order, bool bBinary) { //----------------------------------------------------- if( !Table_Load(Info, "raster_columns", "*", CSG_String("r_table_name = '") + Table + "'") || Info.Get_Count() != 1 ) { SG_UI_Msg_Add_Error(CSG_String::Format("[PostGIS] %s (%s)", _TL("could not access table"), SG_T("raster_columns"))); return( false ); } CSG_String Field = Info[0].asString("r_raster_column"); //----------------------------------------------------- if( !Table_Load(Info, Table, "rid, name", Where, "", "", Order) ) { SG_UI_Msg_Add_Error(CSG_String::Format("[PostGIS] %s (%s)", _TL("could not access raster table"), Table.c_str())); return( false ); } //----------------------------------------------------- CSG_String Select = "COPY (SELECT ST_AsBinary(\"" + Field + "\") AS rastbin FROM \"" + Table + "\""; if( Where.Length() ) Select += " WHERE " + Where; if( Order.Length() ) Select += " ORDER BY " + Order; Select += ") TO STDOUT"; if( bBinary ) Select += " WITH (FORMAT 'binary')"; //----------------------------------------------------- PGresult *pResult = PQexec(m_pgConnection, Select); if( PQresultStatus(pResult) != PGRES_COPY_OUT ) { _Error_Message(_TL("SQL execution failed"), m_pgConnection); PQclear(pResult); return( false ); } PQclear(pResult); return( true ); } //--------------------------------------------------------- bool CSG_PG_Connection::_Raster_Load(CSG_Grid *pGrid, bool bFirst, bool bBinary) { //----------------------------------------------------- char *Bytes; int nBytes; if( (nBytes = PQgetCopyData(m_pgConnection, &Bytes, 0)) <= 0 ) { return( false ); } //----------------------------------------------------- CSG_Bytes Band; if( bBinary ) { int Offset = bFirst ? 25 : 6; if( *((short *)Bytes) > 0 && nBytes > Offset ) { Band.Create((BYTE *)(Bytes + Offset), nBytes - Offset); } } else if( nBytes > 3 ) { Band.fromHexString(Bytes + 3); } PQfreemem(Bytes); return( Band.Get_Count() > 0 && CSG_Grid_OGIS_Converter::from_WKBinary(Band, pGrid) ); } //--------------------------------------------------------- bool CSG_PG_Connection::Raster_Load(CSG_Parameter_Grid_List *pGrids, const CSG_String &Table, const CSG_String &Where, const CSG_String &Order) { //----------------------------------------------------- bool bBinary = true; CSG_Table Info; if( !_Raster_Open(Info, Table, Where, Order, bBinary) ) { return( false ); } //----------------------------------------------------- for(int iBand=0; iBandSet_Name(Table + " [" + Info[iBand].asString(1) + "]"); Add_MetaData(*pGrid, Table + CSG_String::Format(":rid=%d", Info[iBand].asInt(0))); SG_Get_Data_Manager().Add(pGrid); if( pGrids ) { pGrids->Add_Item(pGrid); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CSG_PG_Connection::Raster_Load(CSG_Grid *pGrid, const CSG_String &Table, const CSG_String &Where) { CSG_Table Info; if( _Raster_Open(Info, Table, Where) && _Raster_Load(pGrid, true) ) { pGrid->Set_Name(Table + " [" + Info[0].asString(1) + "]"); Add_MetaData(*pGrid, Table + CSG_String::Format(":rid=%d", Info[0].asInt(0))); SG_Get_Data_Manager().Add(pGrid); return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_PG_Connection::Raster_Save(CSG_Grid *pGrid, int SRID, const CSG_String &Table, const CSG_String &Name) { CSG_Table Info; if( !pGrid || !Table_Load(Info, "raster_columns", "*", CSG_String("r_table_name = '") + Table + "'") || Info.Get_Count() != 1 ) { SG_UI_Msg_Add_Error(CSG_String::Format("[PostGIS] %s (%s)", _TL("could not access table"), SG_T("raster_columns"))); return( false ); } CSG_String Geometry = Info[0].asString("r_raster_column"); //----------------------------------------------------- bool bBinary = false; // binary raster import not (yet??!!) supported CSG_String Select = "COPY \"" + Table + "\" (\"" + Geometry + "\") FROM STDIN"; if( bBinary ) Select += " WITH (FORMAT 'binary')"; //----------------------------------------------------- PGresult *pResult = PQexec(m_pgConnection, Select); if( PQresultStatus(pResult) != PGRES_COPY_IN ) { _Error_Message(_TL("SQL execution failed"), m_pgConnection); PQclear(pResult); return( false ); } PQclear(pResult); //----------------------------------------------------- CSG_Bytes Band; if( CSG_Grid_OGIS_Converter::to_WKBinary(Band, pGrid, SRID) ) { if( bBinary ) { PQputCopyData(m_pgConnection, (const char *)Band.Get_Bytes(), Band.Get_Count()); } else { CSG_String hex(Band.toHexString()); PQputCopyData(m_pgConnection, hex, (int)hex.Length()); } PQputCopyEnd (m_pgConnection, NULL); } //----------------------------------------------------- Table_Load(Info, Table, "rid"); // CSG_String::Format("SELECT currval('%s_rid_seq')", Table.c_str())); int rid = Info[Info.Get_Count() - 1].asInt(0); //----------------------------------------------------- Info = Get_Field_Desc(Table); if( !Name.is_Empty() && Info.Get_Count() > 2 && !SG_STR_CMP("varchar", Info[2].asString(1)) ) { Execute(CSG_String::Format("UPDATE %s SET %s='%s' WHERE rid=%d", Table.c_str(), Info[2].asString(0), Name.c_str(), rid)); } Add_MetaData(*pGrid, Table + CSG_String::Format(":rid=%d", rid)); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_PG_Connections::CSG_PG_Connections(void) { m_nConnections = 0; m_pConnections = NULL; Create(); } //--------------------------------------------------------- CSG_PG_Connections::~CSG_PG_Connections(void) { Destroy(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_PG_Connections::Create(void) { Destroy(); return( true ); } //--------------------------------------------------------- bool CSG_PG_Connections::Destroy(void) { if( m_pConnections ) { for(int i=0; iis_Connected() ) { m_pConnections = (CSG_PG_Connection **)SG_Realloc(m_pConnections, (m_nConnections + 1) * sizeof(CSG_PG_Connection *)); m_pConnections[m_nConnections++] = pConnection; } else { delete(pConnection); pConnection = NULL; } } return( pConnection ); } //--------------------------------------------------------- CSG_PG_Connection * CSG_PG_Connections::Get_Connection(const CSG_String &Name) { for(int i=0; iGet_Connection()) == 0 ) { return( m_pConnections[i] ); } } return( NULL ); } //--------------------------------------------------------- bool CSG_PG_Connections::Del_Connection(int Index, bool bCommit) { if( Index >= 0 && Index < m_nConnections ) { if( m_pConnections[Index]->is_Transaction() ) { if( bCommit ) { m_pConnections[Index]->Commit(); } else { m_pConnections[Index]->Rollback(); } } delete(m_pConnections[Index]); for(m_nConnections--; IndexGet_Connection()) == 0 ) { return( Del_Connection(i, bCommit) ); } } return( false ); } bool CSG_PG_Connections::Del_Connection(CSG_PG_Connection *pConnection, bool bCommit) { return( !pConnection ? false : Del_Connection(pConnection->Get_Connection(), bCommit) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Strings CSG_PG_Connections::Get_Servers(void) { CSG_Strings Servers; return( Servers ); } //--------------------------------------------------------- int CSG_PG_Connections::Get_Servers(CSG_Strings &Servers) { Servers = Get_Servers(); return( Servers.Get_Count() ); } //--------------------------------------------------------- int CSG_PG_Connections::Get_Servers(CSG_String &Servers) { CSG_Strings s = Get_Servers(); for(int i=0; iGet_Connection()); } return( Connections ); } //--------------------------------------------------------- int CSG_PG_Connections::Get_Connections(CSG_String &Connections) { Connections.Clear(); for(int i=0; iGet_Connection() + "|"; } return( m_nConnections ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_PG_Module::CSG_PG_Module(void) { Parameters.Add_String( NULL , "PG_HOST" , _TL("Host"), _TL("Password"), "" )->Set_UseInGUI(false); Parameters.Add_Value( NULL , "PG_PORT" , _TL("Port"), _TL(""), PARAMETER_TYPE_Int, 5432, 0, true )->Set_UseInGUI(false); Parameters.Add_String( NULL , "PG_NAME" , _TL("Database"), _TL("Database Name"), "" )->Set_UseInGUI(false); Parameters.Add_String( NULL , "PG_USER" , _TL("User"), _TL("User Name"), "" )->Set_UseInGUI(false); Parameters.Add_String( NULL , "PG_PWD" , _TL("Password"), _TL("Password"), "" )->Set_UseInGUI(false); Parameters.Add_Choice( NULL , "CONNECTION" , _TL("Available Connections"), _TL(""), "" )->Set_UseInCMD(false); m_pConnection = NULL; } //--------------------------------------------------------- bool CSG_PG_Module::On_Before_Execution(void) { m_pConnection = NULL; if( !SG_UI_Get_Window_Main() ) { m_pConnection = SG_PG_Get_Connection_Manager().Add_Connection( Parameters("PG_NAME")->asString(), Parameters("PG_USER")->asString(), Parameters("PG_PWD" )->asString(), Parameters("PG_HOST")->asString(), Parameters("PG_PORT")->asInt() ); } else { CSG_String Connections; int nConnections = SG_PG_Get_Connection_Manager().Get_Connections(Connections); if( nConnections <= 0 ) { Message_Dlg( _TL("No PostgreSQL connection available!"), _TL("PostgreSQL Database Connection Error") ); return( false ); } if( nConnections == 1 || !(m_pConnection = SG_PG_Get_Connection_Manager().Get_Connection(Parameters("CONNECTION")->asString())) ) { m_pConnection = SG_PG_Get_Connection_Manager().Get_Connection(0); } Parameters("CONNECTION")->asChoice()->Set_Items(Connections); Parameters("CONNECTION")->Set_Enabled(nConnections > 1); Parameters("CONNECTION")->Set_Value(m_pConnection->Get_Connection()); On_Parameter_Changed(&Parameters, Parameters("CONNECTION")); } return( true ); } //--------------------------------------------------------- bool CSG_PG_Module::On_After_Execution(void) { if( !SG_UI_Get_Window_Main() ) { SG_PG_Get_Connection_Manager().Del_Connection(m_pConnection, true); } return( true ); } //--------------------------------------------------------- int CSG_PG_Module::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( SG_UI_Get_Window_Main() ) { //------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_EPSG_GEOGCS") || !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_EPSG_PROJCS") ) { int EPSG; if( pParameter->asChoice()->Get_Data(EPSG) ) { pParameters->Get_Parameter("CRS_EPSG")->Set_Value(EPSG); } } //------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CONNECTION") ) { m_pConnection = SG_PG_Get_Connection_Manager().Get_Connection(pParameter->asString()); if( m_pConnection ) { On_Connection_Changed(pParameters); } } } //----------------------------------------------------- return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_PG_Module::Add_SRID_Picker(CSG_Parameters *pParameters) { if( !pParameters ) { pParameters = &Parameters; } if( pParameters->Get_Parameter("CRS_EPSG") ) { return( false ); // don't add twice ... } CSG_Parameter *pNode = pParameters->Add_Value( NULL , "CRS_EPSG" , _TL("EPSG Code"), _TL(""), PARAMETER_TYPE_Int, -1, -1, true ); if( SG_UI_Get_Window_Main() ) { pParameters->Add_Choice( pNode , "CRS_EPSG_GEOGCS" , _TL("Geographic Coordinate Systems"), _TL(""), SG_Get_Projections().Get_Names_List(SG_PROJ_TYPE_CS_Geographic) ); pParameters->Add_Choice( pNode , "CRS_EPSG_PROJCS" , _TL("Projected Coordinate Systems"), _TL(""), SG_Get_Projections().Get_Names_List(SG_PROJ_TYPE_CS_Projected) ); } return( true ); } //--------------------------------------------------------- bool CSG_PG_Module::Set_SRID_Picker_Enabled(CSG_Parameters *pParameters, bool bEnable) { CSG_Parameter *pParameter = pParameters ? pParameters->Get_Parameter("CRS_EPSG") : NULL; if( pParameter ) { pParameter->Set_Enabled(bEnable); return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_PG_Module::Set_SRID(CSG_Parameters *pParameters, int SRID) { CSG_Parameter *pParameter = pParameters ? pParameters->Get_Parameter("CRS_EPSG") : NULL; CSG_Projection Projection; if( pParameter && SG_Get_Projections().Get_Projection(Projection, SRID) ) { pParameter->Set_Value(SRID); return( true ); } return( false ); } //--------------------------------------------------------- int CSG_PG_Module::Get_SRID(CSG_Parameters *pParameters) { if( !pParameters ) { pParameters = &Parameters; } CSG_Parameter *pParameter = pParameters->Get_Parameter("CRS_EPSG"); return( pParameter ? pParameter->asInt() : -1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_PG_Module::Set_Constraints(CSG_Parameters *pParameters, const CSG_String &Identifier) { CSG_Parameter *pParent = pParameters ? pParameters->Get_Parameter(Identifier) : NULL; if( !pParent || (pParent->Get_Type() != PARAMETER_TYPE_Table && pParent->Get_Type() != PARAMETER_TYPE_Shapes) ) { return( false ); } pParameters->Add_Table_Fields(pParent, Identifier + "_PK", _TL("Primary Key"), _TL("")); pParameters->Add_Table_Fields(pParent, Identifier + "_NN", _TL("Not Null" ), _TL("")); pParameters->Add_Table_Fields(pParent, Identifier + "_UQ", _TL("Unique" ), _TL("")); return( true ); } //--------------------------------------------------------- CSG_Buffer CSG_PG_Module::Get_Constraints(CSG_Parameters *pParameters, const CSG_String &Identifier) { CSG_Buffer Flags; CSG_Parameter *pParent = pParameters ? pParameters->Get_Parameter(Identifier) : NULL; if( !pParent || (pParent->Get_Type() != PARAMETER_TYPE_Table && pParent->Get_Type() != PARAMETER_TYPE_Shapes) ) { return( Flags ); } CSG_Parameter *pFields; Flags.Set_Size(((CSG_Table *)pParent->asDataObject())->Get_Field_Count()); memset(Flags.Get_Data(), 0, Flags.Get_Size()); if( (pFields = pParameters->Get_Parameter(Identifier + "_PK")) != NULL && pFields->Get_Type() == PARAMETER_TYPE_Table_Fields ) { for(int i=0, Index; iasTableFields()->Get_Count(); i++) { if( (Index = pFields->asTableFields()->Get_Index(i)) >= 0 && Index < (int)Flags.Get_Size() ) { Flags.Get_Data()[Index] |= SG_PG_PRIMARY_KEY; } } } if( (pFields = pParameters->Get_Parameter(Identifier + "_NN")) != NULL && pFields->Get_Type() == PARAMETER_TYPE_Table_Fields ) { for(int i=0, Index; iasTableFields()->Get_Count(); i++) { if( (Index = pFields->asTableFields()->Get_Index(i)) >= 0 && Index < (int)Flags.Get_Size() ) { Flags.Get_Data()[Index] |= SG_PG_NOT_NULL; } } } if( (pFields = pParameters->Get_Parameter(Identifier + "_UQ")) != NULL && pFields->Get_Type() == PARAMETER_TYPE_Table_Fields ) { for(int i=0, Index; iasTableFields()->Get_Count(); i++) { if( (Index = pFields->asTableFields()->Get_Index(i)) >= 0 && Index < (int)Flags.Get_Size() ) { Flags.Get_Data()[Index] |= SG_PG_UNIQUE; } } } return( Flags ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/db/db_pgsql/get_connection.h0000744000175000017500000001670612737416155023400 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: get_connection.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // Get_Connection.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Get_Connection_H #define HEADER_INCLUDED__Get_Connection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGet_Connections : public CSG_Module { public: CGet_Connections(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGet_Connection : public CSG_Module { public: CGet_Connection(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDel_Connection : public CSG_PG_Module { public: CDel_Connection(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDel_Connections : public CSG_Module { public: CDel_Connections(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Before_Execution (void); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTransaction_Start : public CSG_PG_Module { public: CTransaction_Start(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTransaction_Stop : public CSG_PG_Module { public: CTransaction_Stop(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CExecute_SQL : public CSG_PG_Module { public: CExecute_SQL(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDatabase_Create : public CSG_Module { public: CDatabase_Create(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDatabase_Destroy : public CSG_Module { public: CDatabase_Destroy(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Get_Connection_H saga-2.3.1/src/modules/db/db_pgsql/table.h0000744000175000017500000001476712737416155021476 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // Table.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Table_H #define HEADER_INCLUDED__Table_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_List : public CSG_PG_Module { public: CTable_List(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Info : public CSG_PG_Module { public: CTable_Info(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Load : public CSG_PG_Module { public: CTable_Load(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tables") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Save : public CSG_PG_Module { public: CTable_Save(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tables") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Drop : public CSG_PG_Module { public: CTable_Drop(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tables") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Query : public CSG_PG_Module { public: CTable_Query(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tables") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Table_H saga-2.3.1/src/modules/db/db_pgsql/Makefile.in0000664000175000017500000005607512737447615022307 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/db/db_pgsql ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libdb_pgsql_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libdb_pgsql_la_OBJECTS = get_connection.lo MLB_Interface.lo \ db_pgsql.lo pgis_raster.lo pgis_shapes.lo table.lo libdb_pgsql_la_OBJECTS = $(am_libdb_pgsql_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdb_pgsql_la_SOURCES) DIST_SOURCES = $(libdb_pgsql_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1790 2013-08-20 09:23:17Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core $(POSTGRESQL_CFLAGS) AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) $(POSTGRESQL_LDFLAGS) $(DEP_LIBS) -shared -lpq -avoid-version pkglib_LTLIBRARIES = libdb_pgsql.la libdb_pgsql_la_SOURCES = \ get_connection.cpp\ MLB_Interface.cpp\ db_pgsql.cpp\ pgis_raster.cpp\ pgis_shapes.cpp\ table.cpp\ get_connection.h\ MLB_Interface.h\ db_pgsql.h\ pgis_raster.h\ pgis_shapes.h\ table.h libdb_pgsql_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/db/db_pgsql/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/db/db_pgsql/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libdb_pgsql.la: $(libdb_pgsql_la_OBJECTS) $(libdb_pgsql_la_DEPENDENCIES) $(EXTRA_libdb_pgsql_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libdb_pgsql_la_OBJECTS) $(libdb_pgsql_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/db_pgsql.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_connection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pgis_raster.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pgis_shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/db/db_pgsql/Makefile.am0000744000175000017500000000134412737416155022255 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1790 2013-08-20 09:23:17Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core $(POSTGRESQL_CFLAGS) AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) $(POSTGRESQL_LDFLAGS) $(DEP_LIBS) -shared -lpq -avoid-version pkglib_LTLIBRARIES = libdb_pgsql.la libdb_pgsql_la_SOURCES =\ get_connection.cpp\ MLB_Interface.cpp\ db_pgsql.cpp\ pgis_raster.cpp\ pgis_shapes.cpp\ table.cpp\ get_connection.h\ MLB_Interface.h\ db_pgsql.h\ pgis_raster.h\ pgis_shapes.h\ table.h libdb_pgsql_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/db/db_pgsql/MLB_Interface.h0000744000175000017500000001000412737416155022755 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__db_pgsql_MLB_Interface_H #define HEADER_INCLUDED__db_pgsql_MLB_Interface_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef db_pgsql_EXPORTS #define db_pgsql_EXPORT _SAGA_DLL_EXPORT #else #define db_pgsql_EXPORT _SAGA_DLL_IMPORT #endif //--------------------------------------------------------- #include "db_pgsql.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__db_pgsql_MLB_Interface_H saga-2.3.1/src/modules/db/db_pgsql/pgis_shapes.cpp0000744000175000017500000003103712737416155023234 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pgis_shapes.cpp 1646 2013-04-10 16:29:00Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // PGIS_Shapes.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pgis_shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Load::CShapes_Load(void) { Set_Name (_TL("Import Shapes from PostGIS")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Imports shapes from a PostGIS database." )); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); } //--------------------------------------------------------- void CShapes_Load::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_String s; CSG_Table t; if( Get_Connection()->Table_Load(t, SG_T("geometry_columns")) ) { for(int i=0; iasChoice()->Set_Items(s); } //--------------------------------------------------------- bool CShapes_Load::On_Execute(void) { CSG_Shapes *pShapes = Parameters("SHAPES")->asShapes(); CSG_String Name = Parameters("TABLES")->asString(); if( !Get_Connection()->Shapes_Load(pShapes, Name) ) { Error_Set(_TL("unable to load vector data from PostGIS database") + CSG_String(":\n") + Name); return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_Save::CShapes_Save(void) { //----------------------------------------------------- Set_Name (_TL("Export Shapes to PostGIS")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Exports shapes to a PostGIS database." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Set_Constraints(&Parameters, "SHAPES"); Parameters.Add_String( NULL , "NAME" , _TL("Table Name"), _TL("if empty shapes layers's name is used as table name"), SG_T("") ); Parameters.Add_Choice( NULL , "EXISTS" , _TL("If table exists..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("abort export"), _TL("replace existing table"), _TL("append records, if table structure allows") ), 0 ); Add_SRID_Picker(); } //--------------------------------------------------------- int CShapes_Save::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "SHAPES") ) { CSG_Shapes *pShapes = pParameter->asShapes() ? pParameter->asShapes() : NULL; if( pShapes && *pShapes->Get_Name() ) { pParameters->Get_Parameter("NAME")->Set_Value(pShapes->Get_Name()); } Set_SRID(pParameters, pShapes ? pShapes->Get_Projection().Get_EPSG() : -1); } return( CSG_PG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- bool CShapes_Save::On_Execute(void) { if( !Get_Connection()->has_PostGIS() ) { Error_Set(_TL("not a valid PostGIS database!")); return( false ); } //----------------------------------------------------- CSG_Shapes *pShapes; CSG_String SQL, Name, Type, Field, SavePoint; pShapes = Parameters("SHAPES")->asShapes(); Name = Parameters("NAME" )->asString(); if( Name.Length() == 0 ) Name = pShapes->Get_Name(); Field = "geometry"; int SRID = Get_SRID(); //----------------------------------------------------- if( !CSG_Shapes_OGIS_Converter::from_ShapeType(Type, pShapes->Get_Type(), pShapes->Get_Vertex_Type()) ) { Error_Set(_TL("invalid or unsupported shape or vertex type")); return( false ); } //----------------------------------------------------- Get_Connection()->Begin(SavePoint = Get_Connection()->is_Transaction() ? "SHAPES_SAVE" : ""); //----------------------------------------------------- if( Get_Connection()->Table_Exists(Name) ) { Message_Add(_TL("table already exists") + CSG_String(": ") + Name); switch( Parameters("EXISTS")->asInt() ) { case 0: // abort export return( false ); case 1: // replace existing table Message_Add(_TL("trying to drop table") + CSG_String(": ") + Name); if( !Get_Connection()->Table_Drop(Name, false) ) { Message_Add(CSG_String(" ...") + _TL("failed") + "!"); return( false ); } break; case 2: // append records, if table structure allows break; } } //----------------------------------------------------- if( !Get_Connection()->Table_Exists(Name) ) { if( !Get_Connection()->Table_Create(Name, *pShapes, Get_Constraints(&Parameters, "SHAPES"), false) ) { Error_Set(_TL("could not create table")); Get_Connection()->Rollback(SavePoint); return( false ); } //------------------------------------------------- // SELECT AddGeometryColumn(, , , , ) SQL.Printf(SG_T("SELECT AddGeometryColumn('%s', '%s', %d, '%s', %d)"), Name.c_str(), Field.c_str(), SRID, Type.c_str(), pShapes->Get_Vertex_Type() == SG_VERTEX_TYPE_XY ? 2 : pShapes->Get_Vertex_Type() == SG_VERTEX_TYPE_XYZ ? 3 : 4 ); if( !Get_Connection()->Execute(SQL) ) { Error_Set(_TL("could not create geometry field")); Get_Connection()->Rollback(SavePoint); return( false ); } } //----------------------------------------------------- bool bBinary = Get_Connection()->has_Version(9); int iShape, iField, nAdded; CSG_String Insert = "INSERT INTO \"" + Name + "\" (" + Field; for(iField=0; iFieldGet_Field_Count(); iField++) { Insert += CSG_String(", ") + pShapes->Get_Field_Name(iField); } Insert += ") VALUES ("; //----------------------------------------------------- for(iShape=0, nAdded=0; iShape==nAdded && iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); if( pShape->is_Valid() ) { SQL = Insert; if( bBinary ) { CSG_Bytes WKB; CSG_Shapes_OGIS_Converter::to_WKBinary(pShape, WKB); SQL += "ST_GeomFromWKB(E'\\\\x" + WKB.toHexString() + CSG_String::Format("', %d)", SRID); } else { CSG_String WKT; CSG_Shapes_OGIS_Converter::to_WKText(pShape, WKT); SQL += "ST_GeomFromText('" + WKT + CSG_String::Format("', %d)", SRID); } for(iField=0; iFieldGet_Field_Count(); iField++) { CSG_String s = pShape->asString(iField); if( pShapes->Get_Field_Type(iField) == SG_DATATYPE_String ) { if( 1 ) { char *_s = NULL; if( s.to_ASCII(&_s) ) s = _s; SG_FREE_SAFE(_s); } s.Replace("'", "\""); s = "'" + s + "'"; } SQL += ", " + s; } SQL += ")"; if( Get_Connection()->Execute(SQL) ) { nAdded++; } else { Message_Add(CSG_String::Format("%s [%d/%d]", _TL("could not save shape"), 1 + iShape, pShapes->Get_Count())); } } } //----------------------------------------------------- if( nAdded < pShapes->Get_Count() ) { Message_Add(SQL); Get_Connection()->Rollback(SavePoint); return( false ); } Get_Connection()->Commit(SavePoint); Get_Connection()->GUI_Update(); Get_Connection()->Add_MetaData(*pShapes, Name); pShapes->Set_Modified(false); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CShapes_SRID_Update::CShapes_SRID_Update(void) { Set_Name (_TL("Update Shapes SRID")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( " Change the SRID of all geometries in the user-specified column and table." )); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); Add_SRID_Picker(); } //--------------------------------------------------------- void CShapes_SRID_Update::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_String s; CSG_Table t; if( Get_Connection()->Table_Load(t, SG_T("geometry_columns")) ) { for(int i=0; iGet_Parameter("TABLES")->asChoice()->Set_Items(s); } //--------------------------------------------------------- bool CShapes_SRID_Update::On_Execute(void) { if( !Get_Connection()->has_PostGIS() ) { Error_Set(_TL("no PostGIS layer")); return( false ); } //----------------------------------------------------- CSG_String Select; CSG_Table Table; Select.Printf(SG_T("f_table_name='%s'"), Parameters("TABLES")->asString()); if( !Get_Connection()->Table_Load(Table, "geometry_columns", "*", Select) || Table.Get_Count() != 1 ) { return( false ); } Select.Printf(SG_T("SELECT UpdateGeometrySRID('%s', '%s', %d)"), Parameters("TABLES")->asString(), Table[0].asString("f_geometry_column"), Get_SRID() ); //----------------------------------------------------- if( !Get_Connection()->Execute(Select) ) { return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/db/db_pgsql/MLB_Interface.cpp0000744000175000017500000001307112737416155023317 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_pgsql // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("PostgreSQL") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2013") ); case MLB_INFO_Description: return( _TL("Accessing PostgreSQL databases.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Database|PostgreSQL") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "get_connection.h" #include "table.h" #include "pgis_shapes.h" #include "pgis_raster.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CGet_Connections ); case 1: return( new CGet_Connection ); case 2: return( new CDel_Connection ); case 3: return( new CDel_Connections ); case 4: return( new CTransaction_Start ); case 5: return( new CTransaction_Stop ); case 6: return( new CExecute_SQL ); case 10: return( new CTable_List ); case 11: return( new CTable_Info ); case 12: return( new CTable_Load ); case 13: return( new CTable_Save ); case 14: return( new CTable_Drop ); case 15: return( new CTable_Query ); case 20: return( new CShapes_Load ); case 21: return( new CShapes_Save ); case 22: return( new CShapes_SRID_Update ); case 30: return( new CRaster_Load ); case 33: return( new CRaster_Load_Band ); case 31: return( new CRaster_Save ); case 32: return( new CRaster_SRID_Update ); case 35: return( new CDatabase_Create ); case 36: return( new CDatabase_Destroy ); case 40: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/db/Makefile.in0000664000175000017500000004704012737447615020504 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/db ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = db_odbc db_pgsql am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @HAVE_POSTGRESQL_FALSE@@WITH_ODBC_FALSE@SUBDIRS = @HAVE_POSTGRESQL_FALSE@@WITH_ODBC_TRUE@SUBDIRS = db_odbc @HAVE_POSTGRESQL_TRUE@@WITH_ODBC_FALSE@SUBDIRS = db_pgsql @HAVE_POSTGRESQL_TRUE@@WITH_ODBC_TRUE@SUBDIRS = db_odbc db_pgsql all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/db/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/db/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/db/Makefile.am0000744000175000017500000000024512737416155020461 0ustar00oconradoconrad00000000000000if HAVE_POSTGRESQL if WITH_ODBC SUBDIRS = db_odbc db_pgsql else SUBDIRS = db_pgsql endif else if WITH_ODBC SUBDIRS = db_odbc else SUBDIRS = endif endif saga-2.3.1/src/modules/db/db_odbc/0000775000175000017500000000000012737740003017771 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/db/db_odbc/odbc.cpp0000744000175000017500000012167312737416155021425 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: saga_odbc.cpp 1513 2012-11-06 08:33:32Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_odbc // // // //-------------------------------------------------------// // // // odbc.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "odbc.h" #include #include #include using namespace std; //--------------------------------------------------------- #define OTL_ODBC_MULTI_MODE #if defined(_SAGA_LINUX) #define OTL_ODBC_UNIX #endif #if !defined(_SAGA_LINUX) && !defined(_SAGA_MSW) #define OTL_ODBC_ALTERNATE_RPC #define OTL_UNICODE #if defined(__GNUC__) namespace std { typedef unsigned short unicode_char; typedef basic_string unicode_string; } #define OTL_UNICODE_CHAR_TYPE unicode_char #define OTL_UNICODE_STRING_TYPE unicode_string #else #define OTL_UNICODE_CHAR_TYPE wchar_t #define OTL_UNICODE_STRING_TYPE wstring #endif #define std_string std::wstring #else #if defined(_UNICODE) || defined(UNICODE) #undef _UNICODE #undef UNICODE #endif #define OTL_ANSI_CPP // Turn on ANSI C++ typecasts #define OTL_STL // Turn on STL features #define std_string std::string #endif #if defined(UNICODE) #define SG_ODBC_CHAR wchar_t #else #define SG_ODBC_CHAR char #endif #include "otlv4.h" // include the OTL 4 header file //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_ODBC_Connections g_Connections; //--------------------------------------------------------- CSG_ODBC_Connections & SG_ODBC_Get_Connection_Manager(void) { return( g_Connections ); } //--------------------------------------------------------- bool SG_ODBC_is_Supported(void) { return( true ); } //--------------------------------------------------------- void _Error_Message(const CSG_String &Message, const CSG_String &Additional = SG_T("")) { SG_UI_Msg_Add_Execution(Message, true, SG_UI_MSG_STYLE_FAILURE); CSG_String s(Message); s += SG_T(":\n"); if( Additional.Length() > 0 ) { s += Additional; s += SG_T("\n"); } SG_UI_Msg_Add_Error(s); } void _Error_Message(otl_exception &e) { CSG_String s; if( e.stm_text && *e.stm_text != '\0' ) { s = (const char *)e.stm_text; if( e.var_info && *e.var_info != '\0' ) { s += SG_T(" ["); s += (const char *)e.var_info; s += SG_T("]"); } } _Error_Message((const char *)e.msg, s); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define m_Connection (*((otl_connect *)m_pConnection)) /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- 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); } } //--------------------------------------------------------- CSG_ODBC_Connection::~CSG_ODBC_Connection(void) { if( is_Connected() ) { delete(((otl_connect *)m_pConnection)); m_pConnection = NULL; } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_ODBC_Connection::Set_Size_Buffer(int Size) { if( Size > 0 ) { m_Size_Buffer = Size; return( true ); } return( false ); } //--------------------------------------------------------- int CSG_ODBC_Connection::Get_Size_LOB_Max(void) const { return( is_Connected() ? m_Connection.get_max_long_size() : 0 ); } //--------------------------------------------------------- bool CSG_ODBC_Connection::Set_Size_LOB_Max(int Size) { if( is_Connected() && Size > 0 ) { m_Connection.set_max_long_size(Size); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CSG_ODBC_Connection::_Get_DBMS_Info(int What) const { CSG_String Result; if( is_Connected() ) { SQLSMALLINT nBuffer; SQLTCHAR Buffer[256]; SQLGetInfo(m_Connection.get_connect_struct().get_hdbc(), What, (SQLPOINTER)Buffer, 255, &nBuffer); Result = (const SG_ODBC_CHAR *)Buffer; } return( Result ); } //--------------------------------------------------------- CSG_String CSG_ODBC_Connection::Get_DBMS_Name(void) const { return( _Get_DBMS_Info(SQL_DBMS_NAME) ); } //--------------------------------------------------------- CSG_String CSG_ODBC_Connection::Get_DBMS_Version(void) const { return( _Get_DBMS_Info(SQL_DBMS_VER) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSG_ODBC_Connection::Get_Tables(CSG_Strings &Tables) const { Tables.Clear(); if( is_Connected() ) { try { otl_stream Stream(m_Size_Buffer, "$SQLTables", m_Connection); // get a list of all tables in the current database. while( !Stream.eof() ) { std_string Catalog, Schema, Table, Type, Remarks; Stream >> Catalog >> Schema >> Table >> Type >> Remarks; Tables += Table.c_str(); } } catch( otl_exception &e ) { _Error_Message(e); } } return( Tables.Get_Count() ); } //--------------------------------------------------------- CSG_String CSG_ODBC_Connection::Get_Tables(void) const { CSG_String Tables; if( is_Connected() ) { try { otl_stream Stream(m_Size_Buffer, "$SQLTables", m_Connection); // get a list of all tables in the current database. while( !Stream.eof() ) { std_string Catalog, Schema, Table, Type, Remarks; Stream >> Catalog >> Schema >> Table >> Type >> Remarks; Tables += Table.c_str(); Tables += SG_T("|"); } } catch( otl_exception &e ) { _Error_Message(e); } } return( Tables ); } //--------------------------------------------------------- bool CSG_ODBC_Connection::Table_Exists(const CSG_String &Table_Name) const { if( is_Connected() ) { try { otl_stream Stream(m_Size_Buffer, "$SQLTables", m_Connection); // get a list of all tables in the current database. while( !Stream.eof() ) { std_string Catalog, Schema, Table, Type, Remarks; Stream >> Catalog >> Schema >> Table >> Type >> Remarks; if( !Table_Name.Cmp(CSG_String(Table.c_str())) ) { return( true ); } } } catch( otl_exception &e ) { _Error_Message(e); } } return( false ); } //--------------------------------------------------------- CSG_Table CSG_ODBC_Connection::Get_Field_Desc(const CSG_String &Table_Name) const { CSG_Table Fields; Fields.Set_Name(CSG_String::Format(SG_T("%s [%s]"), Table_Name.c_str(), _TL("Field Description"))); if( is_Connected() ) { try { int i, n; std_string s; otl_column_desc *desc; otl_stream Stream; Stream.set_all_column_types(otl_all_num2str|otl_all_date2str); Stream.open(m_Size_Buffer, CSG_String::Format(SG_T("$SQLColumns $3:'%s'"), Table_Name.c_str()), m_Connection); // get a list of all columns. desc = Stream.describe_select(n); for(i=0; i> s; pField->Set_Value(i, CSG_String(s.c_str())); } } } catch( otl_exception &e ) { _Error_Message(e); } } return( Fields ); } //--------------------------------------------------------- CSG_String CSG_ODBC_Connection::Get_Field_Names(const CSG_String &Table_Name) const { CSG_Table Fields = Get_Field_Desc(Table_Name); CSG_String Names; for(int i=0; i= 0 ) // { // return( bCommit ? Commit() : true ); // } // _Error_Message(_TL("sql excution error"), SQL); } catch( otl_exception &e ) { _Error_Message(e); } return( false ); } //--------------------------------------------------------- void CSG_ODBC_Connection::Set_Auto_Commit(bool bOn) { if( is_Connected() && m_bAutoCommit != bOn ) { m_bAutoCommit = bOn; if( bOn ) { m_Connection.auto_commit_on(); } else { m_Connection.auto_commit_off(); } } } //--------------------------------------------------------- bool CSG_ODBC_Connection::Commit(void) { if( !is_Connected() ) { _Error_Message(_TL("no database connection")); return( false ); } try { m_Connection.commit(); return( true ); } catch( otl_exception &e ) { _Error_Message(e); } return( false ); } //--------------------------------------------------------- bool CSG_ODBC_Connection::Rollback(void) { if( !is_Connected() ) { _Error_Message(_TL("no database connection")); return( false ); } try { m_Connection.rollback(); return( true ); } catch( otl_exception &e ) { _Error_Message(e); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_ODBC_Connection::Table_Create(const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags, bool bCommit) { if( Table.Get_Field_Count() <= 0 ) { _Error_Message(_TL("no attributes in table")); return( false ); } //----------------------------------------------------- int iField; CSG_String SQL; SQL.Printf(SG_T("CREATE TABLE \"%s\"("), Table_Name.c_str()); for(iField=0; iField 0 ) { SQL += SG_T(", "); } SQL += CSG_String::Format(SG_T("%s %s"), Table.Get_Field_Name(iField), s.c_str()); } //----------------------------------------------------- if( (int)Flags.Get_Size() == Table.Get_Field_Count() ) { CSG_String s; for(iField=0; iField 0 ) { SQL += s + SG_T(")"); } } //----------------------------------------------------- SQL += SG_T(")"); //----------------------------------------------------- return( Execute(SQL, bCommit) ); } //--------------------------------------------------------- bool CSG_ODBC_Connection::Table_Drop(const CSG_String &Table_Name, bool bCommit) { if( !Table_Exists(Table_Name) ) { _Error_Message(_TL("database table does not exist")); return( false ); } return( Execute(CSG_String::Format(SG_T("DROP TABLE \"%s\""), Table_Name.c_str()), bCommit) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_ODBC_Connection::Table_Insert(const CSG_String &Table_Name, const CSG_Table &Table, bool bCommit) { //----------------------------------------------------- if( !is_Connected() ) { _Error_Message(_TL("no database connection")); return( false ); } if( !Table_Exists(Table_Name) ) { return( false ); } CSG_Table Fields = Get_Field_Desc(Table_Name); if( Fields.Get_Count() != Table.Get_Field_Count() ) { return( false ); } //----------------------------------------------------- try { bool bLOB = false; int iField, iRecord; CSG_String Insert; otl_stream Stream; //------------------------------------------------- Insert.Printf(SG_T("INSERT INTO %s VALUES("), Table_Name.c_str()); for(iField=0; iField 0 ) { Insert += SG_T(","); } Insert += CSG_String::Format(SG_T(":f%d"), 1 + iField); switch( Table.Get_Field_Type(iField) ) { default: case SG_DATATYPE_String: Insert += SG_T(""); break; case SG_DATATYPE_Date: Insert += SG_T(""); break; case SG_DATATYPE_Char: Insert += SG_T(""); break; case SG_DATATYPE_Short: Insert += SG_T(""); break; case SG_DATATYPE_Int: Insert += SG_T(""); break; case SG_DATATYPE_Color: Insert += SG_T(""); break; case SG_DATATYPE_Long: Insert += SG_T(""); break; case SG_DATATYPE_Float: Insert += SG_T(""); break; case SG_DATATYPE_Double: Insert += SG_T(""); break; } } Insert += SG_T(")"); Stream.set_all_column_types(otl_all_date2str); Stream.set_lob_stream_mode(bLOB); Stream.open(bLOB ? 1 : m_Size_Buffer, Insert, m_Connection); std_string valString; //------------------------------------------------- for(iRecord=0; iRecordis_NoData(iField) ) { Stream << otl_null(); } else switch( Table.Get_Field_Type(iField) ) { default: case SG_DATATYPE_String: case SG_DATATYPE_Date: valString = CSG_String(pRecord->asString(iField)); Stream << valString; break; case SG_DATATYPE_Char: Stream << (char)pRecord->asChar (iField); break; case SG_DATATYPE_Short: Stream << pRecord->asShort (iField); break; case SG_DATATYPE_Int: Stream << pRecord->asInt (iField); break; case SG_DATATYPE_Color: case SG_DATATYPE_Long: Stream << (long)pRecord->asInt (iField); break; case SG_DATATYPE_Float: Stream << pRecord->asFloat (iField); break; case SG_DATATYPE_Double: Stream << pRecord->asDouble(iField); break; } } } } //----------------------------------------------------- catch( otl_exception &e ) { _Error_Message(e); return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_ODBC_Connection::Table_Save(const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags, bool bCommit) { //----------------------------------------------------- if( !is_Connected() ) { _Error_Message(_TL("no database connection")); return( false ); } if( Table_Exists(Table_Name) && !Table_Drop(Table_Name, bCommit) ) { return( false ); } if( !Table_Create(Table_Name, Table, Flags, bCommit) ) { return( false ); } if( !Table_Insert(Table_Name, Table, bCommit) ) { return( false ); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_ODBC_Connection::_Table_Load(CSG_Table &Table, const CSG_String &Select, const CSG_String &Name, bool bLOB) { //----------------------------------------------------- if( !is_Connected() ) { _Error_Message(_TL("no database connection")); return( false ); } //----------------------------------------------------- try { int valInt, iField, nFields; long valLong; float valFloat; double valDouble; std_string valString; otl_long_string valRaw(m_Connection.get_max_long_size()); otl_column_desc *Fields; otl_stream Stream; CSG_Bytes BLOB; Stream.set_all_column_types (otl_all_date2str); Stream.set_lob_stream_mode (bLOB); Stream.open (bLOB ? 1 : m_Size_Buffer, Select, m_Connection); Fields = Stream.describe_select(nFields); if( Fields == NULL || nFields <= 0 ) { _Error_Message(_TL("no fields in selection")); return( false ); } //------------------------------------------------- Table.Destroy(); Table.Set_Name(Name); for(iField=0; iField> valString; if( Stream.is_null() ) pRecord->Set_NoData(iField); else pRecord->Set_Value(iField, CSG_String(valString.c_str())); break; case SG_DATATYPE_Short: case SG_DATATYPE_Int: Stream >> valInt; if( Stream.is_null() ) pRecord->Set_NoData(iField); else pRecord->Set_Value(iField, valInt); break; case SG_DATATYPE_DWord: case SG_DATATYPE_Long: Stream >> valLong; if( Stream.is_null() ) pRecord->Set_NoData(iField); else pRecord->Set_Value(iField, valLong); break; case SG_DATATYPE_Float: Stream >> valFloat; if( Stream.is_null() ) pRecord->Set_NoData(iField); else pRecord->Set_Value(iField, valFloat); break; case SG_DATATYPE_Double: Stream >> valDouble; if( Stream.is_null() ) pRecord->Set_NoData(iField); else pRecord->Set_Value(iField, valDouble); break; case SG_DATATYPE_Binary: Stream >> valRaw; if( Stream.is_null() ) pRecord->Set_NoData(iField); else { BLOB.Clear(); for(int i=0; iSet_Value(iField, BLOB); } break; } } } } //----------------------------------------------------- catch( otl_exception &e ) { _Error_Message(e); return( false ); } return( true ); } //--------------------------------------------------------- bool CSG_ODBC_Connection::Table_Load(CSG_Table &Table, const CSG_String &Table_Name, bool bLOB) { return( _Table_Load(Table, CSG_String::Format(SG_T("SELECT * FROM \"%s\""), Table_Name.c_str()), Table_Name, bLOB) ); } //--------------------------------------------------------- bool CSG_ODBC_Connection::Table_Load(CSG_Table &Table, const CSG_String &Tables, const CSG_String &Fields, const CSG_String &Where, const CSG_String &Group, const CSG_String &Having, const CSG_String &Order, bool bDistinct, bool bLOB) { CSG_String Select; Select.Printf(SG_T("SELECT %s %s FROM %s"), bDistinct ? SG_T("DISTINCT") : SG_T("ALL"), Fields.c_str(), Tables.c_str()); if( Where.Length() ) { Select += SG_T(" WHERE ") + Where; } if( Group.Length() ) { Select += SG_T(" GROUP BY ") + Group; if( Having.Length() ) { Select += SG_T(" HAVING ") + Having; } } if( Order.Length() ) { Select += SG_T(" ORDER BY ") + Order; } return( _Table_Load(Table, Select, Table.Get_Name(), bLOB) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_ODBC_Connection::Table_Load_BLOBs(CSG_Bytes_Array &BLOBs, const CSG_String &Table_Name, const CSG_String &Field, const CSG_String &Where, const CSG_String &Order) { //----------------------------------------------------- if( !is_Connected() ) { _Error_Message(_TL("no database connection")); return( false ); } //----------------------------------------------------- try { bool bLOB = true; int nFields; otl_column_desc *Fields; otl_long_string valRaw(m_Connection.get_max_long_size()); otl_stream Stream; CSG_String Select; //------------------------------------------------- Select.Printf(SG_T("SELECT %s FROM %s"), Field.c_str(), Table_Name.c_str()); if( Where.Length() ) { Select += SG_T(" WHERE ") + Where; } if( Order.Length() ) { Select += SG_T(" ORDER BY ") + Order; } //------------------------------------------------- Stream.set_lob_stream_mode (bLOB); Stream.open (bLOB ? 1 : m_Size_Buffer, Select, m_Connection); Fields = Stream.describe_select(nFields); if( Fields == NULL || nFields <= 0 ) { _Error_Message(_TL("no fields in selection")); return( false ); } if( nFields != 1 ) { _Error_Message(_TL("more than one field in selection")); return( false ); } if( _Get_Type_From_SQL(Fields[0].otl_var_dbtype) != SG_DATATYPE_Binary )//|| _Get_Type_From_SQL(Fields[0].otl_var_dbtype) != SG_DATATYPE_String ) { _Error_Message(_TL("field cannot be mapped to binary object")); return( false ); } //------------------------------------------------- BLOBs.Destroy(); while( !Stream.eof() && SG_UI_Process_Get_Okay() ) // while not end-of-data { CSG_Bytes *pBLOB = BLOBs.Add(); Stream >> valRaw; if( !Stream.is_null() ) { for(int i=0; iAdd((BYTE)valRaw[i]); } } } } //----------------------------------------------------- catch( otl_exception &e ) { _Error_Message(e); return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_ODBC_Connections::CSG_ODBC_Connections(void) { otl_connect::otl_initialize(); // initialize ODBC environment m_hEnv = SQL_NULL_HENV; m_nConnections = 0; m_pConnections = NULL; Create(); } //--------------------------------------------------------- CSG_ODBC_Connections::~CSG_ODBC_Connections(void) { Destroy(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_ODBC_Connections::Create(void) { Destroy(); #if ODBCVER >= 0x0300 SQLRETURN r = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &m_hEnv); #else SQLRETURN r = SQLAllocEnv(&henv_); #endif if( r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO ) { SG_UI_Msg_Add_Error(SG_T("Failed to allocate environment handle")); return( false ); } #if ODBCVER >= 0x0300 // this should immediately follow an AllocEnv per ODBC3 SQLSetEnvAttr(m_hEnv, SQL_ATTR_ODBC_VERSION, (SQLPOINTER)SQL_OV_ODBC3, SQL_IS_UINTEGER); #endif return( true ); } //--------------------------------------------------------- bool CSG_ODBC_Connections::Destroy(void) { if( m_pConnections ) { for(int i=0; i= 0x0300 SQLRETURN r = SQLFreeHandle(SQL_HANDLE_ENV, m_hEnv); #else SQLRETURN r = SQLFreeEnv(m_hEnv); #endif if( r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO ) { SG_UI_Msg_Add_Error(SG_T("Failed to close ODBC connection.")); } m_hEnv = SQL_NULL_HENV; } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_ODBC_Connection * CSG_ODBC_Connections::Add_Connection(const CSG_String &Server, const CSG_String &User, const CSG_String &Password) { CSG_ODBC_Connection *pConnection = new CSG_ODBC_Connection(Server, User, Password); if( pConnection ) { if( pConnection->is_Connected() ) { m_pConnections = (CSG_ODBC_Connection **)SG_Realloc(m_pConnections, (m_nConnections + 1) * sizeof(CSG_ODBC_Connection *)); m_pConnections[m_nConnections++] = pConnection; } else { delete(pConnection); pConnection = NULL; } } return( pConnection ); } //--------------------------------------------------------- CSG_ODBC_Connection * CSG_ODBC_Connections::Get_Connection(const CSG_String &Server) { for(int i=0; iGet_Server().Cmp(Server) == 0 ) { return( m_pConnections[i] ); } } return( NULL ); } //--------------------------------------------------------- bool CSG_ODBC_Connections::Del_Connection(int Index, bool bCommit) { if( Index >= 0 && Index < m_nConnections ) { if( bCommit ) { m_pConnections[Index]->Commit(); } else { m_pConnections[Index]->Rollback(); } delete(m_pConnections[Index]); for(m_nConnections--; IndexGet_Server().Cmp(Server) == 0 ) { return( Del_Connection(i, bCommit) ); } } return( false ); } bool CSG_ODBC_Connections::Del_Connection(CSG_ODBC_Connection *pConnection, bool bCommit) { return( !pConnection ? false : Del_Connection(pConnection->Get_Server(), bCommit) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Strings CSG_ODBC_Connections::Get_Servers(void) { CSG_Strings Servers; SQLRETURN r; SQLSMALLINT dsnlen, dsclen; SQLTCHAR dsn[SQL_MAX_DSN_LENGTH + 1], dsc[256]; r = SQLDataSources(m_hEnv, SQL_FETCH_FIRST, (SQLTCHAR *)dsn, SQL_MAX_DSN_LENGTH + 1, &dsnlen, (SQLTCHAR *)dsc, 256, &dsclen ); if( r != SQL_SUCCESS && r != SQL_SUCCESS_WITH_INFO ) { SG_UI_Msg_Add_Error(SG_T("Unable to retrieve data source names!")); } else { do { Servers += CSG_String((const SG_ODBC_CHAR *)dsn); r = SQLDataSources(m_hEnv, SQL_FETCH_NEXT, (SQLTCHAR *)dsn, SQL_MAX_DSN_LENGTH + 1, &dsnlen, (SQLTCHAR *)dsc, 256, &dsclen ); } while( r == SQL_SUCCESS || r == SQL_SUCCESS_WITH_INFO ); } return( Servers ); } //--------------------------------------------------------- int CSG_ODBC_Connections::Get_Servers(CSG_Strings &Servers) { Servers = Get_Servers(); return( Servers.Get_Count() ); } //--------------------------------------------------------- int CSG_ODBC_Connections::Get_Servers(CSG_String &Servers) { CSG_Strings s = Get_Servers(); for(int i=0; iGet_Server()); } return( Connections ); } //--------------------------------------------------------- int CSG_ODBC_Connections::Get_Connections(CSG_String &Connections) { CSG_Strings s = Get_Connections(); Connections.Clear(); for(int i=0; iSet_UseInGUI(false); Parameters.Add_String(NULL, "ODBC_USR" , _TL("User" ), _TL("User Name" ), "")->Set_UseInGUI(false); Parameters.Add_String(NULL, "ODBC_PWD" , _TL("Password" ), _TL("Password" ), "")->Set_UseInGUI(false); Parameters.Add_Choice(NULL, "CONNECTION", _TL("Server Connection"), _TL("Server Connection"), "")->Set_UseInCMD(false); m_pConnection = NULL; } //--------------------------------------------------------- bool CSG_ODBC_Module::On_Before_Execution(void) { m_pConnection = NULL; if( !SG_UI_Get_Window_Main() ) { m_pConnection = SG_ODBC_Get_Connection_Manager().Add_Connection( Parameters("ODBC_DSN")->asString(), Parameters("ODBC_USR")->asString(), Parameters("ODBC_PWD")->asString() ); if( m_pConnection == NULL ) { Message_Dlg( _TL("No ODBC connection available!"), _TL("ODBC Database Connection Error") ); return( false ); } } else { CSG_String Connections; int nConnections = SG_ODBC_Get_Connection_Manager().Get_Connections(Connections); if( nConnections <= 0 ) { Message_Dlg( _TL("No ODBC connection available!"), _TL("ODBC Database Connection Error") ); return( false ); } if( nConnections == 1 ) { m_pConnection = SG_ODBC_Get_Connection_Manager().Get_Connection(0); } Parameters("CONNECTION")->asChoice()->Set_Items(Connections); Parameters("CONNECTION")->Set_Enabled(nConnections > 1); if( !(m_pConnection = SG_ODBC_Get_Connection_Manager().Get_Connection(Parameters("CONNECTION")->asString())) ) { m_pConnection = SG_ODBC_Get_Connection_Manager().Get_Connection(0); } On_Parameter_Changed(&Parameters, Parameters("CONNECTION")); } return( true ); } //--------------------------------------------------------- bool CSG_ODBC_Module::On_After_Execution(void) { if( !SG_UI_Get_Window_Main() ) { SG_ODBC_Get_Connection_Manager().Del_Connection(m_pConnection, true); } return( true ); } //--------------------------------------------------------- int CSG_ODBC_Module::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( SG_UI_Get_Window_Main() && !SG_STR_CMP(pParameter->Get_Identifier(), "CONNECTION") ) { m_pConnection = SG_ODBC_Get_Connection_Manager().Get_Connection(pParameter->asString()); if( m_pConnection ) { On_Connection_Changed(pParameters); } } return( -1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_ODBC_Module::Set_Constraints(CSG_Parameters *pParameters, CSG_Table *pTable) { if( !pParameters || !pTable ) { return( false ); } pParameters->Del_Parameters(); if( pTable ) { CSG_Parameter *pP = pParameters->Add_Node(NULL, "P", _TL("Primary key)") , _TL("")); CSG_Parameter *pN = pParameters->Add_Node(NULL, "N", _TL("Not Null") , _TL("")); CSG_Parameter *pU = pParameters->Add_Node(NULL, "U", _TL("Unique") , _TL("")); for(int i=0; iGet_Field_Count(); i++) { pParameters->Add_Value(pP, CSG_String::Format(SG_T("P%d"), i), pTable->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false); pParameters->Add_Value(pN, CSG_String::Format(SG_T("N%d"), i), pTable->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false); pParameters->Add_Value(pU, CSG_String::Format(SG_T("U%d"), i), pTable->Get_Field_Name(i), _TL(""), PARAMETER_TYPE_Bool, false); } } return( true ); } //--------------------------------------------------------- CSG_Buffer CSG_ODBC_Module::Get_Constraints(CSG_Parameters *pParameters, CSG_Table *pTable) { CSG_Buffer Flags; if( pParameters ) { int nFields = pTable ? pTable->Get_Field_Count() : (pParameters->Get_Count() - 3) / 3; if( nFields * 3 + 3 == pParameters->Get_Count() ) { for(int i=0; iGet_Parameter(CSG_String::Format(SG_T("P%d"), i))->asBool() ) { Flag |= SG_ODBC_PRIMARY_KEY; } if( pParameters->Get_Parameter(CSG_String::Format(SG_T("N%d"), i))->asBool() ) { Flag |= SG_ODBC_NOT_NULL; } if( pParameters->Get_Parameter(CSG_String::Format(SG_T("U%d"), i))->asBool() ) { Flag |= SG_ODBC_UNIQUE; } Flags += Flag; } } } return( Flags ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/db/db_odbc/table.cpp0000744000175000017500000003177112737416155021604 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_odbc // // // //-------------------------------------------------------// // // // Table.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "get_connection.h" #include "table.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_List::CTable_List(void) { Set_Name (_TL("List Tables")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Lists all tables of an ODBC data source." )); Parameters.Add_Table( NULL , "TABLES" , _TL("Tables"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- bool CTable_List::On_Execute(void) { CSG_Table *pTables = Parameters("TABLES")->asTable(); pTables->Destroy(); pTables->Set_Name(_TL("Tables")); pTables->Add_Field(_TL("Table"), SG_DATATYPE_String); if( Get_Connection() ) { CSG_Strings Tables; Get_Connection()->Get_Tables(Tables); for(int i=0; iAdd_Record(); pTable->Set_Value(0, Tables[i]); } pTables->Set_Name(Get_Connection()->Get_Server() + " [" + _TL("Tables") + "]"); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Info::CTable_Info(void) { Set_Name (_TL("List Table Fields")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "Loads table information from ODBC data source." )); Parameters.Add_Table( NULL , "TABLE" , _TL("Field Description"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); } //--------------------------------------------------------- void CTable_Info::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_Parameter *pParameter = pParameters->Get_Parameter("TABLES"); pParameter->asChoice()->Set_Items(Get_Connection()->Get_Tables()); pParameter->Set_Value(pParameter->asString()); } //--------------------------------------------------------- bool CTable_Info::On_Execute(void) { CSG_String Table = Parameters("TABLES")->asString(); CSG_Table *pTable = Parameters("TABLE" )->asTable(); CSG_Table tab = Get_Connection()->Get_Field_Desc(Table); pTable->Assign(&tab); pTable->Set_Name(Table + " [" + _TL("Field Description") + "]"); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Load::CTable_Load(void) { Set_Name (_TL("Import Table")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "Imports a table from a database via ODBC." )); Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); } //--------------------------------------------------------- void CTable_Load::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_Parameter *pParameter = pParameters->Get_Parameter("TABLES"); pParameter->asChoice()->Set_Items(Get_Connection()->Get_Tables()); pParameter->Set_Value(pParameter->asString()); } //--------------------------------------------------------- bool CTable_Load::On_Execute(void) { CSG_Table *pTable = Parameters("TABLE")->asTable(); return( Get_Connection()->Table_Load(*pTable, Parameters("TABLES")->asString()) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Save::CTable_Save(void) { Set_Name (_TL("Export Table")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "Exports a table to a database via ODBC." )); Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_String( NULL , "NAME" , _TL("Table Name"), _TL(""), SG_T("") ); Parameters.Add_Parameters( NULL , "FLAGS" , _TL("Constraints"), _TL("") ); Parameters.Add_Choice( NULL , "EXISTS" , _TL("If table exists..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("abort export"), _TL("replace existing table"), _TL("append records, if table structure allows") ), 0 ); } //--------------------------------------------------------- int CTable_Save::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("TABLE")) ) { pParameters->Get_Parameter("NAME")->Set_Value(pParameter->asTable() ? pParameter->asTable()->Get_Name() : SG_T("")); Set_Constraints(pParameters->Get_Parameter("FLAGS")->asParameters(), pParameter->asTable()); } return( CSG_ODBC_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- bool CTable_Save::On_Execute(void) { bool bResult = false; CSG_Table *pTable = Parameters("TABLE")->asTable(); CSG_String Name = Parameters("NAME" )->asString(); if( Name.Length() == 0 ) Name = pTable->Get_Name(); //----------------------------------------------------- if( Get_Connection()->Table_Exists(Name) ) { Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("table already exists"), Name.c_str())); switch( Parameters("EXISTS")->asInt() ) { case 0: // abort export break; case 1: // replace existing table Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("dropping table"), Name.c_str())); if( !Get_Connection()->Table_Drop(Name, false) ) { Message_Add(CSG_String::Format(SG_T(" ...%s!"), _TL("failed"))); } else { bResult = Get_Connection()->Table_Save(Name, *pTable, Get_Constraints(Parameters("FLAGS")->asParameters(), pTable)); } break; case 2: // append records, if table structure allows Message_Add(CSG_String::Format(SG_T("%s: %s"), _TL("appending to existing table"), Name.c_str())); if( !(bResult = Get_Connection()->Table_Insert(Name, *pTable)) ) { Message_Add(CSG_String::Format(SG_T(" ...%s!"), _TL("failed"))); } break; } } else { bResult = Get_Connection()->Table_Save(Name, *pTable, Get_Constraints(Parameters("FLAGS")->asParameters(), pTable)); } //----------------------------------------------------- if( bResult ) { SG_UI_ODBC_Update(Get_Connection()->Get_Server()); } return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Drop::CTable_Drop(void) { Set_Name (_TL("Drop Table")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "Deletes a table from a database via ODBC." )); Parameters.Add_Choice( NULL , "TABLES" , _TL("Tables"), _TL(""), "" ); } //--------------------------------------------------------- void CTable_Drop::On_Connection_Changed(CSG_Parameters *pParameters) { CSG_Parameter *pParameter = pParameters->Get_Parameter("TABLES"); pParameter->asChoice()->Set_Items(Get_Connection()->Get_Tables()); pParameter->Set_Value(pParameter->asString()); } //--------------------------------------------------------- bool CTable_Drop::On_Execute(void) { if( Get_Connection()->Table_Drop(Parameters("TABLES")->asChoice()->asString()) ) { SG_UI_ODBC_Update(Get_Connection()->Get_Server()); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Query::CTable_Query(void) { CSG_Parameter *pNode; Set_Name (_TL("Import Table from SQL Query")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "Import a SQL table from a database via ODBC." )); Parameters.Add_Table( NULL , "TABLE" , _TL("Table from SQL Query"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_String( NULL , "TABLES" , _TL("Tables"), _TL(""), SG_T("") ); Parameters.Add_String( NULL , "FIELDS" , _TL("Fields"), _TL(""), SG_T("*") ); Parameters.Add_String( NULL , "WHERE" , _TL("Where"), _TL(""), SG_T("") ); pNode = Parameters.Add_String( NULL , "GROUP" , _TL("Group by"), _TL(""), SG_T("") ); Parameters.Add_String( pNode , "HAVING" , _TL("Having"), _TL(""), SG_T("") ); Parameters.Add_String( NULL , "ORDER" , _TL("Order by"), _TL(""), SG_T("") ); Parameters.Add_Value( NULL , "DISTINCT" , _TL("Distinct"), _TL(""), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------- bool CTable_Query::On_Execute(void) { CSG_Table *pTable = Parameters("TABLE" )->asTable (); CSG_String Tables = Parameters("TABLES" )->asString(); CSG_String Fields = Parameters("FIELDS" )->asString(); CSG_String Where = Parameters("WHERE" )->asString(); CSG_String Group = Parameters("GROUP" )->asString(); CSG_String Having = Parameters("HAVING" )->asString(); CSG_String Order = Parameters("ORDER" )->asString(); bool bDistinct = Parameters("DISTINCT")->asBool (); return( Get_Connection()->Table_Load(*pTable, Tables, Fields, Where, Group, Having, Order, bDistinct) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/db/db_odbc/get_connection.cpp0000744000175000017500000003223312737416155023505 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: get_connection.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_odbc // // // //-------------------------------------------------------// // // // Get_Connection.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "get_connection.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGet_Servers::CGet_Servers(void) { Set_Name (_TL("List ODBC Servers")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Lists all ODBC sources." )); Parameters.Add_Table( NULL , "SERVERS" , _TL("Server"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "CONNECTED" , _TL("Only List Connected Servers"), _TL(""), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------- bool CGet_Servers::On_Execute(void) { bool bConnected = Parameters("CONNECTED")->asBool(); CSG_Table *pServers = Parameters("SERVERS" )->asTable(); pServers->Destroy(); pServers->Set_Name(_TL("ODBC Servers")); pServers->Add_Field(_TL("Server") , SG_DATATYPE_String); pServers->Add_Field(_TL("Connected"), SG_DATATYPE_Int); CSG_Strings Servers; if( SG_ODBC_Get_Connection_Manager().Get_Servers(Servers) > 0 ) { for(int i=0; iAdd_Record(); pServer->Set_Value(0, Servers[i]); pServer->Set_Value(1, SG_ODBC_Get_Connection_Manager().Get_Connection(Servers[i]) ? 1 : 0); } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGet_Connection::CGet_Connection(void) { Set_Name (_TL("Connect to ODBC Source")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "Connects to an ODBC source." )); Parameters.Add_Choice( NULL , "SERVER" , _TL("Server"), _TL(""), _TL("") ); Parameters.Add_String( NULL , "USERNAME" , _TL("User"), _TL(""), _TL("") ); Parameters.Add_String( NULL , "PASSWORD" , _TL("Password"), _TL(""), SG_T(""), false, true ); } //--------------------------------------------------------- bool CGet_Connection::On_Before_Execution(void) { CSG_String Servers; if( SG_ODBC_Get_Connection_Manager().Get_Servers(Servers) > 0 ) { Parameters("SERVER")->asChoice()->Set_Items(Servers); return( true ); } Message_Dlg( _TW("No ODBC server available!\n" "Set up an ODBC server first."), _TL("ODBC Database Connection Error") ); return( false ); } //--------------------------------------------------------- bool CGet_Connection::On_Execute(void) { CSG_String Server, User, Password; Server = Parameters("SERVER" )->asString(); User = Parameters("USERNAME")->asString(); Password = Parameters("PASSWORD")->asString(); if( SG_ODBC_Get_Connection_Manager().Add_Connection(Server, User, Password) ) { Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("ODBC source connected"))); SG_UI_ODBC_Update(Server); return( true ); } Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("could not connect ODBC source"))); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDel_Connection::CDel_Connection(void) { Set_Name (_TL("Disconnect from ODBC Source")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "Disconnects an ODBC source connection." )); Parameters.Add_Choice( NULL , "TRANSACT" , _TL("Transactions"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("rollback"), _TL("commit") ), 1 ); } //--------------------------------------------------------- bool CDel_Connection::On_Execute(void) { CSG_String Server = Get_Connection()->Get_Server(); if( SG_ODBC_Get_Connection_Manager().Del_Connection(Get_Connection(), Parameters("TRANSACT")->asInt() == 1) ) { Message_Add(Server + ": " + _TL("ODBC source disconnected")); SG_UI_ODBC_Update(Server); return( true ); } Message_Add(Server + ": " + _TL("could not disconnect ODBC source")); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDel_Connections::CDel_Connections(void) { Set_Name (_TL("Disconnect All")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Disconnects all connected ODBC sources." )); Parameters.Add_Choice( NULL , "TRANSACT" , _TL("Transactions"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("rollback"), _TL("commit") ), 1 ); } //--------------------------------------------------------- bool CDel_Connections::On_Before_Execution(void) { CSG_String Servers; if( SG_ODBC_Get_Connection_Manager().Get_Connections(Servers) > 0 ) { return( true ); } Message_Dlg( _TL("No ODBC connection available!"), _TL("ODBC Database Connection Error") ); return( false ); } //--------------------------------------------------------- bool CDel_Connections::On_Execute(void) { bool bCommit = Parameters("TRANSACT")->asInt() == 1; CSG_ODBC_Connections &Manager = SG_ODBC_Get_Connection_Manager(); for(int i=Manager.Get_Count()-1; i>=0; i--) { Manager.Del_Connection(i, bCommit); } return( Manager.Get_Count() == 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTransaction::CTransaction(void) { Set_Name (_TL("Commit/Rollback Transaction")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "Execute a commit or rollback on open transactions with ODBC source." )); Parameters.Add_Choice( NULL , "SERVERS" , _TL("Server"), _TL(""), _TL("") ); Parameters.Add_Choice( NULL , "TRANSACT" , _TL("Transactions"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("rollback"), _TL("commit") ), 1 ); } //--------------------------------------------------------- bool CTransaction::On_Before_Execution(void) { CSG_String Servers; if( SG_ODBC_Get_Connection_Manager().Get_Connections(Servers) > 0 ) { Parameters("SERVERS")->asChoice()->Set_Items(Servers); return( true ); } Message_Dlg( _TL("No ODBC connection available!"), _TL("ODBC Database Connection Error") ); return( false ); } //--------------------------------------------------------- bool CTransaction::On_Execute(void) { CSG_String Server; Server = Parameters("SERVERS") ->asString(); CSG_ODBC_Connection *pConnection = SG_ODBC_Get_Connection_Manager().Get_Connection(Server); if( !pConnection ) { return( false ); } if( Parameters("TRANSACT")->asInt() == 1 ) { if( pConnection->Commit() ) { Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("open transactions committed"))); SG_UI_ODBC_Update(Server); return( true ); } } else { if( pConnection->Rollback() ) { Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("open transactions rollbacked"))); SG_UI_ODBC_Update(Server); return( true ); } } Message_Add(CSG_String::Format(SG_T("%s: %s"), Server.c_str(), _TL("could not commit/rollback transactions."))); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExecute_SQL::CExecute_SQL(void) { Set_Name (_TL("Execute SQL")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "Execute SQL commands on a connected ODBC source. " "Separate different commands with a semicolon (\';\'). " )); Parameters.Add_String( NULL , "SQL" , _TL("SQL Statment"), _TL(""), SG_T("CREATE TABLE myTable1 (Col1 VARCHAR(255) PRIMARY KEY, Col2 INTEGER);\n") SG_T("INSERT INTO myTable1 (Col1, Col2) VALUES(\'First Value\', 1);\n") SG_T("DROP TABLE myTable1;\n"), true ); Parameters.Add_Value( NULL , "COMMIT" , _TL("Commit"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "STOP" , _TL("Stop on Error"), _TL(""), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------- bool CExecute_SQL::On_Execute(void) { if( !Get_Connection() ) { return( false ); } //----------------------------------------------------- bool bCommit = Parameters("COMMIT") ->asBool (); bool bStop = Parameters("STOP") ->asBool (); CSG_String SQL = Parameters("SQL") ->asString(); //----------------------------------------------------- if( SQL.Find(SG_T(';')) < 0 ) { return( Get_Connection()->Execute(SQL, bCommit) ); } //----------------------------------------------------- int nSuccess = 0, nErrors = 0; SQL += SG_T(';'); do { CSG_String s = SQL.BeforeFirst(SG_T(';')); s.Trim(); if( s.Length() > 0 ) { Message_Add(s); if( Get_Connection()->Execute(s, bCommit) ) { nSuccess++; Message_Add(CSG_String::Format(SG_T("...%s!"), _TL("okay")), false); } else { nErrors++; Message_Add(CSG_String::Format(SG_T("...%s!"), _TL("failed"))); if( bStop ) { return( false ); } } } SQL = SQL.AfterFirst(SG_T(';')); } while( SQL.Length() > 0 ); return( nErrors == 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/db/db_odbc/otlv4.h0000744000175000017500000310323412737416155021227 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: otlv4.h 1100 2011-06-17 00:47:16Z johanvdw $ *********************************************************/ // ================================================================================= // ORACLE, ODBC and DB2/CLI Template Library, Version 4.0.210, // Copyright (C) 1996-2010, Sergei Kuchin (skuchin@gmail.com) // // This library is free software. Permission to use, copy, modify, // and/or distribute this software for any purpose with or without fee // is hereby granted, provided that the above copyright notice and // this permission notice appear in all copies. // // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // // a.k.a. as Open BSD license // (http://www.openbsd.org/cgi-bin/cvsweb/~checkout~/src/share/misc/license.template // ================================================================================= #ifndef __OTL_H__ #define __OTL_H__ #if defined(OTL_INCLUDE_0) #include "otl_include_0.h" #endif #define OTL_VERSION_NUMBER (0x0400D2L) #if defined(_MSC_VER) && (_MSC_VER >= 1400) #pragma warning (disable:4351) #pragma warning (disable:4290) #define OTL_STRCAT_S(dest,dest_sz,src) strcat_s(dest,dest_sz,src) #define OTL_STRCPY_S(dest,dest_sz,src) strcpy_s(dest,dest_sz,src) #define OTL_STRNCPY_S(dest,dest_sz,src,count) strncpy_s(dest,dest_sz,src,count) #else #define OTL_STRCAT_S(dest,dest_sz,src) strcat(dest,src) #define OTL_STRCPY_S(dest,dest_sz,src) strcpy(dest,src) #define OTL_STRNCPY_S(dest,dest_sz,src,count) strncpy(dest,src,count) #endif #include #include #include #include #include //======================= CONFIGURATION #DEFINEs =========================== // Uncomment the following line in order to include the OTL for ODBC: //#define OTL_ODBC // Uncomment the following line in order to include the OTL for // MySQL/MyODBC for MyODBC 2.5 (pretty old). Otherwise, use OTL_ODBC //#define OTL_ODBC_MYSQL // Uncomment the following line in order to include the OTL for DB2 CLI: //#define OTL_DB2_CLI // Uncomment the following line in order to include the OTL for // Oracle 7: //#define OTL_ORA7 // Uncomment the following line in order to include the OTL for // Oracle 8: //#define OTL_ORA8 // Uncomment the following line in order to include the OTL for // Oracle 8i: //#define OTL_ORA8I // Uncomment the following line in order to include the OTL for // Oracle 9i: //#define OTL_ORA9I // Uncomment the following line in order to include the OTL for // Oracle 10g Release 1: //#define OTL_ORA10G // Uncomment the following line in order to include the OTL for // Oracle 10g Release 2: //#define OTL_ORA10G_R2 // Uncomment the following line in order to include the OTL for // Oracle 11g Release 1 //#define OTL_ORA11G // The macro definitions may be also turned on via C++ compiler command line // option, e.g.: -DOTL_ODBC, -DOTL_ORA7, -DOTL_ORA8, -DOTL_ORA8I, -DOTL_ODBC_UNIX // -DOTL_ODBC_MYSQL, -DOTL_DB2_CLI // this becomes the default from version 4.0.162 and on. // the #define is not enabled for vc++ 6.0 in version 4.0.167 and higher. #if !defined(OTL_UNCAUGHT_EXCEPTION_ON) && !(defined(_MSC_VER)&&(_MSC_VER==1200)) #define OTL_UNCAUGHT_EXCEPTION_ON #endif #if !defined(OTL_TRACE_LEVEL) #define OTL_TRACE_FORMAT_TZ_DATETIME(s) #define OTL_TRACE_FORMAT_DATETIME(s) #else #if !defined(OTL_TRACE_FORMAT_DATETIME) #define OTL_TRACE_FORMAT_TZ_DATETIME(s) \ s.month<<"/"< #endif #if defined(OTL_ODBC_TIMESTEN_UNIX) #define OTL_ODBC_TIMESTEN #define OTL_ODBC #define OTL_ODBC_UNIX #define OTL_ODBC_SQL_EXTENDED_FETCH_ON #include #endif #if defined(OTL_ODBC_ENTERPRISEDB) #define OTL_ODBC_POSTGRESQL #endif #if defined(OTL_ODBC_POSTGRESQL) #define OTL_ODBC #endif // Comment out this #define when using pre-ANSI C++ compiler #if !defined(OTL_ODBC_zOS) && !defined (OTL_ANSI_CPP) #define OTL_ANSI_CPP #endif #if defined(OTL_ODBC_zOS) #define OTL_ODBC_UNIX #define OTL_ODBC_SQL_EXTENDED_FETCH_ON #endif #if defined(OTL_ORA8I) #define OTL_ORA8 #define OTL_ORA8_8I_REFCUR #define OTL_ORA8_8I_DESC_COLUMN_SCALE #endif #if defined(OTL_ORA10G)||defined(OTL_ORA10G_R2) #define OTL_ORA9I #define OTL_ORA_NATIVE_TYPES #endif #if defined(OTL_ORA9I) #define OTL_ORA8 #define OTL_ORA8_8I_REFCUR #define OTL_ORA8_8I_DESC_COLUMN_SCALE #endif #if defined(OTL_ODBC_MYSQL) #define OTL_ODBC #endif #if defined(OTL_ODBC_XTG_IBASE6) #define OTL_ODBC #endif #define OTL_VALUE_TEMPLATE //#define OTL_ODBC_SQL_EXTENDED_FETCH_ON #if defined(OTL_ODBC_UNIX) && !defined(OTL_ODBC) #define OTL_ODBC #endif #if defined(OTL_BIND_VAR_STRICT_TYPE_CHECKING_ON) #define OTL_CHECK_BIND_VARS \ if(strcmp(type_arr,"INT")==0|| \ strcmp(type_arr,"UNSIGNED")==0|| \ strcmp(type_arr,"SHORT")==0|| \ strcmp(type_arr,"LONG")==0|| \ strcmp(type_arr,"FLOAT")==0|| \ strcmp(type_arr,"DOUBLE")==0|| \ strcmp(type_arr,"TIMESTAMP")==0|| \ strcmp(type_arr,"TZ_TIMESTAMP")==0|| \ strcmp(type_arr,"LTZ_TIMESTAMP")==0|| \ strcmp(type_arr,"BIGINT")==0|| \ strcmp(type_arr,"CHAR")==0|| \ strcmp(type_arr,"CHARZ")==0|| \ strcmp(type_arr,"DB2DATE")==0|| \ strcmp(type_arr,"DB2TIME")==0|| \ strcmp(type_arr,"VARCHAR_LONG")==0|| \ strcmp(type_arr,"RAW_LONG")==0|| \ strcmp(type_arr,"RAW")==0|| \ strcmp(type_arr,"CLOB")==0|| \ strcmp(type_arr,"BLOB")==0|| \ strcmp(type_arr,"NCHAR")==0|| \ strcmp(type_arr,"NCLOB")==0|| \ strcmp(type_arr,"REFCUR")==0) \ ; \ else \ return 0; #else #define OTL_CHECK_BIND_VARS #endif // ------------------- Namespace generation ------------------------ #if defined(OTL_EXPLICIT_NAMESPACES) #if defined(OTL_DB2_CLI) #define OTL_ODBC_NAMESPACE_BEGIN namespace db2 { #define OTL_ODBC_NAMESPACE_PREFIX db2:: #define OTL_ODBC_NAMESPACE_END } #else #define OTL_ODBC_NAMESPACE_BEGIN namespace odbc { #define OTL_ODBC_NAMESPACE_PREFIX odbc:: #define OTL_ODBC_NAMESPACE_END } #endif #define OTL_ORA7_NAMESPACE_BEGIN namespace oracle { #define OTL_ORA7_NAMESPACE_PREFIX oracle:: #define OTL_ORA7_NAMESPACE_END } #define OTL_ORA8_NAMESPACE_BEGIN namespace oracle { #define OTL_ORA8_NAMESPACE_PREFIX oracle:: #define OTL_ORA8_NAMESPACE_END } #else // Only one OTL is being intantiated #if defined(OTL_ODBC)&&!defined(OTL_ORA8)&& \ !defined(OTL_ORA7)&&!defined(OTL_DB2_CLI) \ || !defined(OTL_ODBC)&&defined(OTL_ORA8)&& \ !defined(OTL_ORA7)&&!defined(OTL_DB2_CLI) \ || !defined(OTL_ODBC)&&!defined(OTL_ORA8)&& \ defined(OTL_ORA7)&&!defined(OTL_DB2_CLI) \ || !defined(OTL_ODBC)&&!defined(OTL_ORA8)&& \ !defined(OTL_ORA7)&&defined(OTL_DB2_CLI) #define OTL_ODBC_NAMESPACE_BEGIN #define OTL_ODBC_NAMESPACE_PREFIX #define OTL_ODBC_NAMESPACE_END #define OTL_ORA7_NAMESPACE_BEGIN #define OTL_ORA7_NAMESPACE_PREFIX #define OTL_ORA7_NAMESPACE_END #define OTL_ORA8_NAMESPACE_BEGIN #define OTL_ORA8_NAMESPACE_PREFIX #define OTL_ORA8_NAMESPACE_END #endif // ================ Combinations of two OTLs ========================= #if defined(OTL_ODBC) && defined(OTL_ORA7) && \ !defined(OTL_ORA8) && !defined(OTL_DB2_CLI) #define OTL_ODBC_NAMESPACE_BEGIN namespace odbc{ #define OTL_ODBC_NAMESPACE_PREFIX odbc:: #define OTL_ODBC_NAMESPACE_END } #define OTL_ORA7_NAMESPACE_BEGIN namespace oracle { #define OTL_ORA7_NAMESPACE_PREFIX oracle:: #define OTL_ORA7_NAMESPACE_END } #define OTL_ORA8_NAMESPACE_BEGIN #define OTL_ORA8_NAMESPACE_PREFIX #define OTL_ORA8_NAMESPACE_END #endif #if defined(OTL_ODBC) && !defined(OTL_ORA7) && \ defined(OTL_ORA8) && !defined(OTL_DB2_CLI) #define OTL_ODBC_NAMESPACE_BEGIN namespace odbc{ #define OTL_ODBC_NAMESPACE_PREFIX odbc:: #define OTL_ODBC_NAMESPACE_END } #define OTL_ORA8_NAMESPACE_BEGIN namespace oracle { #define OTL_ORA8_NAMESPACE_PREFIX oracle:: #define OTL_ORA8_NAMESPACE_END } #define OTL_ORA7_NAMESPACE_BEGIN #define OTL_ORA7_NAMESPACE_PREFIX #define OTL_ORA7_NAMESPACE_END #endif #if !defined(OTL_ODBC) && defined(OTL_ORA7) && \ !defined(OTL_ORA8) && defined(OTL_DB2_CLI) #define OTL_ORA7_NAMESPACE_BEGIN namespace oracle { #define OTL_ORA7_NAMESPACE_PREFIX oracle:: #define OTL_ORA7_NAMESPACE_END } #define OTL_ORA8_NAMESPACE_BEGIN #define OTL_ORA8_NAMESPACE_PREFIX #define OTL_ORA8_NAMESPACE_END #define OTL_ODBC_NAMESPACE_BEGIN namespace db2 { #define OTL_ODBC_NAMESPACE_PREFIX db2:: #define OTL_ODBC_NAMESPACE_END } #endif #if !defined(OTL_ODBC) && !defined(OTL_ORA7) && \ defined(OTL_ORA8) && defined(OTL_DB2_CLI) #define OTL_ORA8_NAMESPACE_BEGIN namespace oracle { #define OTL_ORA8_NAMESPACE_PREFIX oracle:: #define OTL_ORA8_NAMESPACE_END } #define OTL_ORA7_NAMESPACE_BEGIN #define OTL_ORA7_NAMESPACE_PREFIX #define OTL_ORA7_NAMESPACE_END #define OTL_ODBC_NAMESPACE_BEGIN namespace db2 { #define OTL_ODBC_NAMESPACE_PREFIX db2:: #define OTL_ODBC_NAMESPACE_END } #endif #endif // -------------------- End of namespace generation ------------------- // --------------------- Invalid combinations -------------------------- #if (defined(OTL_ORA7_TIMESTAMP_TO_STRING)||defined(OTL_ORA7_STRING_TO_TIMESTAMP)) \ && defined(OTL_ORA_TIMESTAMP) #error Invalid combination: OTL_ORA_TIMESTAMP and \ OTL_ORA7_TIMESTAMP_TO_STRING/OTL_ORA7_STRING_TO_TIMESTAMP #endif #if defined(OTL_ORA_MAP_BIGINT_TO_LONG) && \ defined(OTL_BIGINT_TO_STR) && \ defined(OTL_STR_TO_BIGINT) #error OTL_ORA_MAP_BIGINT_TO_LONG cannot be used when \ OTL_BIGINT_TO_STR and OTL_STR_TO_BIGINT are defined #endif #if defined(OTL_STL) && defined(OTL_UNICODE_STRING_TYPE) #error Invalid combination: OTL_STL and OTL_UNICODE_STRING_TYPE #endif #if defined(OTL_ORA_UTF8) && !defined(OTL_ORA10G) && \ !defined(OTL_ORA_10G_R2) && !defined(OTL_ORA9I) #error Invalid combination: OTL_ORA_UTF8 can only be used with OTL_ORA9I or higher #endif #if defined(OTL_ORA_UTF8) && defined(OTL_UNICODE) #error Invalid combination: OTL_ORA_UTF8 and OTL_UNICODE are mutually exclusive #endif #if defined(OTL_ODBC) && defined(OTL_DB2_CLI) #error Invalid combination: OTL_ODBC && OTL_DB2_CLI together #endif #if defined(OTL_ORA7) && defined(OTL_ORA8) #error Invalid combination: OTL_ORA7 && OTL_ORA8(I) together #endif #if (defined(OTL_ORA7) || defined(OTL_ORA8) || \ defined(OTL_ORA8I) || defined(OTL_ORA9I) ) && \ defined(OTL_BIGINT) && \ (defined(OTL_ODBC) || defined(OTL_DB2_CLI)) #error OTL_BIGINT is not supported when OTL_ORAXX and OTL_ODBC \ (or OTL_DB2_CLI) are defined together #endif #if defined (OTL_ORA7) && defined(OTL_ORA8) #error Invalid combination: OTL_ORA7 && OTL_ORA8(I) together #endif #if defined(OTL_ORA_OCI_ENV_CREATE) && \ (!defined(OTL_ORA8I) && !defined(OTL_ORA9I) && \ !defined(OTL_ORA10G) && !defined(OTL_ORA10G_R2)) #error OTL_ORA_OCI_ENV_CREATE can be only defined when OTL_ORA8I, OTL_ORA9I, OTL_ORA10G, OTL_ORA10G_R2, or OTL_ORA11G is defined #endif // -------------------------------------------------------------------- #if defined(OTL_TRACE_LEVEL) #if !defined(OTL_TRACE_LINE_PREFIX) #define OTL_TRACE_LINE_PREFIX "OTL TRACE ==> " #endif #if defined(OTL_UNICODE_CHAR_TYPE) && !defined(OTL_UNICODE) #error OTL_UNICODE needs to be defined if OTL_UNICODE_CHAR_TYPE is defined #endif #if defined(OTL_UNICODE_STRING_TYPE) && !defined(OTL_UNICODE_CHAR_TYPE) #error OTL_UNICODE_CHAR_TYPE needs to be defined if OTL_UNICODE_STRING_TYPE is defined #endif #if defined(OTL_UNICODE_STRING_TYPE) && !defined(OTL_UNICODE_CHAR_TYPE) #error OTL_UNICODE_CHAR_TYPE needs to be defined if OTL_UNICODE_STRING_TYPE is defined #endif #if defined(OTL_UNICODE_STRING_TYPE) && !defined(OTL_UNICODE) #error OTL_UNICODE needs to be defined if OTL_UNICODE_STRING_TYPE is defined #endif #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) && !defined(OTL_UNICODE_CHAR_TYPE) #error OTL_UNICODE_CHAR_TYPE needs to be defined if OTL_UNICODE_EXCEPTION_AND_RLOGON is defined #endif #if !defined(OTL_TRACE_LINE_SUFFIX) #if defined(OTL_UNICODE) #define OTL_TRACE_LINE_SUFFIX L"\n" #else #define OTL_TRACE_LINE_SUFFIX "\n" #endif #endif #if !defined(OTL_TRACE_STREAM_OPEN) #define OTL_TRACE_STREAM_OPEN \ if(OTL_TRACE_LEVEL & 0x4){ \ OTL_TRACE_STREAM<0){ \ OTL_STRCAT_S(temp_connect_str,sizeof(temp_connect_str),"@"); \ OTL_STRCAT_S(temp_connect_str,sizeof(temp_connect_str),tnsname); \ } \ OTL_TRACE_STREAM<0){ \ OTL_STRCAT_S(temp_connect_str2,sizeof(temp_connect_str2),"@"); \ OTL_STRCAT_S(temp_connect_str2,sizeof(temp_connect_str2),tnsname); \ } \ OTL_TRACE_STREAM<(_e) #define OTL_RCAST(_t,_e) reinterpret_cast<_t >(_e) #define OTL_DCAST(_t,_e) dynamic_cast<_t >(_e) #define OTL_CCAST(_t,_e) const_cast<_t >(_e) #define OTL_CONST_EXCEPTION const #if defined(OTL_FUNC_THROW_SPEC_ON) #define OTL_THROWS_OTL_EXCEPTION throw(otl_exception) #define OTL_NO_THROW throw() #else #define OTL_THROWS_OTL_EXCEPTION #define OTL_NO_THROW #endif #define OTL_TYPE_NAME typename #include #else #define OTL_SCAST(_t,_e) ((_t)(_e)) #define OTL_RCAST(_t,_e) ((_t)(_e)) #define OTL_DCAST(_t,_e) ((_t)(_e)) #define OTL_CCAST(_t,_e) ((_t)(_e)) #define OTL_CONST_EXCEPTION #define OTL_THROWS_OTL_EXCEPTION #define OTL_NO_THROW #define OTL_TYPE_NAME class #endif #define OTL_PCONV(_to,_from,_val) \ OTL_SCAST(_to,*OTL_RCAST(_from*,OTL_CCAST(void*,_val))) #if defined(OTL_ACE) #include #include #include #include #include #define OTL_USER_DEFINED_STRING_CLASS_ON #define USER_DEFINED_STRING_CLASS ACE_TString #define OTL_VALUE_TEMPLATE_ON const int otl_tmpl_vector_default_size=16; template class otl_tmpl_vector: public ACE_Array{ public: otl_tmpl_vector(const int init_size=otl_tmpl_vector_default_size) : ACE_Array(init_size==0?otl_tmpl_vector_default_size:init_size) { length_=0; } ~otl_tmpl_vector(){} int capacity(void) const { return this->max_size(); } int size(void) const { return length_; } void clear(void) { length_=0; } void resize(const int new_size, const T& t=T()) { ACE_Array::size(new_size); if(new_size>length_){ for(int i=length_;imax_size()); if(length_==curr_max_size) ACE_Array::size(curr_max_size*2); ++length_; (*this)[length_-1]=elem; } void pop_back(void) { if(length_>0) --length_; } private: int length_; }; #endif #if defined(OTL_UNCAUGHT_EXCEPTION_ON) #include #if !defined(OTL_STLPORT) inline bool otl_uncaught_exception() { return std::uncaught_exception(); } #else inline bool otl_uncaught_exception() { return __std_alias::uncaught_exception(); } #endif #else inline bool otl_uncaught_exception() { return false; } #endif #if defined(OTL_STLPORT) #if defined(__STLPORT_STD) #define OTL_STLPORT_NAMESPACE __STLPORT_STD #else #if defined(_STLP_USE_OWN_NAMESPACE) #define OTL_STLPORT_NAMESPACE _STL #else #define OTL_STLPORT_NAMESPACE std #endif #endif #define OTL_STL #endif #if defined(OTL_VALUE_TEMPLATE_ON) && !defined(OTL_STL) && !defined(OTL_ACE) #define STD_NAMESPACE_PREFIX #if (defined(_MSC_VER)&&(_MSC_VER>=1300))||defined(OTL_ANSI_CPP) #include using namespace std; #else #include #endif #endif #if defined(OTL_USER_DEFINED_STRING_CLASS_ON) #if defined(OTL_STL) #error OTL_STL cannot be used in combination with OTL_USER_DEFINED_STRING_CLASS_ON #endif #if defined(USER_DEFINED_STRING_CLASS) #define OTL_STRING_CONTAINER USER_DEFINED_STRING_CLASS #define STD_NAMESPACE_PREFIX #else #error USER_DEFINED_STRING_CLASS macro needs to be defined before including otlv4.h #endif #endif #if defined(OTL_STL) #if defined(_MSC_VER) #if (_MSC_VER >= 1200) #pragma warning (disable:4786) #pragma warning (disable:4290) #pragma warning (disable:4996) #endif #endif #if defined(OTL_STL_NOSTD_NAMESPACE) #ifndef OTL_STRING_CONTAINER #define OTL_STRING_CONTAINER string #endif #define STD_NAMESPACE_PREFIX #else #ifndef OTL_STRING_CONTAINER #if defined(OTL_STLPORT) #define OTL_STRING_CONTAINER OTL_STLPORT_NAMESPACE ::string #else #define OTL_STRING_CONTAINER std::string #endif #endif #if defined(OTL_STLPORT) #define STD_NAMESPACE_PREFIX OTL_STLPORT_NAMESPACE :: #else #define STD_NAMESPACE_PREFIX std:: #endif #endif #include #include #include #ifndef OTL_STL_NOSTD_NAMESPACE #include #else #if defined(_MSC_VER) && (_MSC_VER >= 1300) #include using namespace std; #else #include #endif #endif #endif //======================= END OF CONFIGURATION ============================== // ====== COMMON NON-TEMPLATE OBJECTS: CONSTANTS, CLASSES, ETC. =========== #if defined(OTL_ORA8) const int otl_var_list_size=1024; #else const int otl_var_list_size=512; #endif const int otl_error_code_0=32000; #define otl_error_msg_0 "Incompatible data types in stream operation" const int otl_error_code_1=32004; #define otl_error_msg_1 "No input variables have been defined in SQL statement" const int otl_error_code_2=32003; #define otl_error_msg_2 "Not all input variables have been initialized" const int otl_error_code_3=32001; #define otl_error_msg_3 "Row must be full for flushing output stream" const int otl_error_code_4=32005; #define otl_error_msg_4 "Input string value is too large to fit into the buffer" const int otl_error_code_5=32006; #define otl_error_msg_5 "Input otl_long_string is too large to fit into the buffer" const int otl_error_code_6=32007; #define otl_error_msg_6 "PL/SQL table size is too large (>32767)" const int otl_error_code_7=32008; #define otl_error_msg_7 "Writing CLOB/BLOB in stream mode: actual size is greater than specified" const int otl_error_code_8=32009; #define otl_error_msg_8 "Closing CLOB/BLOB in stream mode: actual size is not equal to specified size" const int otl_error_code_9=32010; #define otl_error_msg_9 "CLOB/BLOB stream is not open for writing" const int otl_error_code_10=32011; #define otl_error_msg_10 "CLOB/BLOB stream is not open for reading" const int otl_error_code_11=32012; #define otl_error_msg_11 "First session must be started with session_begin()" const int otl_error_code_12=32013; #define otl_error_msg_12 "Invalid bind variable declaration" const int otl_error_code_13=32014; #define otl_error_msg_13 "No stored procedure was found" const int otl_error_code_14=32015; #define otl_error_msg_14 "Unsupported data type: " const int otl_error_code_15=32016; #define otl_error_msg_15 "Unsupported procedure type" const int otl_error_code_16=32017; #define otl_error_msg_16 "Stream buffer size can't be > 1 in this case" const int otl_error_code_17=32018; #define otl_error_msg_17 \ "ODBC / DB2 CLI function name is not recognized. " \ "It should be one of the following: SQLTables, SQLColumns, " \ "SQLProcedures, SQLColumnPrivileges, SQLTablePrivileges, " \ "SQLPrimaryKeys, SQLProcedureColumns, SQLForeignKeys" const int otl_error_code_18=32019; #define otl_error_msg_18 \ "otl_stream::operator>>() should have been called " \ "before otl_stream::operator int()" const int otl_error_code_19=32020; #define otl_error_msg_19 \ "otl_stream_read_iterator: otl_stream is not open" const int otl_error_code_20=32021; #define otl_error_msg_20 \ "otl_stream_read_iterator: PL/SQL table and 'refcur' " \ "parameters are not supported" const int otl_error_code_21=32022; #define otl_error_msg_21 \ "otl_stream_read_iterator: otl_stream cannot be described" const int otl_error_code_22=32023; #define otl_error_msg_22 \ "otl_stream_read_iterator: position is out of range" const int otl_error_code_23=32024; #define otl_error_msg_23 \ "otl_stream_read_iterator: incompatible types in get()" const int otl_error_code_24=32025; #define otl_error_msg_24 \ "otl_stream::operator int() is not supported in the LOB stream mode" const int otl_error_code_25=32026; #define otl_error_msg_25 \ "otl_stream_read_iterator: get(otl_lob_stream*&) function " \ "can only be used if otl_stream::set_lob_stream_mode(true) had been called " \ "before the iterator was attached to the stream" const int otl_error_code_26=32027; #define otl_error_msg_26 \ "otl_stream_read_iterator: variable name is not recognized " const int otl_error_code_27=32028; #define otl_error_msg_27 "Unsupported column data type" const int otl_error_code_28=32029; #define otl_error_msg_28 \ "RAW value cannot be read with otl_lob_stream, use otl_long_string instead" const int otl_error_code_29=32030; #define otl_error_msg_29 \ "otl_stream is already open" const int otl_error_code_30=32031; #define otl_error_msg_30 \ "otl_connect is already connected" const int otl_error_code_31=32032; #define otl_error_msg_31 \ "SELECT otl_stream buffer size for TimesTen should be in [0..128] range" const int otl_error_code_32=32033; #define otl_error_msg_32 \ "otl_connect object needs to be connected to DB before using otl_subscriber" const int otl_error_code_33=32034; #define otl_error_msg_33 \ "otl_stream buffer size should be 1 when refcur or plsql table is used" const int otl_error_code_34=32035; #define otl_error_msg_34 "END-OF-ROW check failed" const int otl_oracle_date_size=7; const int otl_explicit_select=0; const int otl_implicit_select=1; const int otl_input_param=0; const int otl_output_param=1; const int otl_inout_param=2; const unsigned int otl_all_num2str=1; const unsigned int otl_all_date2str=2; const int otl_num_str_size=60; const int otl_date_str_size=60; class otl_select_struct_override{ public: otl_select_struct_override(): col_ndx(new short int[otl_var_list_size]), col_type(new short int[otl_var_list_size]), col_size(new int[otl_var_list_size]), len(0), all_mask(0), lob_stream_mode(false), container_size_(otl_var_list_size), master_stream_ptr_(0) { } ~otl_select_struct_override() { delete[] col_ndx; delete[] col_type; delete[] col_size; } void set_master_stream_ptr(void* stream_ptr) { master_stream_ptr_=stream_ptr; } void* get_master_stream_ptr(){return master_stream_ptr_;} void reset(void) { len=0; all_mask=0; lob_stream_mode=false; } void add_override(const int andx, const int atype, const int asize=0) { if(len==otl_var_list_size){ int temp_container_size=container_size_; container_size_*=2; short int* temp_col_ndx=new short int[container_size_]; short int* temp_col_type=new short int[container_size_]; int* temp_col_size=new int[container_size_]; memcpy(temp_col_ndx,col_ndx,sizeof(short int)*temp_container_size); memcpy(temp_col_type,col_type,sizeof(short int)*temp_container_size); memcpy(temp_col_size,col_size,sizeof(int)*temp_container_size); delete[] col_ndx; delete[] col_type; delete[] col_size; col_ndx=temp_col_ndx; col_type=temp_col_type; col_size=temp_col_size; } ++len; col_ndx[len-1]=OTL_SCAST(short,andx); col_type[len-1]=OTL_SCAST(short,atype); col_size[len-1]=asize; } int find(const int ndx) const { int i; for(i=0;ifrac_prec){ // in case if the actual fraction value is beyond the "fraction // precision" range, truncate the value int excess_decimal_digits=fraction_degree-frac_prec; for(int iter=1;iter<=excess_decimal_digits;++iter) fraction/=10; } int degree_diff=9-frac_prec; for(int i=0;i=desc.name_len_) OTL_STRCPY_S(name,name_len_,desc.name); else if(name==0 && desc.name!=0){ name=new char[desc.name_len_]; name_len_=desc.name_len_; OTL_STRCPY_S(name,name_len_,desc.name); }else if(name_len_= 1400) OTL_STRNCPY_S(name,sizeof(name),nm,sizeof(name)-1); name[sizeof(name)-1]=0; #else strncpy(name,nm,sizeof(name)); name[sizeof(name)-1]=0; #endif #else strncpy(name,nm,sizeof(name)); name[sizeof(name)-1]=0; #endif } } }; const int otl_var_none=0; const int otl_var_char=1; const int otl_var_double=2; const int otl_var_float=3; const int otl_var_int=4; const int otl_var_unsigned_int=5; const int otl_var_short=6; const int otl_var_long_int=7; const int otl_var_timestamp=8; const int otl_var_varchar_long=9; const int otl_var_raw_long=10; const int otl_var_clob=11; const int otl_var_blob=12; const int otl_var_refcur=13; const int otl_var_long_string=15; const int otl_var_db2time=16; const int otl_var_db2date=17; const int otl_var_tz_timestamp=18; const int otl_var_ltz_timestamp=19; const int otl_var_bigint=20; #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) const int otl_var_nchar=21; const int otl_var_nclob=22; #else #endif const int otl_var_raw=23; const int otl_var_lob_stream=100; const int otl_bigint_str_size=40; const int otl_sql_exec_from_cursor_class=0; const int otl_sql_exec_from_select_cursor_class=1; class otl_long_string{ public: unsigned char* v; otl_long_string(const int buffer_size=32760,const int input_length=0): v(0), length(0), extern_buffer_flag(0), buf_size(0), this_is_last_piece_(false) { this_is_last_piece_=false; if(buffer_size==0){ v=0; length=0; extern_buffer_flag=0; }else{ extern_buffer_flag=0; length=input_length; buf_size=buffer_size; v=new unsigned char[buffer_size+1]; memset(v,0,buffer_size); } } otl_long_string (const void* external_buffer, const int buffer_size, const int input_length=0): v(OTL_RCAST(unsigned char*, OTL_CCAST(void*, external_buffer))), length(input_length), extern_buffer_flag(1), buf_size(buffer_size), this_is_last_piece_(false) { } otl_long_string& operator=(const otl_long_string& s) { this_is_last_piece_=s.this_is_last_piece_; if(s.extern_buffer_flag){ if(!extern_buffer_flag) delete[] v; v=s.v; length=s.length; extern_buffer_flag=s.extern_buffer_flag; buf_size=s.buf_size; }else{ if(extern_buffer_flag){ v=new unsigned char[s.buf_size+1]; buf_size=s.buf_size; }else if(buf_sizebuf_size=s.buf_size; this->this_is_last_piece_=s.this_is_last_piece_; this->extern_buffer_flag=s.extern_buffer_flag; this->v=0; this->length=s.length; if(s.extern_buffer_flag) v=s.v; else{ v=new unsigned char[(buf_size+1)*sizeof(OTL_WCHAR)]; memcpy(v,s.v,length*sizeof(OTL_WCHAR)); if(length= 1400) // VC++ 8.0 or higher const size_t var_info_sz #else const size_t /*var_info_sz*/ #endif #else const size_t /*var_info_sz*/ #endif ) {char buf1[128]; char buf2[128]; OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code)); OTL_STRCPY_S(var_info,var_info_sz,"Variable: "); OTL_STRCAT_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz,"<"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info,var_info_sz,">, datatype in operator <>: "); OTL_STRCAT_S(var_info,var_info_sz,buf2); } inline void otl_var_info_var2 (const char* name, const int ftype, char* var_info, #if defined(_MSC_VER) #if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t var_info_sz #else const size_t /*var_info_sz*/ #endif #else const size_t /*var_info_sz*/ #endif ) {char buf1[128]; OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(var_info,var_info_sz,"Variable: "); OTL_STRCPY_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz,"<"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info,var_info_sz,">"); } inline void otl_var_info_var3 (const char* name, const int ftype, const int type_code, char* var_info, #if defined(_MSC_VER) #if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t var_info_sz #else const size_t /*var_info_sz*/ #endif #else const size_t /*var_info_sz*/ #endif ) {char buf1[128]; char buf2[128]; OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code)); OTL_STRCPY_S(var_info,var_info_sz,"Variable: "); OTL_STRCAT_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz,"<"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info, var_info_sz, ">, datatype in otl_stream_read_iterator::get(): "); OTL_STRCAT_S(var_info,var_info_sz,buf2); } inline void otl_var_info_var4 (const char* name, const int ftype, const int type_code, char* var_info, #if defined(_MSC_VER) #if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t var_info_sz #else const size_t /*var_info_sz*/ #endif #else const size_t /*var_info_sz*/ #endif ) {char buf1[128]; char buf2[128]; OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code)); OTL_STRCPY_S(var_info,var_info_sz,"Variable: "); OTL_STRCAT_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz,"<"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info, var_info_sz, ">, datatype in otl_stream_read_iterator::get(): "); OTL_STRCAT_S(var_info,var_info_sz,buf2); } inline void otl_strcpy( unsigned char* trg, unsigned char* src, int& overflow, const int inp_size=0, const int actual_inp_size=-1 ) { OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg); const OTL_CHAR* c2=OTL_RCAST(const OTL_CHAR*,src); int out_size=0; overflow=0; if(actual_inp_size!=-1){ while(out_size= 1400)) inline void otl_strcpy (unsigned char* trg, const unsigned char* src) { OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg); const OTL_CHAR* c2=OTL_RCAST(const OTL_CHAR*,src); while(*c2){ *c1++=*c2++; } *c1=0; } #else inline void otl_strcpy(unsigned char* trg,const unsigned char* src) { strcpy(OTL_RCAST(char*,trg),OTL_RCAST(const char*,src)); } #endif inline void otl_strcat(char* trg,const char* src) { while(*trg)++trg; while(*src){ *trg=*src; ++trg; ++src; } *trg=0; } #if defined(OTL_UNICODE) && !defined(OTL_ODBC) inline void otl_strcpy2( unsigned char* trg, const unsigned char* src, const int max_src_len ) { OTL_CHAR* c1=OTL_RCAST(OTL_CHAR*,trg); const OTL_CHAR* c2=OTL_RCAST(const OTL_CHAR*,src); int src_len=OTL_SCAST(int,*OTL_SCAST(const unsigned short*,c2)); int len=0; ++c2; while(*c2&&len=10) k=n%10; else k=n; digit=digits[k]; *c=digit; ++c; ++klen; n=n/10; }while(n!=0); *c=0; if(negative){ *c1='-'; ++c1; } for(int j=klen-1;j>=0;--j){ *c1=buf[j]; ++c1; } *c1=0; return c1; } inline void otl_var_info_col (const int pos, const int ftype, const int type_code, char* var_info, #if defined(_MSC_VER) #if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t var_info_sz #else const size_t /*var_info_sz*/ #endif #else const size_t /*var_info_sz*/ #endif ) { char buf1[128]; char buf2[128]; char name[128]; otl_itoa(pos,name); OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(buf2,sizeof(buf2),otl_var_type_name(type_code)); OTL_STRCPY_S(var_info,var_info_sz,"Column: "); OTL_STRCAT_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz,"<"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info, var_info_sz, ">, datatype in operator <>: "); OTL_STRCAT_S(var_info,var_info_sz,buf2); } inline void otl_var_info_col2 (const int pos, const int ftype, char* var_info, #if defined(_MSC_VER) #if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t var_info_sz #else const size_t /*var_info_sz*/ #endif #else const size_t /*var_info_sz*/ #endif ) { char buf1[128]; char name[128]; otl_itoa(pos,name); OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(var_info,var_info_sz,"Column: "); OTL_STRCAT_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz,"<"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info,var_info_sz,">"); } inline void otl_var_info_col3 (const int pos, const int ftype, const char* col_name, char* var_info, #if defined(_MSC_VER) #if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t var_info_sz #else const size_t /*var_info_sz*/ #endif #else const size_t /*var_info_sz*/ #endif ) { char buf1[128]; char name[128]; otl_itoa(pos,name); OTL_STRCPY_S(buf1,sizeof(buf1),otl_var_type_name(ftype)); OTL_STRCPY_S(var_info,var_info_sz,"Column: "); OTL_STRCAT_S(var_info,var_info_sz,name); OTL_STRCAT_S(var_info,var_info_sz," / "); OTL_STRCAT_S(var_info,var_info_sz,col_name); OTL_STRCAT_S(var_info,var_info_sz," <"); OTL_STRCAT_S(var_info,var_info_sz,buf1); OTL_STRCAT_S(var_info,var_info_sz,">"); } class otl_pl_tab_generic{ public: otl_pl_tab_generic(): p_v(0), p_null(0), elem_size(0), tab_size(0), tab_len(0), vtype(0) { } virtual ~otl_pl_tab_generic(){} unsigned char* val(int ndx=0) { return p_v+(ndx*elem_size); } int is_null(int ndx=0) { return p_null[ndx]!=0; } void set_null(int ndx=0) { p_null[ndx]=1; } void set_non_null(int ndx=0) { p_null[ndx]=0; } void init_generic(void) {int i; memset(p_v,0,elem_size*tab_len); for(i=0;i inline int otl_numeric_convert_T (const int ftype,const void* val,T& n) { if(ftype==T_type){ n=*OTL_RCAST(T*,OTL_CCAST(void*,val)); return 1; }else return 0; } template inline int otl_numeric_convert_T2(const int ftype,const void* val,T& n) { int rc=1; switch(ftype){ case otl_var_double: n=OTL_PCONV(T,double,val); break; case otl_var_short: n=OTL_PCONV(T,short,val); break; case otl_var_int: n=OTL_PCONV(T,int,val); break; case otl_var_unsigned_int: n=OTL_PCONV(T,unsigned int,val); break; case otl_var_long_int: n=OTL_PCONV(T,long int,val); break; case otl_var_float: n=OTL_PCONV(T,float,val); break; #if defined(OTL_BIGINT) case otl_var_bigint: n=OTL_PCONV(T,OTL_BIGINT,val); break; #endif default: rc=0; break; } return rc; } #else template inline int otl_numeric_convert_T(const int ftype,const void* val,T& n) { int rc=1; switch(ftype){ case otl_var_double: n=OTL_PCONV(T,double,val); break; case otl_var_short: n=OTL_PCONV(T,short,val); break; case otl_var_int: n=OTL_PCONV(T,int,val); break; case otl_var_unsigned_int: n=OTL_PCONV(T,unsigned int,val); break; case otl_var_long_int: n=OTL_PCONV(T,long int,val); break; case otl_var_float: n=OTL_PCONV(T,float,val); break; #if defined(OTL_BIGINT) case otl_var_bigint: n=OTL_PCONV(T,OTL_BIGINT,val); break; #endif default: rc=0; break; } return rc; } #endif #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) class otl_ltstr{ public: bool operator()(const OTL_STRING_CONTAINER& s1, const OTL_STRING_CONTAINER& s2) const { return strcmp(s1.c_str(), s2.c_str()) < 0; } }; const int otl_max_default_pool_size=32; #endif #if defined(OTL_ACE) const int otl_max_default_pool_size=32; #endif class otl_stream_shell_generic{ public: otl_stream_shell_generic(): should_delete(0) { } virtual ~otl_stream_shell_generic(){} int get_should_delete() const { return should_delete; } void set_should_delete(const int ashould_delete) { should_delete=ashould_delete; } protected: int should_delete; }; #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) #if defined(OTL_STL) #include #endif class otl_stream_pool; class otl_stream_pool_entry{ public: friend class otl_stream_pool; #if defined(OTL_ACE) otl_tmpl_vector s; #else STD_NAMESPACE_PREFIX vector s; #endif otl_stream_pool_entry(): s(), cnt(0) { } otl_stream_pool_entry(const otl_stream_pool_entry& sc): s(), cnt(0) { copy(sc); } otl_stream_pool_entry& operator=(const otl_stream_pool_entry& sc) { copy(sc); return *this; } virtual ~otl_stream_pool_entry(){} int get_cnt() const { return cnt; } void set_cnt(const int acnt) { cnt=acnt; } private: int cnt; void copy(const otl_stream_pool_entry& sc) { s.clear(); #if defined(OTL_ACE) for(int i=0;i, ACE_Null_Mutex> sc_type; typedef otl_tmpl_vector vec_type; typedef ACE_RB_Tree_Node ace_map_entry; #else typedef STD_NAMESPACE_PREFIX map sc_type; typedef STD_NAMESPACE_PREFIX vector vec_type; #endif protected: sc_type sc; int max_size; int size; public: otl_stream_pool(): sc(), max_size(otl_max_default_pool_size), size(0) { } void init(int amax_size=otl_max_default_pool_size) { if(size==0&&max_size==0)return; if(amax_size<2) amax_size=2; #if defined(OTL_ACE) sc_type::iterator elem0=sc.begin(); sc_type::iterator elemN=sc.end(); for(sc_type::iterator i=elem0; i!=elemN; ++i){ cache_entry_type& ce=(*i).item(); int sz=ce.s.size(); for(int j=0;jset_should_delete(1); delete ce.s[j]; ce.s[j]=0; } ce.s.clear(); ce.cnt=0; } sc.clear(); #else sc_type::iterator elem0=sc.begin(); sc_type::iterator elemN=sc.end(); for(sc_type::iterator i=elem0; i!=elemN; ++i){ cache_entry_type& ce=(*i).second; size_t sz=ce.s.size(); for(size_t j=0;jset_should_delete(1); delete ce.s[j]; ce.s[j]=0; } ce.s.clear(); ce.set_cnt(0); } sc.clear(); #endif size=0; max_size=amax_size; } otl_stream_shell_generic* find(const OTL_STRING_CONTAINER& stmtxt) { otl_stream_shell_generic* s; #if defined(OTL_ACE) ace_map_entry* ce=0; int found=sc.find(stmtxt,ce); if(found==-1)return 0; // entry not found s=ce->item().s[ce->item().s.size()-1]; ce->item().s.pop_back(); if(ce->item().s.size()==0){ sc.unbind(ce); --size; } #else sc_type::iterator cur=sc.find(stmtxt); if(cur==sc.end()) return 0; // entry not found cache_entry_type& ce=(*cur).second; s=ce.s[ce.s.size()-1]; ce.s.pop_back(); if(ce.s.size()==0){ sc.erase(cur); --size; } #endif return s; } void remove(const otl_stream_shell_generic* s,const OTL_STRING_CONTAINER& stmtxt) { #if defined(OTL_ACE) ace_map_entry* cur=0; int found=sc.find(stmtxt,cur); if(found==-1) return; cache_entry_type& ce=(*cur).item(); for(int i=0;i1 && i!=ce.s.size()-1){ otl_stream_shell_generic* temp_s=ce.s[i]; ce.s[i]=ce.s[ce.s.size()-1]; ce.s[ce.s.size()-1]=temp_s; } ce.s.pop_back(); --size; return; } #else sc_type::iterator cur=sc.find(stmtxt); if(cur==sc.end()) return; cache_entry_type& ce=(*cur).second; vec_type::iterator bgn=ce.s.begin(); vec_type::iterator end=ce.s.end(); for(vec_type::iterator i=bgn;i!=end;++i) if((*i)==s){ ce.s.erase(i); --size; return; } #endif } int get_max_size() const { return max_size; } void add(otl_stream_shell_generic* s,const char* stm_text) { OTL_STRING_CONTAINER stmtxt(stm_text); #if defined(OTL_ACE) ace_map_entry* cur=0; int found_in_map=sc.find(stmtxt,cur); if(found_in_map==0){ // entry found bool found=false; cache_entry_type& ce=(*cur).item(); int sz=ce.s.size(); for(int i=0;i(*i).item().cnt){ // found less used entry min_entry=&(*i); min_cnt=(*i).item().cnt; } } cache_entry_type& me=(*min_entry).item(); int sz=me.s.size(); for(int n=0;nset_should_delete(1); otl_stream_shell_generic* tmp=me.s[n]; delete tmp; } me.s.clear(); sc.unbind(min_entry); cache_entry_type ce; ce.cnt=1; ce.s.push_back(s); sc.bind(stmtxt,ce); } } #else sc_type::iterator cur=sc.find(stmtxt); if(cur!=sc.end()){ // entry found bool found=false; cache_entry_type& ce=(*cur).second; size_t sz=ce.s.size(); for(size_t i=0;i(*i).second.get_cnt()){ // found less used entry min_entry=i; min_cnt=(*i).second.get_cnt(); } } cache_entry_type& me=(*min_entry).second; size_t sz=me.s.size(); for(size_t n=0;nset_should_delete(1); otl_stream_shell_generic* tmp=me.s[n]; delete tmp; } me.s.clear(); sc.erase(min_entry); cache_entry_type ce; ce.set_cnt(1); ce.s.push_back(s); sc[stmtxt]=ce; } } #endif } virtual ~otl_stream_pool() { init(); } private: otl_stream_pool(const otl_stream_pool&): sc(), max_size(0), size(0) { } otl_stream_pool& operator=(const otl_stream_pool&) { return *this; } }; #endif // =========================== COMMON TEMPLATES ============================ #if (defined(OTL_STL)||defined(OTL_VALUE_TEMPLATE_ON)) && defined(OTL_VALUE_TEMPLATE) template class otl_value{ public: TData v; bool ind; otl_value(): v(), ind(true) { } virtual ~otl_value(){} otl_value(const otl_value& var): v(var.v), ind(var.ind) { } otl_value(const TData& var): v(var), ind(false) { } otl_value(const otl_null&): v(), ind(true) { } otl_value& operator=(const otl_value& var) { v=var.v; ind=var.ind; return *this; } otl_value& operator=(const TData& var) { v=var; ind=false; return *this; } otl_value& operator=(const otl_null&) { ind=true; return *this; } bool is_null(void)const {return ind;} void set_null(void){ind=true;} void set_non_null(void){ind=false;} }; template STD_NAMESPACE_PREFIX ostream& operator<< (STD_NAMESPACE_PREFIX ostream& s, const otl_value& var) { if(var.ind) s<<"NULL"; else s<& var) { if(var.ind) s<<"NULL"; else{ #if !defined(OTL_TRACE_LEVEL) s< class otl_auto_array_ptr{ public: otl_auto_array_ptr(): ptr(0), arr_size_(0) { } otl_auto_array_ptr(const int arr_size): ptr(new T[arr_size]), arr_size_(arr_size) { } void double_size(void) { int old_arr_size=arr_size_; arr_size_*=2; T* temp_ptr=new T[arr_size_]; for(int i=0;i&): ptr(0), arr_size_(0) { } otl_auto_array_ptr& operator=(const otl_auto_array_ptr&) { return *this; } }; template class otl_ptr{ public: otl_ptr(): ptr(0), arr_flag(0) { } void assign(T** var) { ptr=var; arr_flag=0; } void assign_array(T** var) { ptr=var; arr_flag=1; } void disconnect(void) { if(ptr!=0) *ptr=0; ptr=0; } void destroy(void) { if(ptr==0)return; if(*ptr!=0){ if(arr_flag) delete[] *ptr; else delete *ptr; *ptr=0; } } ~otl_ptr() { destroy(); } protected: T** ptr; int arr_flag; private: otl_ptr(const otl_ptr&): ptr(0), arr_flag(0) { } otl_ptr& operator=(const otl_ptr&) { return *this; } }; template class otl_Tptr{ public: otl_Tptr(): ptr(0), do_not_destroy(false) { } void assign(T* var) { ptr=var; } void disconnect(void) { ptr=0; } void destroy(void) { if(do_not_destroy) return; delete ptr; ptr=0; } ~otl_Tptr() { destroy(); } otl_Tptr& operator=(const otl_Tptr& src) { ptr=src.ptr; do_not_destroy=src.do_not_destroy; return *this; } void set_do_not_destroy(const bool ado_not_destroy) { do_not_destroy=ado_not_destroy; } T* get_ptr() { return ptr; } protected: T* ptr; bool do_not_destroy; private: otl_Tptr(const otl_Tptr&): ptr(0), do_not_destroy(false) { } }; template class otl_tmpl_nocommit_stream: public OTLStream{ public: otl_tmpl_nocommit_stream() OTL_NO_THROW : OTLStream() { OTLStream::set_commit(0); } otl_tmpl_nocommit_stream (const otl_stream_buffer_size_type arr_size, const char* sqlstm, OTLConnect& pdb, const char* ref_cur_placeholder=0) OTL_THROWS_OTL_EXCEPTION : OTLStream(arr_size,sqlstm,pdb,ref_cur_placeholder) { OTLStream::set_commit(0); } void open (otl_stream_buffer_size_type arr_size, const char* sqlstm, OTLConnect& db, const char* ref_cur_placeholder=0) OTL_THROWS_OTL_EXCEPTION { OTLStream::open(arr_size,sqlstm,db,ref_cur_placeholder); OTLStream::set_commit(0); } }; #if defined(OTL_STL) class otl_pl_vec_generic{ public: typedef STD_NAMESPACE_PREFIX vector null_flag_type; otl_pl_vec_generic(): p_v(0), null_flag(), vtype(0), elem_size(0) { } virtual int len(void) const { return 0; } virtual void set_len(const int /*new_len*/=0, const bool /*set_all_to_null*/=true) { } bool is_null(const int ndx=0) const { return null_flag[ndx]; } void set_null(const int ndx=0) { null_flag[ndx]=true; } void set_non_null(const int ndx=0) { null_flag[ndx]=false; } virtual ~otl_pl_vec_generic(){} int get_vtype() const { return vtype; } int get_elem_size() const { return elem_size; } void* get_p_v() { return p_v; } protected: void* p_v; null_flag_type null_flag; int vtype; int elem_size; private: otl_pl_vec_generic(const otl_pl_vec_generic&): p_v(0), null_flag(), vtype(0), elem_size(0) { } otl_pl_vec_generic& operator=(const otl_pl_vec_generic&) { return *this; } }; template class otl_T_vec: public otl_pl_vec_generic{ public: STD_NAMESPACE_PREFIX vector v; otl_T_vec(): v() { this->p_v=OTL_RCAST(void*,&v); this->vtype=type_code; this->elem_size=T_sz; } virtual ~otl_T_vec(){} virtual void set_len (const int new_len=0, const bool set_all_to_null=true) {int i,vsize; v.resize(new_len); this->null_flag.resize(new_len); vsize=OTL_SCAST(int,v.size()); if(set_all_to_null) for(i=0;inull_flag[i]=true; } virtual int len(void) const { return OTL_SCAST(int,v.size()); } T& operator[](int ndx) { return v[ndx]; } private: otl_T_vec(const otl_T_vec&): v() { } otl_T_vec& operator=(const otl_T_vec&) { return *this; } }; typedef otl_T_vec otl_double_vec; typedef otl_T_vec otl_float_vec; typedef otl_T_vec otl_int_vec; typedef otl_T_vec otl_short_vec; typedef otl_T_vec otl_long_int_vec; typedef otl_T_vec otl_datetime_vec; typedef otl_T_vec otl_string_vec; #endif template class otl_tmpl_pl_tab: public otl_pl_tab_generic{ public: T v[atab_size]; void init(void) {int i; tab_len=0; vtype=avtype; tab_size=atab_size; p_null=null_flag; p_v=OTL_RCAST(unsigned char*,v); elem_size=sizeof(T); for(i=0;i class otl_int_tab: public otl_tmpl_pl_tab{ public: otl_int_tab():otl_tmpl_pl_tab(){} }; template class otl_double_tab: public otl_tmpl_pl_tab{ public: otl_double_tab():otl_tmpl_pl_tab(){} }; template class otl_float_tab: public otl_tmpl_pl_tab{ public: otl_float_tab():otl_tmpl_pl_tab(){} }; template class otl_unsigned_tab: public otl_tmpl_pl_tab{ public: otl_unsigned_tab():otl_tmpl_pl_tab(){} }; template class otl_short_tab: public otl_tmpl_pl_tab{ public: otl_short_tab():otl_tmpl_pl_tab(){} }; template class otl_long_int_tab: public otl_tmpl_pl_tab{ public: otl_long_int_tab():otl_tmpl_pl_tab(){} }; template class otl_cstr_tab: public otl_pl_tab_generic{ public: typedef unsigned char T[str_size]; T v[atab_size]; void init(void) {int i; tab_len=0; vtype=otl_var_char; tab_size=atab_size; p_null=null_flag; p_v=OTL_RCAST(unsigned char*,v); elem_size=sizeof(T); for(i=0;i class otl_datetime_tab: public otl_pl_tab_generic{ public: typedef otl_datetime T; T v[atab_size]; void init(void) {int i; tab_len=0; vtype=otl_var_timestamp; tab_size=atab_size; p_null=null_flag; p_v=OTL_RCAST(unsigned char*,v); elem_size=sizeof(otl_oracle_date); for(i=0;i class otl_tmpl_dyn_pl_tab: public otl_pl_tab_generic{ public: T* v; void init(const int atab_size=1) {int i; tab_len=0; vtype=avtype; tab_size=atab_size; v=new T[tab_size]; null_flag=new short[tab_size]; p_null=null_flag; p_v=OTL_RCAST(unsigned char*,v); elem_size=sizeof(T); for(i=0;i&): v(0), null_flag(0) { } otl_tmpl_dyn_pl_tab& operator=(const otl_tmpl_dyn_pl_tab&) { return *this; } }; class otl_dynamic_int_tab: public otl_tmpl_dyn_pl_tab{ public: otl_dynamic_int_tab(const int atab_size=1) :otl_tmpl_dyn_pl_tab(atab_size){} }; class otl_dynamic_double_tab: public otl_tmpl_dyn_pl_tab{ public: otl_dynamic_double_tab(const int atab_size=1) :otl_tmpl_dyn_pl_tab(atab_size){} }; class otl_dynamic_float_tab: public otl_tmpl_dyn_pl_tab{ public: otl_dynamic_float_tab(const int atab_size=1) :otl_tmpl_dyn_pl_tab(atab_size){} }; class otl_dynamic_unsigned_tab: public otl_tmpl_dyn_pl_tab{ public: otl_dynamic_unsigned_tab(const int atab_size=1) :otl_tmpl_dyn_pl_tab(atab_size){} }; class otl_dynamic_short_tab: public otl_tmpl_dyn_pl_tab{ public: otl_dynamic_short_tab(const int atab_size=1) :otl_tmpl_dyn_pl_tab(atab_size){} }; class otl_dynamic_long_int_tab: public otl_tmpl_dyn_pl_tab{ public: otl_dynamic_long_int_tab(const int atab_size=1) :otl_tmpl_dyn_pl_tab(atab_size){} }; template class otl_dynamic_cstr_tab: public otl_pl_tab_generic{ public: typedef unsigned char T[str_size]; T* v; void init(const int atab_size=1) {int i; tab_len=0; vtype=otl_var_char; tab_size=atab_size; v=new T[tab_size]; null_flag=new short[tab_size]; p_null=null_flag; p_v=OTL_RCAST(unsigned char*,v); elem_size=sizeof(T); for(i=0;i #define OTL_TMPL_CONNECT \ otl_tmpl_connect \ #define OTL_TMPL_CURSOR \ otl_tmpl_cursor \ #define OTL_TMPL_OUT_STREAM \ otl_tmpl_out_stream \ #define OTL_TMPL_SELECT_CURSOR \ otl_tmpl_select_cursor \ #define OTL_TMPL_INOUT_STREAM \ otl_tmpl_inout_stream \ #define OTL_TMPL_SELECT_STREAM \ otl_tmpl_select_stream \ #if defined(OTL_EXCEPTION_IS_DERIVED_FROM_STD_EXCEPTION) #if defined(OTL_EXCEPTION_DERIVED_FROM) #error OTL_EXCEPTION_DERIVED_FROM is already defined. \ OTL_EXCEPTION_IS_DERIVED_FROM_STD_EXCEPTION cannot be used #endif #define OTL_EXCEPTION_DERIVED_FROM std::exception #define OTL_EXCEPTION_HAS_MEMBERS \ virtual const char* what() const throw() \ { \ return reinterpret_cast(this->msg); \ } #endif template #if defined(OTL_EXCEPTION_DERIVED_FROM) class otl_tmpl_exception: public OTL_EXCEPTION_DERIVED_FROM, public TExceptionStruct{ #else class otl_tmpl_exception: public TExceptionStruct{ #endif public: #if defined(OTL_EXCEPTION_HAS_MEMBERS) OTL_EXCEPTION_HAS_MEMBERS #endif #if defined(OTL_EXCEPTION_STM_TEXT_SIZE) char stm_text[OTL_EXCEPTION_STM_TEXT_SIZE]; #else char stm_text[2048]; #endif char var_info[256]; otl_tmpl_exception() #if defined(__GNUC__) && (__GNUC__>=3) throw() #else OTL_NO_THROW #endif { stm_text[0]=0; var_info[0]=0; } otl_tmpl_exception(TConnectStruct& conn_struct, const char* sqlstm=0) #if defined(__GNUC__) && (__GNUC__>=3) throw() #else OTL_NO_THROW #endif { stm_text[0]=0; var_info[0]=0; if(sqlstm){ OTL_STRNCPY_S(OTL_RCAST(char*,stm_text), sizeof(stm_text), sqlstm, sizeof(stm_text)-1); stm_text[sizeof(stm_text)-1]=0; } conn_struct.error(OTL_SCAST(TExceptionStruct&,*this)); OTL_TRACE_EXCEPTION(this->code,this->msg,this->stm_text,this->var_info) } otl_tmpl_exception(TCursorStruct& cursor_struct, const char* sqlstm=0) #if defined(__GNUC__) && (__GNUC__>=3) throw() #else OTL_NO_THROW #endif { stm_text[0]=0; var_info[0]=0; if(sqlstm){ OTL_STRNCPY_S(OTL_RCAST(char*,stm_text), sizeof(stm_text), sqlstm, sizeof(stm_text)-1); stm_text[sizeof(stm_text)-1]=0; } cursor_struct.error(OTL_SCAST(TExceptionStruct&,*this)); OTL_TRACE_EXCEPTION(this->code,this->msg,this->stm_text,this->var_info) } otl_tmpl_exception (const char* amsg, const int acode, const char* sqlstm=0, const char* varinfo=0) #if defined(__GNUC__) && (__GNUC__>=3) throw() #else OTL_NO_THROW #endif { stm_text[0]=0; var_info[0]=0; if(sqlstm){ #if defined(_MSC_VER) #if (_MSC_VER >= 1400) OTL_STRCPY_S(OTL_RCAST(char*,stm_text),sizeof(stm_text),sqlstm); #else strncpy(OTL_RCAST(char*,stm_text),sqlstm,sizeof(stm_text)); stm_text[sizeof(stm_text)-1]=0; #endif #else strncpy(OTL_RCAST(char*,stm_text),sqlstm,sizeof(stm_text)); stm_text[sizeof(stm_text)-1]=0; #endif } if(varinfo) OTL_STRCPY_S(OTL_RCAST(char*,var_info),sizeof(var_info),varinfo); TExceptionStruct::init(amsg,acode); OTL_TRACE_EXCEPTION(this->code,this->msg,this->stm_text,this->var_info) } virtual ~otl_tmpl_exception() #if defined(__GNUC__) && (__GNUC__>=3) throw() #else OTL_NO_THROW #endif { } }; template class otl_tmpl_connect{ protected: TConnectStruct connect_struct; int long_max_size; int retcode; int throw_count; public: void set_retcode(const int aretcode) { retcode=aretcode; } int get_retcode() const { return retcode; } void reset_throw_count(void) { throw_count=0; } void increment_throw_count() { throw_count++; } int get_throw_count() const { return throw_count; } TConnectStruct& get_connect_struct() { return connect_struct; } int connected; void set_max_long_size(const int amax_size) { reset_throw_count(); #if defined(OTL_UNICODE) #if defined(OTL_ORA8I)||defined(OTL_ORA9I)||defined(OTL_ORA10G)||defined(OTL_ORA10G_R2) long_max_size=amax_size*sizeof(OTL_WCHAR); #else long_max_size=amax_size; #endif #else long_max_size=amax_size; #endif } int get_max_long_size(void) { reset_throw_count(); return long_max_size; } void set_timeout(const int atimeout=0) { reset_throw_count(); connect_struct.set_timeout(atimeout); } void set_cursor_type(const int acursor_type=0) { reset_throw_count(); connect_struct.set_cursor_type(acursor_type); } otl_tmpl_connect(): connect_struct(), long_max_size(32760), retcode(1), throw_count(0), connected(0) { } otl_tmpl_connect(const char* connect_str,const int auto_commit=0): connect_struct(), long_max_size(32760), retcode(1), throw_count(0), connected(0) { rlogon(connect_str,auto_commit); } virtual ~otl_tmpl_connect() { logoff(); } static int otl_initialize(const int threaded_mode=0) { return TConnectStruct::initialize(threaded_mode); } void rlogon(const char* connect_str,const int auto_commit=0) { throw_count=0; retcode=connect_struct.rlogon(connect_str,auto_commit); if(retcode) connected=1; else{ connected=0; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; OTL_TMPL_EXCEPTION ex(connect_struct); connect_struct.cleanup(); throw ex; } } void logoff(void) { if(!connected)return; OTL_TRACE_FUNC(0x1,"otl_connect","logoff","") retcode=connect_struct.logoff(); connected=0; if(retcode)return; if(get_throw_count()>0) return; increment_throw_count(); if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(connect_struct); } void commit(void) { if(!connected)return; OTL_TRACE_FUNC(0x1,"otl_connect","commit","") reset_throw_count(); retcode=connect_struct.commit(); if(retcode)return; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(connect_struct); } void auto_commit_on(void) { if(!connected)return; OTL_TRACE_FUNC(0x1,"otl_connect","auto_commit_on","") reset_throw_count(); retcode=connect_struct.auto_commit_on(); if(retcode)return; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(connect_struct); } void auto_commit_off(void) { if(!connected)return; OTL_TRACE_FUNC(0x1,"otl_connect","auto_commit_off","") reset_throw_count(); retcode=connect_struct.auto_commit_off(); if(retcode)return; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(connect_struct); } void rollback(void) { if(!connected)return; OTL_TRACE_FUNC(0x1,"otl_connect","rollback","") reset_throw_count(); retcode=connect_struct.rollback(); if(retcode)return; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(connect_struct); } private: otl_tmpl_connect(const otl_tmpl_connect&): connected(0), connect_struct(), long_max_size(32760), retcode(1), throw_count(0) { } otl_tmpl_connect& operator=(const otl_tmpl_connect&) { return *this; } }; template class otl_tmpl_variable{ protected: int param_type; int ftype; int elem_size; int array_size; char* name; int pos; int name_pos; int bound; int pl_tab_flag; TVariableStruct var_struct; public: TVariableStruct& get_var_struct(){return var_struct;} const TVariableStruct& get_const_var_struct() const {return var_struct;} int get_bound() const {return bound;} int get_param_type() const {return param_type;} int get_ftype() const {return ftype;} int get_name_pos() const {return name_pos;} int get_elem_size() const {return elem_size;} int get_pl_tab_flag() const {return pl_tab_flag;} int get_pos() const {return pos;} int get_array_size() const {return array_size;} const char* get_name() const {return name;} void set_pos(const int apos) { this->pos=apos; } void set_bound(const int abound) { this->bound=abound; } void set_name_pos(const int aname_pos) { this->name_pos=aname_pos; } void set_ftype(const int aftype) { this->ftype=aftype; } int actual_elem_size(void) { return var_struct.actual_elem_size(); } void copy_var_desc(otl_var_desc& v) { v.param_type=param_type; v.ftype=ftype; v.elem_size=elem_size; v.array_size=array_size; v.pos=pos; v.name_pos=name_pos; if(name){ OTL_STRNCPY_S(v.name,sizeof(v.name),name,sizeof(v.name)-1); v.name[sizeof(v.name)-1]=0; }else v.name[0]=0; v.pl_tab_flag=pl_tab_flag; } otl_tmpl_variable(): param_type(0), ftype(0), elem_size(0), array_size(0), name(0), pos(0), name_pos(0), bound(0), pl_tab_flag(0), var_struct() { } virtual ~otl_tmpl_variable() { delete[] name; } otl_tmpl_variable (const int column_num, const int aftype, const int aelem_size, const short aarray_size): param_type(0), ftype(0), elem_size(0), array_size(0), name(0), pos(0), name_pos(0), bound(0), pl_tab_flag(0), var_struct() { copy_pos(column_num); init(aftype,aelem_size,aarray_size); } otl_tmpl_variable (const char* aname, const int aftype, const int aelem_size, const short aarray_size, const int apl_tab_flag=0) { copy_name(aname); init (aftype, aelem_size, aarray_size, 0, apl_tab_flag); } void init (const bool select_stm_flag, const int aftype, const int aelem_size, const otl_stream_buffer_size_type aarray_size, const void* connect_struct=0, const int apl_tab_flag=0) { ftype=aftype; #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) if(ftype==otl_var_nchar) ftype=otl_var_char; else if(ftype==otl_var_nclob) ftype=otl_var_clob; #endif elem_size=aelem_size; array_size=aarray_size; pl_tab_flag=apl_tab_flag; bound=0; var_struct.init(select_stm_flag, aftype, elem_size, aarray_size, connect_struct, pl_tab_flag); } void set_param_type(const int aparam_type=otl_input_param) { param_type=aparam_type; } int get_param_type(void) { return param_type; } void copy_name(const char* aname) { pos=0; if(name==aname)return; if(name)delete[] name; size_t len=strlen(aname)+1; name=new char[len]; OTL_STRCPY_S(name,len,aname); } void copy_pos(const int apos) { if(name){ delete[] name; name=0; name_pos=0; } pos=apos; } void set_null(int ndx) { var_struct.set_null(ndx); } void set_not_null(int ndx) { var_struct.set_not_null(ndx,elem_size); } void set_len(int len, int ndx=0) { var_struct.set_len(len,ndx); } int get_len(int ndx=0) { return var_struct.get_len(ndx); } int get_pl_tab_len(void) { return this->var_struct.get_pl_tab_len(); } int get_max_pl_tab_len(void) { return this->var_struct.get_max_pl_tab_len(); } void set_pl_tab_len(const int pl_tab_len) { this->var_struct.set_pl_tab_len(pl_tab_len); } int is_null(int ndx) { return var_struct.is_null(ndx); } void* val(int ndx=0) { return var_struct.val(ndx,elem_size); } static void map_ftype (otl_column_desc& desc, const int max_long_size, int& aftype, int& aelem_size, otl_select_struct_override& override, const int column_ndx, const int connection_type) { TVariableStruct::map_ftype (desc, max_long_size, aftype, aelem_size, override, column_ndx, connection_type); } static int int2ext(int int_type) { return TVariableStruct::int2ext(int_type); } private: otl_tmpl_variable(const otl_tmpl_variable&): param_type(0), ftype(0), elem_size(0), array_size(0), name(0), pos(0), name_pos(0), bound(0), pl_tab_flag(0), var_struct() { } otl_tmpl_variable& operator=(const otl_tmpl_variable&) { return *this; } }; template class otl_tmpl_cursor{ protected: int connected; char* stm_text; char* stm_label; TCursorStruct cursor_struct; int vl_len; otl_tmpl_variable** vl; OTL_TMPL_CONNECT* adb; int eof_data; int eof_desc; int retcode; long _rpc; int in_destructor; public: OTL_TMPL_CONNECT* get_adb(){return adb;} void set_adb(OTL_TMPL_CONNECT* aadb) { adb=aadb; } TCursorStruct& get_cursor_struct_ref(){return cursor_struct;} otl_tmpl_variable** get_vl(){return vl;} int get_vl_len() const {return vl_len;} const char* get_stm_label() const { return stm_label; } const char* get_stm_text() const { return stm_text; } void set_connected(const int aconnected) { connected=aconnected; } int& get_eof_data_ref() { return eof_data; } TCursorStruct& get_cursor_struct() { return cursor_struct; } int get_connected() const { return connected; } otl_tmpl_cursor(): connected(0), stm_text(0), stm_label(0), cursor_struct(), vl_len(0), vl(0), adb(0), eof_data(), eof_desc(), retcode(1), _rpc(0), in_destructor(0) { } otl_tmpl_cursor(OTL_TMPL_CONNECT& connect): connected(0), stm_text(0), stm_label(0), cursor_struct(), vl_len(0), vl(0), adb(&connect), eof_data(), eof_desc(), retcode(1), _rpc(0), in_destructor(0) { open(connect); } otl_tmpl_cursor (OTL_TMPL_CONNECT& connect, TVariableStruct* var): connected(0), stm_text(0), stm_label(0), cursor_struct(), vl_len(0), vl(0), adb(&connect), eof_data(), eof_desc(), retcode(1), _rpc(0), in_destructor(0) { open(connect,var); } virtual ~otl_tmpl_cursor() { in_destructor=1; close(); delete[] stm_label; stm_label=0; delete[] stm_text; stm_text=0; } void open (OTL_TMPL_CONNECT& connect, TVariableStruct* var=0) { in_destructor=0; eof_data=0; eof_desc=0; retcode=1; adb=&connect; _rpc=0; if(var==0) retcode=cursor_struct.open(connect.get_connect_struct()); else retcode=cursor_struct.open(connect.get_connect_struct(),var); if(retcode){ connected=1; return; } if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(cursor_struct); } virtual void close(void) {_rpc=0; if(!connected)return; if(!this->adb)return; if(!adb->connected){ connected=0; adb=0; retcode=1; return; } connected=0; retcode=cursor_struct.close(); if(retcode){ adb=0; return; } if(this->adb->get_throw_count()>0){ adb=0; return; } this->adb->increment_throw_count(); adb=0; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(cursor_struct); } void parse(void) {_rpc=0; if(!connected)return; retcode=cursor_struct.parse(stm_text); switch(retcode){ case 0: if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(cursor_struct,stm_label?stm_label:stm_text); case 2: if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; char var_info[1]; var_info[0]=0; throw OTL_TMPL_EXCEPTION (otl_error_msg_17, otl_error_code_17, this->stm_label?this->stm_label:this->stm_text, var_info); } } void parse(const char* sqlstm) { if(!connected)return; if(stm_text){ delete[] stm_text; stm_text=0; } size_t len=strlen(sqlstm)+1; stm_text=new char[len]; OTL_STRCPY_S(stm_text,len,sqlstm); parse(); } long get_rpc() { return _rpc; } void exec(const int iters/*=1*/, const int rowoff/*=0*/, const int otl_sql_exec_from_class/*=otl_sql_exec_from_cursor_class*/) { if(!connected)return; retcode=cursor_struct.exec(iters,rowoff,otl_sql_exec_from_class); _rpc=cursor_struct.get_rpc(); if(retcode)return; if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(cursor_struct,stm_label?stm_label:stm_text); } virtual bool valid_binding (const otl_tmpl_variable& v, const int binding_type) { bool rc=true; if(((v.get_ftype()==otl_var_varchar_long||v.get_ftype()==otl_var_raw_long) && (v.get_const_var_struct().get_otl_adapter()==otl_ora7_adapter|| v.get_const_var_struct().get_otl_adapter()==otl_ora8_adapter) && v.get_array_size()>1) || ((v.get_ftype()==otl_var_blob||v.get_ftype()==otl_var_clob)&& v.get_const_var_struct().get_otl_adapter()==otl_ora8_adapter&& v.get_array_size()>1 && binding_type==otl_inout_binding)) rc=false; return rc; } virtual void bind (const char* name, otl_tmpl_variable& v) { if(!connected)return; if(v.get_bound())return; v.copy_name(name); if(!valid_binding(v,otl_inout_binding)){ char var_info[256]; otl_var_info_var2 (v.get_name(), v.get_ftype(), var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (otl_error_msg_16, otl_error_code_16, stm_label?stm_label:stm_text, var_info); } retcode=cursor_struct.bind (name, v.get_var_struct(), v.get_elem_size(), v.get_ftype(), v.get_param_type(), v.get_name_pos(), this->adb->get_connect_struct().get_connection_type(), v.get_pl_tab_flag()); if(retcode){ v.set_bound(1); return; } if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(cursor_struct,stm_label?stm_label:stm_text); } virtual void bind (const int column_num, otl_tmpl_variable& v) { if(!connected)return; v.copy_pos(column_num); if(!valid_binding(v,otl_select_binding)){ char var_info[256]; otl_var_info_col2 (v.get_pos(), v.get_ftype(), var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (otl_error_msg_16, otl_error_code_16, stm_label?stm_label:stm_text, var_info); } retcode=cursor_struct.bind (column_num, v.get_var_struct(), v.get_elem_size(), v.get_ftype(), v.get_param_type()); if(retcode)return; if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION(cursor_struct,stm_label?stm_label:stm_text); } virtual void bind(otl_tmpl_variable& v) { if(!connected)return; if(v.get_name()) bind(v.get_name(),v); if(v.get_pos()) bind(v.get_pos(),v); } static long direct_exec (OTL_TMPL_CONNECT& connect, const char* sqlstm, const int exception_enabled=1) #if defined(OTL_ANSI_CPP) && defined(OTL_FUNC_THROW_SPEC_ON) throw(OTL_TMPL_EXCEPTION) #endif { connect.reset_throw_count(); OTL_TRACE_DIRECT_EXEC try{ OTL_TMPL_CURSOR cur(connect); cur.cursor_struct.set_direct_exec(1); cur.parse(sqlstm); cur.exec(1,0,otl_sql_exec_from_cursor_class); return cur.cursor_struct.get_rpc(); }catch(OTL_CONST_EXCEPTION OTL_TMPL_EXCEPTION&){ if(exception_enabled){ connect.increment_throw_count(); throw; } } return -1; } static void syntax_check (OTL_TMPL_CONNECT& connect, const char* sqlstm) #if defined(OTL_ANSI_CPP) && defined(OTL_FUNC_THROW_SPEC_ON) throw(OTL_TMPL_EXCEPTION) #endif { connect.reset_throw_count(); OTL_TRACE_SYNTAX_CHECK OTL_TMPL_CURSOR cur(connect); cur.cursor_struct.set_direct_exec(1); cur.cursor_struct.set_parse_only(1); cur.parse(sqlstm); } int eof(void){return eof_data;} int describe_column (otl_column_desc& col, const int column_num) { if(!connected)return 0; retcode=cursor_struct.describe_column (col,column_num,eof_desc); if(eof_desc)return 0; if(retcode)return 1; if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw OTL_TMPL_EXCEPTION(cursor_struct,stm_label?stm_label:stm_text); } private: otl_tmpl_cursor(const otl_tmpl_cursor&): connected(0), stm_text(0), stm_label(0), cursor_struct(), vl_len(0), vl(0), adb(0), eof_data(), eof_desc(), retcode(1), _rpc(0), in_destructor(0) { } otl_tmpl_cursor& operator=(const otl_tmpl_cursor&) { return *this; } }; inline int is_num(char c) { return c>='0' && c<='9'; } template class otl_tmpl_ext_hv_decl{ private: char** hv; short int* inout; int* pl_tab_size; int array_size; int prev_array_size; short int vst[4]; int len; char* stm_text_; char* stm_label_; int container_size_; bool has_plsql_tabs_or_refcur_; public: bool has_plsql_tabs_or_refcur() const {return has_plsql_tabs_or_refcur_;} short int get_vst(const int ndx) const {return vst[ndx];} int get_len() const {return len;} short int get_inout(const int ndx) const {return inout[ndx];} int get_pl_tab_size(const int ndx) const {return pl_tab_size[ndx];} const char* stm_label() const {return stm_label_;} const char* stm_text() const {return stm_text_;} enum var_status{ in=0, out=1, io=2, def=3 }; otl_tmpl_ext_hv_decl(char* stm, int arr_size=1, char* label=0, otl_select_struct_override** select_override=0, OTL_TMPL_CONNECT* adb=0): hv(0), inout(0), pl_tab_size(0), array_size(0), prev_array_size(0), vst(), len(0), stm_text_(0), stm_label_(0), container_size_(0), has_plsql_tabs_or_refcur_(0) { container_size_=otl_var_list_size; hv=new char*[container_size_]; inout=new short[container_size_]; pl_tab_size=new int[container_size_]; has_plsql_tabs_or_refcur_=false; int j; array_size=arr_size; prev_array_size=arr_size; stm_text_=stm; stm_label_=label; int i=0; short in_str=0; bool in_comment=false; bool in_one_line_comment=false; char *c=stm; bool in_comment_column_override=false; hv[i]=0; while(*c){ switch(*c){ case '\'': if(!in_comment&&!in_one_line_comment){ if(!in_str) in_str=1; else{ if(c[1]=='\'') ++c; else in_str=0; } } break; case '/': if(c[1]=='*' && !in_str && c[2]==':' && c[3]=='#'){ in_comment_column_override=true; *c=' '; ++c; *c=' '; ++c; }else if(c[1]=='*'&&!in_str){ in_comment=true; ++c; } break; case '-': if(c[1]=='-'&&!in_str){ in_one_line_comment=true; ++c; } break; case '*': if(c[1]=='/' && in_comment){ in_comment=false; ++c; }else if(c[1]=='/' && in_comment_column_override){ *c=' '; ++c; *c=' '; } break; case '\n': if(in_one_line_comment) in_one_line_comment=false; break; } if(*c==':' && !in_str && !in_comment && !in_one_line_comment && ((c>stm && *(c-1)!='\\') || c==stm)){ char* bind_var_ptr=c; short in_out=def; int apl_tab_size=0; char var[64]; char* v=var; *v++=*c++; while(is_id(*c)) *v++=*c++; while(otl_isspace(*c)&&*c) ++c; if(*c=='<' || (*c=='/' && c[1]=='*')){ if(*c=='<') *c=' '; else if(*c=='/'&&c[1]=='*'){ *c=' '; ++c; *c=' '; } while(*c!='>' && *c!=',' && *c!='*' && *c){ *v++=*c; *c++=' '; } if(*c==','){ *c++=' '; if(otl_to_upper(*c)=='I'){ if(otl_to_upper(c[2])=='O') in_out=io; else in_out=in; }else if(otl_to_upper(*c)=='O') in_out=out; while(*c!='>' && *c && *c!='*' && (*c!='[' && *c!='(') ) *c++=' '; if(*c=='*'){ *c=' '; ++c; *c=' '; } if(*c=='[' || *c=='('){ char tmp[32]; char *t=tmp; *c++=' '; while((*c!=']' && *c!=')') && *c!='>' && *c!='*' && *c){ *t++=*c; *c++=' '; } if(*c=='*'){ *c=' '; ++c; *c=' '; } *t='\0'; apl_tab_size=atoi(tmp); while(*c!='>' && *c!='*' && *c) *c++=' '; if(*c=='*'){ *c=' '; ++c; *c=' '; } } }else if(*c=='*' && c[1]=='/'){ *c=' '; ++c; *c=' '; } if(*c)*c=' '; *v='\0'; if(select_override!=0 && bind_var_ptr[1]=='#'){ char* c4=bind_var_ptr+2; char col_num[64]; char* col_num_ptr=col_num; while(is_num(*c4) && *c4){ *col_num_ptr=*c4; ++col_num_ptr; ++c4; } *col_num_ptr=0; int col_ndx=atoi(col_num); if(col_ndx>0){ if(*select_override==0){ *select_override=new otl_select_struct_override(); } int data_type=otl_var_none; int data_len=0; char name[128]; parse_var (adb, var, data_type, data_len, name); (*select_override)->add_override (col_ndx, data_type, data_len); } c4=bind_var_ptr; while(*c4 && *c4!=' '){ *c4=' '; ++c4; } }else add_var(i,var,in_out,apl_tab_size); } } if(*c)++c; } for(j=0;j<4;++j)vst[j]=0; i=0; while(hv[i]){ switch(inout[i]){ case in: ++vst[0]; break; case out: ++vst[1]; break; case io: ++vst[2]; break; case def: ++vst[3]; break; } ++i; } len=i; } virtual ~otl_tmpl_ext_hv_decl() {int i; for(i=0;hv[i]!=0;++i) delete[] hv[i]; delete[] hv; delete[] inout; delete[] pl_tab_size; } char* operator[](int ndx){return hv[ndx];} short v_status(int ndx){return inout[ndx];} int is_id(char c){return isalnum(c)||c=='_'||c=='#';} int name_comp(char* n1,char* n2) { while(*n1!=' '&&*n1!='\0'&&*n2!=' '&&*n2!='\0'){ if(otl_to_upper(*n1)!=otl_to_upper(*n2))return 0; ++n1; ++n2; } if((*n1==' '&&*n2!=' ')||(*n2==' '&&*n1!=' ')) return 0; return 1; } void add_var(int &n,char* v,short in_out,int apl_tab_size=0) {int i; for(i=0;i0) has_plsql_tabs_or_refcur_=true; size_t v_len=strlen(v)+1; hv[n]=new char[v_len]; OTL_STRCPY_S(hv[n],v_len,v); inout[n]=in_out; pl_tab_size[n]=apl_tab_size; if(n==container_size_-1){ int temp_container_size=container_size_; container_size_*=2; char** temp_hv=new char*[container_size_]; short* temp_inout=new short[container_size_]; int* temp_pl_tab_size=new int[container_size_]; memcpy(temp_hv,hv,sizeof(char*)*temp_container_size); memcpy(temp_inout,inout,sizeof(short)*temp_container_size); memcpy(temp_pl_tab_size,pl_tab_size,sizeof(int)*temp_container_size); delete[] hv; delete[] inout; delete[] pl_tab_size; hv=temp_hv; inout=temp_inout; pl_tab_size=temp_pl_tab_size; } hv[++n]=0; inout[n]=def; pl_tab_size[n]=0; } int parse_var (OTL_TMPL_CONNECT* pdb, char* s, int& data_type, int& data_len, char* name) { data_type=otl_var_none; data_len=0; #if defined(OTL_BIND_VAR_STRICT_TYPE_CHECKING_ON) char type_arr[256]; #endif char type=' '; char t2=' '; char t3=' '; char t4=' '; int size=0; char *c=name,*c1=s; while(*c1!=' '&&*c1) *c++=*c1++; *c=0; while(*c1==' '&&*c1) ++c1; #if defined(OTL_BIND_VAR_STRICT_TYPE_CHECKING_ON) char* ct=c1; char* tac=type_arr; size_t ta_len=0; while(*ct && (*ct!='[' && *ct!='(') && ta_len=3){ type=otl_to_upper(c1[0]); t2=otl_to_upper(c1[1]); t3=otl_to_upper(c1[2]); t4=otl_to_upper(c1[3]); } if((type=='C'&&t2=='H')||(type=='R'&&t2=='A'&&t3=='W'&&(t4=='['||t4=='('))){ char tmp[32]; char *t=tmp; while((*c1!='[' && *c1!='(')&&*c1) ++c1; ++c1; while((*c1!=']' && *c1!=')')&&*c1) *t++=*c1++; *t=0; size=atoi(tmp); #if defined(OTL_ADD_NULL_TERMINATOR_TO_STRING_SIZE) size+=1; #endif } #if defined(OTL_ORA_UNICODE) if(type=='N'&&t2=='C'&&t3=='H'){ char tmp[32]; char *t=tmp; while((*c1!='[' && *c1!='(')&&*c1) ++c1; ++c1; while((*c1!=']' && *c1!=')')&&*c1) *t++=*c1++; *t=0; size=atoi(tmp); #if defined(OTL_ADD_NULL_TERMINATOR_TO_STRING_SIZE) size+=1; #endif } #endif OTL_CHECK_BIND_VARS int rc=1; switch(type){ case 'B': if(t2=='L'){ data_type=otl_var_blob; if(pdb) data_len=pdb->get_max_long_size(); else data_len=0; } #if defined(OTL_BIGINT) && \ (defined(OTL_ODBC)||defined(OTL_DB2_CLI)||\ (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\ !defined(OTL_BIGINT_TO_STR))) else if(t2=='I'){ data_type=otl_var_bigint; data_len=sizeof(OTL_BIGINT); } #elif (defined(OTL_ORA7)||defined(OTL_ORA8)|| \ defined(OTL_ORA8I)||defined(OTL_ORA9I)) && \ defined(OTL_BIGINT) && defined(OTL_ORA_MAP_BIGINT_TO_LONG) else if(t2=='I'){ data_type=otl_var_long_int; data_len=sizeof(long); } #elif (defined(OTL_ORA7)||defined(OTL_ORA8)|| \ defined(OTL_ORA8I)||defined(OTL_ORA9I)) && \ defined(OTL_BIGINT) else if(t2=='I'){ data_type=otl_var_char; data_len=otl_bigint_str_size; } #endif break; case 'C': if(t2=='H'){ data_type=otl_var_char; data_len=size; }else if(t2=='L'){ data_type=otl_var_clob; if(pdb) data_len=pdb->get_max_long_size(); else data_len=0; }else rc=0; break; case 'D': if(t2=='O'){ data_type=otl_var_double; data_len=sizeof(double); } else if(t2=='B'&&t3=='2'){ if(t4=='T'){ data_type=otl_var_db2time; data_len=sizeof(TTimestampStruct); } else if(t4=='D'){ data_type=otl_var_db2date; data_len=sizeof(TTimestampStruct); }else rc=0; }else rc=0; break; #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) case 'N': if(t2=='C'){ if(t3=='L'){ data_type=otl_var_nclob; if(pdb) data_len=pdb->get_max_long_size(); else data_len=0; }else if(t3=='H'){ data_type=otl_var_nchar; data_len=size; } } break; #endif case 'F': data_type=otl_var_float; data_len=sizeof(float); break; case 'I': data_type=otl_var_int; data_len=sizeof(int); break; case 'U': data_type=otl_var_unsigned_int; data_len=sizeof(unsigned); break; case 'R': if(t2=='E'&&t3=='F'){ data_type=otl_var_refcur; data_len=1; }else if(t2=='A'&&t3=='W'&&t4!='_'){ data_type=otl_var_raw; data_len=size; }else if(t2=='A'&&t3=='W'&&t4=='_'){ data_type=otl_var_raw_long; if(pdb) data_len=pdb->get_max_long_size(); else data_len=0; } break; case 'S': data_type=otl_var_short; data_len=sizeof(short); break; case 'L': if(t2=='O'&&t3=='N'){ data_type=otl_var_long_int; data_len=sizeof(long); }else if(t2=='T'&&t3=='Z'){ data_type=otl_var_ltz_timestamp; data_len=sizeof(TTimestampStruct); }else rc=0; break; case 'T': if(t2=='Z'){ data_type=otl_var_tz_timestamp; data_len=sizeof(TTimestampStruct); }else if(t2=='I' && t3=='M'){ data_type=otl_var_timestamp; data_len=sizeof(TTimestampStruct); }else rc=0; break; case 'V': data_type=otl_var_varchar_long; if(pdb) data_len=pdb->get_max_long_size(); else data_len=0; break; default: return 0; } return rc; } otl_tmpl_variable* alloc_var (char* s, const int vstat, const int status, OTL_TMPL_CONNECT& adb, const int apl_tab_size=0) { char name[128]; #if defined(OTL_BIND_VAR_STRICT_TYPE_CHECKING_ON) char type_arr[256]; #endif char type=' '; char t2=' '; char t3=' '; char t4=' '; char t5=' '; int size=0; char *c=name,*c1=s; while(*c1!=' '&&*c1) *c++=*c1++; *c=0; while(*c1==' '&&*c1) ++c1; #if defined(OTL_BIND_VAR_STRICT_TYPE_CHECKING_ON) char* ct=c1; char* tac=type_arr; size_t ta_len=0; while(*ct && (*ct!='[' && *ct!='(') && ta_len=3){ type=otl_to_upper(c1[0]); t2=otl_to_upper(c1[1]); t3=otl_to_upper(c1[2]); t4=otl_to_upper(c1[3]); } if(clen>4) t5=otl_to_upper(c1[4]); if((type=='C'&&t2=='H')||(type=='R'&&t2=='A'&&t3=='W'&&(t4=='['||t4=='('))){ char tmp[32]; char *t=tmp; while((*c1!='[' && *c1!='(')&&*c1) ++c1; if(*c1)++c1; while((*c1!=']' && *c1!=')')&&*c1) *t++=*c1++; *t=0; if(*tmp==0) // declaration is invalid return 0; size=atoi(tmp); #if defined(OTL_ADD_NULL_TERMINATOR_TO_STRING_SIZE) if(type=='C')size+=1; #endif if(size<2) // minimum size of should be at 2 return 0; } #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) if(type=='N'&&t2=='C'&&t3=='H'){ char tmp[32]; char *t=tmp; while((*c1!='[' && *c1!='(')&&*c1) ++c1; if(*c1)++c1; while((*c1!=']' && *c1!=')')&&*c1) *t++=*c1++; *t=0; if(*tmp==0) return 0; size=atoi(tmp); #if defined(OTL_ADD_NULL_TERMINATOR_TO_STRING_SIZE) size+=1; #endif } #endif if(status==in && (vstat==in||vstat==io)) ; else if(status==out && (vstat==out||vstat==io||vstat==def)) ; else if(status==def) ; else return 0; OTL_CHECK_BIND_VARS int pl_tab_flag=0; if(apl_tab_size){ array_size=apl_tab_size; pl_tab_flag=1; }else array_size=prev_array_size; otl_tmpl_variable* v= new otl_tmpl_variable; v->copy_name(name); switch(type){ case 'B': if(t2=='L') v->init(false, otl_var_blob, adb.get_max_long_size(), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct()); #if defined(OTL_BIGINT) && \ (defined(OTL_ODBC)||defined(OTL_DB2_CLI)||\ (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\ !defined(OTL_BIGINT_TO_STR))) else if(t2=='I') v->init(false, otl_var_bigint,sizeof(OTL_BIGINT), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); #elif (defined(OTL_ORA7)||defined(OTL_ORA8)|| \ defined(OTL_ORA8I)||defined(OTL_ORA9I)) && \ defined(OTL_BIGINT) && defined(OTL_ORA_MAP_BIGINT_TO_LONG) else if(t2=='I') v->init(false, otl_var_long_int, sizeof(long), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(), pl_tab_flag); #elif (defined(OTL_ORA7)||defined(OTL_ORA8)|| \ defined(OTL_ORA8I)||defined(OTL_ORA9I)) && \ defined(OTL_BIGINT) else if(t2=='I') v->init(false, otl_var_char, otl_bigint_str_size, OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(), pl_tab_flag); #endif break; #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) case 'N': if(t2=='C' && (t3=='L'||t3=='H')){ if(t3=='L'){ v->init(false,otl_var_nclob, adb.get_max_long_size(), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct()); v->set_ftype(otl_var_clob); }else if(t3=='H'){ v->init(false,otl_var_nchar, size, OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); v->set_ftype(otl_var_char); } }else{ delete v; v=0; } break; #endif case 'C': if(t2=='H'){ v->init(false,otl_var_char, size, OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); if(t5=='Z') v->get_var_struct().set_charz_flag(true); }else if(t2=='L') v->init(false,otl_var_clob, adb.get_max_long_size(), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct()); else{ delete v; v=0; } break; case 'D': if(t2=='O') v->init(false,otl_var_double,sizeof(double), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); else if(t2=='B'&&t3=='2'){ if(t4=='T') v->init(false,otl_var_db2time,sizeof(TTimestampStruct), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); else if(t4=='D') v->init(false,otl_var_db2date,sizeof(TTimestampStruct), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); else{ delete v; v=0; } }else{ delete v; v=0; } break; case 'F': v->init(false,otl_var_float, sizeof(float), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); break; case 'I': v->init(false,otl_var_int, sizeof(int), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); break; case 'U': v->init(false,otl_var_unsigned_int, sizeof(unsigned), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); break; case 'R': if(t2=='E'&&t3=='F') v->init(false,otl_var_refcur, 1, OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),0); else if(t2=='A'&&t3=='W'&&(t4=='['||t4=='(')) v->init(false,otl_var_raw, size, OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); else if(t2=='A'&&t3=='W') v->init(false,otl_var_raw_long, adb.get_max_long_size(), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct()); break; case 'S': v->init(false,otl_var_short, sizeof(short), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); break; case 'L': if(t2=='O'&&t3=='N') v->init(false,otl_var_long_int, sizeof(long), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); else if(t2=='T'&&t3=='Z') v->init(false,otl_var_ltz_timestamp, sizeof(TTimestampStruct), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); else{ delete v; v=0; } break; case 'T': if(t2=='Z') v->init(false,otl_var_tz_timestamp,sizeof(TTimestampStruct), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); else if(t2=='I' && t3=='M') v->init(false,otl_var_timestamp,sizeof(TTimestampStruct), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct(),pl_tab_flag); else{ delete v; v=0; } break; case 'V': v->init(false,otl_var_varchar_long,adb.get_max_long_size(), OTL_SCAST(const otl_stream_buffer_size_type,array_size), &adb.get_connect_struct()); break; default: delete v; v=0; break; } return v; } void alloc_host_var_list (otl_tmpl_variable** &vl, int& vl_len, OTL_TMPL_CONNECT& adb, const int status=def) { int j; vl_len=0; if(!hv[0]){ vl=0; return; } otl_auto_array_ptr*> loc_ptr(container_size_); otl_tmpl_variable** tmp_vl=loc_ptr.get_ptr(); int i=0; while(hv[i]){ otl_tmpl_variable* vp= alloc_var(hv[i],inout[i],status,adb,pl_tab_size[i]); if(vp==0){ int j2; for(j2=0;j2set_name_pos(i+1); if(vp){ ++vl_len; tmp_vl[vl_len-1]=vp; } ++i; } if(vl_len>0){ vl=new otl_tmpl_variable*[vl_len]; for(j=0;j&): hv(0), inout(0), pl_tab_size(0), array_size(0), prev_array_size(0), vst(), len(0), stm_text_(0), stm_label_(0), container_size_(0), has_plsql_tabs_or_refcur_(0) { } otl_tmpl_ext_hv_decl & operator= (const otl_tmpl_ext_hv_decl &) { return *this; } }; template class otl_tmpl_select_cursor: public OTL_TMPL_CURSOR{ protected: int cur_row; int cur_size; int row_count; int array_size; int prefetch_array_size; TSelectCursorStruct select_cursor_struct; otl_select_struct_override local_override; void* master_stream_ptr_; public: otl_tmpl_select_cursor (OTL_TMPL_CONNECT& pdb, void* master_stream_ptr, const otl_stream_buffer_size_type arr_size=1, const char* sqlstm_label=0): OTL_TMPL_CURSOR(pdb), cur_row(-1), cur_size(0), row_count(0), array_size(0), prefetch_array_size(0), select_cursor_struct(), local_override(), master_stream_ptr_(master_stream_ptr) { local_override.reset(); if(sqlstm_label!=0){ if(this->stm_label!=0){ delete[] this->stm_label; this->stm_label=0; } size_t len=strlen(sqlstm_label)+1; this->stm_label=new char[len]; OTL_STRCPY_S(this->stm_label,len,sqlstm_label); } select_cursor_struct.set_arr_size (arr_size, array_size, prefetch_array_size); select_cursor_struct.init(array_size); } otl_tmpl_select_cursor() : OTL_TMPL_CURSOR(), master_stream_ptr_(0) { } void open (OTL_TMPL_CONNECT& db, otl_stream_buffer_size_type arr_size=1) { local_override.reset(); cur_row=-1; row_count=0; cur_size=0; array_size=arr_size; OTL_TMPL_CURSOR::open(db); } void close(void) { local_override.reset(); OTL_TMPL_CURSOR::close(); } int first(void) { if(!OTL_TMPL_CURSOR::connected)return 0; select_cursor_struct.set_prefetch_size(prefetch_array_size); int rc=select_cursor_struct.first (this->cursor_struct, cur_row,cur_size, row_count, this->eof_data, array_size); OTL_TRACE_FIRST_FETCH if(!rc){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw OTL_TMPL_EXCEPTION (this->cursor_struct, this->stm_label? this->stm_label: this->stm_text); } return cur_size!=0; } int next_throw(void) { if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw OTL_TMPL_EXCEPTION (this->cursor_struct, this->stm_label? this->stm_label: this->stm_text); } int next(void) { if(!this->connected)return 0; if(cur_row==-1)return first(); int rc=select_cursor_struct.next (this->cursor_struct, cur_row,cur_size, row_count, this->eof_data, array_size); if(!rc){ return next_throw(); } OTL_TRACE_NEXT_FETCH return cur_size!=0; } private: otl_tmpl_select_cursor (const otl_tmpl_select_cursor&): OTL_TMPL_CURSOR(), cur_row(-1), cur_size(0), row_count(0), array_size(0), prefetch_array_size(0), select_cursor_struct(), local_override() { } otl_tmpl_select_cursor& operator= (const otl_tmpl_select_cursor&) { return *this; } }; #if defined(OTL_ORA8)||defined(OTL_ODBC) const int otl_lob_stream_read_mode=1; const int otl_lob_stream_write_mode=2; const int otl_lob_stream_zero_mode=3; const int otl_lob_stream_first_piece=1; const int otl_lob_stream_next_piece=2; const int otl_lob_stream_last_piece=3; class otl_lob_stream_generic{ protected: int mode; int retcode; int ndx; int offset; int lob_len; int in_destructor; int eof_flag; int lob_is_null; bool ora_lob; public: int get_ora_lob() const {return ora_lob;} otl_lob_stream_generic(const bool aora_lob=true): mode(0), retcode(0), ndx(0), offset(0), lob_len(0), in_destructor(0), eof_flag(0), lob_is_null(0), ora_lob(aora_lob) { } virtual ~otl_lob_stream_generic(){} virtual void init (void* avar,void* aconnect,void* acursor,int andx, int amode,const int alob_is_null=0) = 0; virtual void set_len(const int new_len=0) = 0; virtual otl_lob_stream_generic& operator<<(const otl_long_string& s) = 0; virtual otl_lob_stream_generic& operator>>(otl_long_string& s) = 0; #if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_UNICODE) virtual otl_lob_stream_generic& operator<<(const OTL_STRING_CONTAINER& s) = 0; virtual otl_lob_stream_generic& operator>>(OTL_STRING_CONTAINER& s) = 0; virtual void setStringBuffer(const int chunk_size) = 0; #endif virtual int eof(void) = 0; virtual int len(void) = 0; virtual bool is_initialized(void) = 0; virtual void close(void) = 0; private: otl_lob_stream_generic(const otl_lob_stream_generic&): mode(0), retcode(0), ndx(0), offset(0), lob_len(0), in_destructor(0), eof_flag(0), lob_is_null(0), ora_lob(false) { } otl_lob_stream_generic& operator=(const otl_lob_stream_generic&) { return *this; } }; #endif #if defined(__GNUC__) || defined(__SUNPRO_CC) || \ (defined(_MSC_VER) && (_MSC_VER <= 1300)) || \ defined(__HP_aCC) || defined(__BORLANDC__) || \ ((defined(__IBMC__) || defined(__IBMCPP__)) && defined(__xlC__)) // Enable the kludge for compilers that do not support template // member functions at all, or have bugs: g++, Forte C++ (Solaris), // Visual C++ 6.0, Visual C++ 7.0, xlC v6, etc. #if !defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) #define OTL_NO_TMPL_MEMBER_FUNC_SUPPORT #endif #endif template class otl_tmpl_select_stream: public OTL_TMPL_SELECT_CURSOR{ protected: otl_column_desc* sl_desc; otl_tmpl_variable* sl; int sl_len; int null_fetched; int cur_col; int cur_in; int executed; int eof_status; char var_info[256]; otl_select_struct_override* override; int delay_next; bool lob_stream_mode; long _rfc; public: int get_select_row_count() const { return this->cur_row==-1?0:this->cur_size-this->cur_row; } int get_prefetched_row_count() const {return this->row_count;} int get_row_count() const {return this->row_count;} int get_sl_len() const {return sl_len;} otl_tmpl_variable* get_sl(){return sl;} otl_column_desc* get_sl_desc(){return sl_desc;} long get_rfc() const {return _rfc;} void cleanup(void) {int i; delete[] sl; for(i=0;ivl_len;++i) delete this->vl[i]; delete[] this->vl; delete[] sl_desc; } virtual ~otl_tmpl_select_stream() { cleanup(); } otl_tmpl_select_stream (otl_select_struct_override* aoverride, const otl_stream_buffer_size_type arr_size, const char* sqlstm, OTL_TMPL_CONNECT& pdb, const int implicit_select=otl_explicit_select, const char* sqlstm_label=0) : OTL_TMPL_SELECT_CURSOR (pdb, aoverride->get_master_stream_ptr(), arr_size,sqlstm_label), sl_desc(0), sl(0), sl_len(0), null_fetched(0), cur_col(0), cur_in(0), executed(0), eof_status(0), var_info(), override(0), delay_next(0), lob_stream_mode(false), _rfc(0) { int i; this->select_cursor_struct.set_select_type(implicit_select); sl=0; sl_len=0; _rfc=0; null_fetched=0; lob_stream_mode=aoverride->get_lob_stream_mode(); this->retcode=0; sl_desc=0; executed=0; cur_in=0; this->stm_text=0; eof_status=1; override=aoverride; { size_t len=strlen(sqlstm)+1; this->stm_text=new char[len]; OTL_STRCPY_S(this->stm_text,len,sqlstm); otl_select_struct_override* temp_local_override=&this->local_override; otl_tmpl_ext_hv_decl hvd (this->stm_text, 1, this->stm_label, &temp_local_override, &pdb ); hvd.alloc_host_var_list(this->vl,this->vl_len,pdb); } try{ this->parse(); if(!this->select_cursor_struct.get_implicit_cursor()){ get_select_list(); bind_all(); }else{ for(i=0;ivl_len;++i) this->bind(*this->vl[i]); } if(this->vl_len==0){ rewind(); null_fetched=0; } }catch(OTL_CONST_EXCEPTION OTL_TMPL_EXCEPTION&){ cleanup(); if(this->adb)this->adb->increment_throw_count(); throw; } } void rewind(void) { OTL_TRACE_STREAM_EXECUTION int i; _rfc=0; if(!this->select_cursor_struct.close_select(this->cursor_struct)){ throw OTL_TMPL_EXCEPTION (this->cursor_struct, this->stm_label?this->stm_label:this->stm_text); } if(this->select_cursor_struct.get_implicit_cursor()){ this->exec(1,0,otl_sql_exec_from_select_cursor_class); if(sl){ delete[] sl; sl=0; } get_select_list(); for(i=0;ibind(sl[i]); } eof_status=this->first(); null_fetched=0; cur_col=-1; cur_in=0; executed=1; delay_next=0; } void clean(void) { _rfc=0; this->cursor_struct.set_canceled(false); null_fetched=0; cur_col=-1; cur_in=0; executed=0; eof_status=0; delay_next=0; this->cur_row=-1; this->row_count=0; this->cur_size=0; if(!this->select_cursor_struct.close_select(this->cursor_struct)){ throw OTL_TMPL_EXCEPTION (this->cursor_struct, this->stm_label?this->stm_label:this->stm_text); } } int is_null(void) { return null_fetched; } int eof(void) { if(delay_next){ look_ahead(); delay_next=0; } return !eof_status; } int eof_intern(void) { return !eof_status; } void skip_to_end_of_row() { check_if_executed(); if(eof_intern())return; while(cur_colcur_row); } eof_status=this->next(); cur_col=0; if(!eof_intern()) cur_col=-1; ++_rfc; } void bind_all(void) {int i; for(i=0;ivl_len;++i)this->bind(*this->vl[i]); for(i=0;ibind(sl[i]); } void get_select_list(void) { int j; otl_auto_array_ptr loc_ptr(otl_var_list_size); otl_column_desc* sl_desc_tmp=loc_ptr.get_ptr(); int sld_tmp_len=0; int ftype,elem_size,i; for(i=1;this->describe_column(sl_desc_tmp[i-1],i);++i){ int temp_code_type= otl_tmpl_variable::int2ext (sl_desc_tmp[i-1].dbtype); if(temp_code_type==otl_unsupported_type){ otl_var_info_col3 (i-1, sl_desc_tmp[i-1].dbtype, sl_desc_tmp[i-1].name, this->var_info, sizeof(this->var_info)); throw OTL_TMPL_EXCEPTION (otl_error_msg_27, otl_error_code_27, this->stm_label? this->stm_label: this->stm_text, this->var_info); } ++sld_tmp_len; if(sld_tmp_len==loc_ptr.get_arr_size()){ loc_ptr.double_size(); sl_desc_tmp=loc_ptr.get_ptr(); } } sl_len=sld_tmp_len; if(sl){ delete[] sl; sl=0; } sl=new otl_tmpl_variable[sl_len==0?1:sl_len]; int max_long_size=this->adb->get_max_long_size(); for(j=0;j::map_ftype (sl_desc_tmp[j], max_long_size, ftype, elem_size, this->local_override.getLen()>0?this->local_override:*override, j+1, this->adb->get_connect_struct().get_connection_type()); sl[j].copy_pos(j+1); #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) if(sl_desc_tmp[j].charset_form==2) sl[j].get_var_struct().set_nls_flag(true); #endif sl[j].init(true, ftype, elem_size, OTL_SCAST(otl_stream_buffer_size_type,(this->array_size)), &this->adb->get_connect_struct() ); sl[j].get_var_struct().set_lob_stream_mode(this->lob_stream_mode); } if(sl_desc){ delete[] sl_desc; sl_desc=0; } sl_desc=new otl_column_desc[sl_len==0?1:sl_len]; for(j=0;jadb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (otl_error_msg_2, otl_error_code_2, this->stm_label? this->stm_label: this->stm_text, 0); } void check_if_executed(void) { if(!executed){ check_if_executed_throw(); } } int check_type_throw(int type_code,int actual_data_type) { int out_type_code; if(actual_data_type!=0) out_type_code=actual_data_type; else out_type_code=type_code; otl_var_info_col (sl[cur_col].get_pos(), sl[cur_col].get_ftype(), out_type_code, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw OTL_TMPL_EXCEPTION (otl_error_msg_0, otl_error_code_0, this->stm_label? this->stm_label: this->stm_text, var_info); } #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) void strict_check_throw(int type_code) { otl_var_info_col (sl[cur_col].get_pos(), sl[cur_col].get_ftype(), type_code, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (otl_error_msg_0, otl_error_code_0, this->stm_label? this->stm_label: this->stm_text, var_info); } #endif int check_type(int type_code,int actual_data_type=0) { switch(sl[cur_col].get_ftype()){ case otl_var_timestamp: case otl_var_tz_timestamp: case otl_var_ltz_timestamp: if(type_code==otl_var_timestamp) return 1; default: if(sl[cur_col].get_ftype()==type_code) return 1; } return check_type_throw(type_code,actual_data_type); } void get_next(void) { if(cur_colcur_row); }else{ eof_status=this->next(); cur_col=0; } } void look_ahead(void) { if(cur_col==sl_len-1){ eof_status=this->next(); cur_col=-1; ++_rfc; } } OTL_TMPL_SELECT_STREAM& operator>>(char& c) { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ c=*OTL_RCAST(char*,sl[cur_col].val(this->cur_row)); look_ahead(); } return *this; } OTL_TMPL_SELECT_STREAM& operator>>(unsigned char& c) { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ c=*OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row)); look_ahead(); } return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) OTL_TMPL_SELECT_STREAM& operator>>(OTL_STRING_CONTAINER& s) { check_if_executed(); if(eof_intern())return *this; get_next(); switch(sl[cur_col].get_ftype()){ case otl_var_char: if(!eof_intern()){ #if defined(OTL_ACE) s.set(OTL_RCAST(char*,sl[cur_col].val(this->cur_row)),1); #else s=OTL_RCAST(char*,sl[cur_col].val(this->cur_row)); #endif look_ahead(); } break; #if defined(OTL_USER_DEFINED_STRING_CLASS_ON) || \ defined(OTL_STL) || defined(OTL_ACE) case otl_var_varchar_long: case otl_var_raw_long: if(!eof_intern()){ unsigned char* c=OTL_RCAST(unsigned char*, sl[cur_col].val(this->cur_row)); int len=sl[cur_col].get_len(this->cur_row); int buf_sz=sl[cur_col].get_elem_size(); if(len>buf_sz)len=buf_sz; #if (defined(OTL_USER_DEFINED_STRING_CLASS_ON) || defined(OTL_STL)) \ && !defined(OTL_ACE) s.assign(OTL_RCAST(char*,c),len); #elif defined(OTL_ACE) s.set(OTL_RCAST(char*,c),len,1); #endif look_ahead(); } break; case otl_var_blob: case otl_var_clob: if(!eof_intern()){ int len=0; int max_long_sz=this->adb->get_max_long_size(); otl_auto_array_ptr loc_ptr(max_long_sz); unsigned char* temp_buf=loc_ptr.get_ptr(); int rc=sl[cur_col].get_var_struct().get_blob (this->cur_row, temp_buf, max_long_sz, len); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } #if (defined(OTL_USER_DEFINED_STRING_CLASS_ON) || \ defined(OTL_STL)) && !defined(OTL_ACE) s.assign(OTL_RCAST(char*,temp_buf),len); #elif defined(OTL_ACE) s.set(OTL_RCAST(char*,temp_buf),len,1); #endif look_ahead(); } break; #endif default: check_type(otl_var_char); } // switch return *this; } #endif OTL_TMPL_SELECT_STREAM& operator>>(char* s) { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,sl[cur_col].val(this->cur_row)) ); look_ahead(); } return *this; } #if defined(OTL_UNICODE_STRING_TYPE) OTL_TMPL_SELECT_STREAM& operator<<(const OTL_UNICODE_STRING_TYPE& s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy4 (OTL_RCAST(unsigned char*,this->vl[cur_in]->val()), OTL_RCAST(unsigned char*, OTL_CCAST(OTL_UNICODE_CHAR_TYPE*,s.c_str())), overflow, this->vl[cur_in]->get_elem_size(), OTL_SCAST(int,s.length()) ); if(overflow){ char temp_var_info[256]; otl_var_info_var (this->vl[cur_in]->get_name(), this->vl[cur_in]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_4, otl_error_code_4, this->stm_label?this->stm_label: this->stm_text, temp_var_info); } this->vl[cur_in]->set_not_null(0); } get_in_next(); return *this; } #endif #if defined(OTL_UNICODE_STRING_TYPE) OTL_TMPL_SELECT_STREAM& operator>>(OTL_UNICODE_STRING_TYPE& s) { check_if_executed(); if(eof_intern())return *this; get_next(); switch(sl[cur_col].get_ftype()){ case otl_var_char: if(!eof_intern()){ #if defined(OTL_ODBC) || defined(DB2_CLI) s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row)); #else #if defined(OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR) OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row)); OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR(s,temp_s+1,*temp_s); #else OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row)); s.assign(temp_s+1,*temp_s); #endif #endif look_ahead(); } break; case otl_var_varchar_long: if(!eof_intern()){ s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row)); look_ahead(); } break; case otl_var_clob: if(!eof_intern()){ int len=0; int max_long_sz=this->adb->get_max_long_size(); otl_auto_array_ptr loc_ptr(max_long_sz); unsigned char* temp_buf=OTL_RCAST(unsigned char*,loc_ptr.get_ptr()); int rc=sl[cur_col].get_var_struct().get_blob (this->cur_row, temp_buf, max_long_sz, len); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,temp_buf); look_ahead(); } break; default: check_type(otl_var_char); } return *this; } #endif OTL_TMPL_SELECT_STREAM& operator>>(unsigned char* s) { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ otl_strcpy2(OTL_RCAST(unsigned char*,s), OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row)), sl[cur_col].get_len(this->cur_row) ); look_ahead(); } return *this; } #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) #define OTL_D1(T,T_type) \ OTL_TMPL_SELECT_STREAM& operator>>(T& n) \ { \ check_if_executed(); \ if(eof_intern())return *this; \ get_next(); \ if(!eof_intern()){ \ int match_found=otl_numeric_convert_T \ (sl[cur_col].get_ftype(), \ sl[cur_col].val(this->cur_row), \ n); \ if(!match_found) \ strict_check_throw(T_type); \ look_ahead(); \ } \ return *this; \ } #else #define OTL_D1(T,T_type) \ OTL_TMPL_SELECT_STREAM& operator>>(T& n) \ { \ check_if_executed(); \ if(eof_intern())return *this; \ get_next(); \ if(!eof_intern()){ \ int match_found=otl_numeric_convert_T \ (sl[cur_col].get_ftype(), \ sl[cur_col].val(this->cur_row), \ n); \ if(!match_found){ \ if(check_type(otl_var_double,T_type)) \ n=OTL_PCONV(T,double,sl[cur_col].val(this->cur_row)); \ } \ look_ahead(); \ } \ return *this; \ } #endif #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) OTL_D1(int,otl_var_int) #if defined(OTL_BIGINT) OTL_D1(OTL_BIGINT,otl_var_bigint) #endif OTL_D1(unsigned,otl_var_unsigned_int) OTL_D1(long,otl_var_long_int) OTL_D1(short,otl_var_short) OTL_D1(float,otl_var_float) OTL_D1(double,otl_var_double) #else template OTL_D1(T,T_type) #endif OTL_TMPL_SELECT_STREAM& operator>>(TTimestampStruct& t) { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_timestamp)&&!eof_intern()){ TTimestampStruct* tm= OTL_RCAST(TTimestampStruct*,sl[cur_col].val(this->cur_row)); int rc=sl[cur_col].get_var_struct().read_dt (&t,tm,sizeof(TTimestampStruct)); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } look_ahead(); } return *this; } OTL_TMPL_SELECT_STREAM& operator>>(otl_long_string& s) { check_if_executed(); if(eof_intern())return *this; get_next(); switch(sl[cur_col].get_ftype()){ case otl_var_raw_long: { if(!eof_intern()){ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row)); int len2=sl[cur_col].get_len(this->cur_row); if(len2>s.get_buf_size()) len2=s.get_buf_size(); otl_memcpy(s.v,c,len2,sl[cur_col].get_ftype()); s.set_len(len2); look_ahead(); } } break; case otl_var_varchar_long: { if(!eof_intern()){ if(sl[cur_col].get_var_struct().get_otl_adapter()==otl_ora8_adapter){ #if defined(OTL_UNICODE) int len2=0; OTL_CHAR* source=OTL_RCAST(OTL_CHAR*,sl[cur_col].val(this->cur_row)); OTL_CHAR* target=OTL_RCAST(OTL_CHAR*,s.v); while(*source && len2cur_row)); int len2=sl[cur_col].get_len(this->cur_row); if(len2>s.get_buf_size()) len2=s.get_buf_size(); otl_memcpy(s.v,c,len2,sl[cur_col].get_ftype()); s.null_terminate_string(len2); s.set_len(len2); look_ahead(); #endif }else{ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row)); int len2=sl[cur_col].get_len(this->cur_row); if(len2>s.get_buf_size()) len2=s.get_buf_size(); otl_memcpy(s.v,c,len2,sl[cur_col].get_ftype()); s.null_terminate_string(len2); s.set_len(len2); look_ahead(); } } } break; case otl_var_raw: { if(!eof_intern()){ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row)); if(sl[cur_col].get_var_struct().get_otl_adapter()==otl_ora7_adapter|| sl[cur_col].get_var_struct().get_otl_adapter()==otl_ora8_adapter){ int len2=OTL_SCAST(int,*OTL_RCAST(unsigned short*,c)); otl_memcpy(s.v,c+sizeof(short int),len2,sl[cur_col].get_ftype()); s.set_len(len2); }else{ int len2=sl[cur_col].get_len(this->cur_row); if(len2>s.get_buf_size()) len2=s.get_buf_size(); otl_memcpy(s.v,c,len2,sl[cur_col].get_ftype()); s.set_len(len2); } look_ahead(); } } break; case otl_var_blob: case otl_var_clob: { if(!eof_intern()){ int len=0; int rc=sl[cur_col].get_var_struct().get_blob (this->cur_row,s.v,s.get_buf_size(),len); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } if(len>s.get_buf_size()) len=s.get_buf_size(); s.set_len(len); if(sl[cur_col].get_ftype()==otl_var_clob) s.null_terminate_string(len); look_ahead(); } } break; default: { char tmp_var_info[256]; otl_var_info_col (sl[cur_col].get_pos(), sl[cur_col].get_ftype(), otl_var_long_string, tmp_var_info, sizeof(tmp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_0, otl_error_code_0, this->stm_label?this->stm_label: this->stm_text, tmp_var_info); } } return *this; } #if defined(OTL_ORA8)||defined(OTL_ODBC) OTL_TMPL_SELECT_STREAM& operator>> (otl_lob_stream_generic& s) { check_if_executed(); if(eof_intern())return *this; get_next(); if(s.get_ora_lob() && (sl[cur_col].get_ftype()==otl_var_blob|| sl[cur_col].get_ftype()==otl_var_clob)&& !eof_intern()){ s.init (OTL_RCAST(void*,&sl[cur_col]), OTL_RCAST(void*,this->adb), OTL_RCAST(void*,this), this->cur_row, otl_lob_stream_read_mode, this->is_null()); delay_next=1; }else if((sl[cur_col].get_ftype()==otl_var_varchar_long|| sl[cur_col].get_ftype()==otl_var_raw_long)&& !eof_intern()){ s.init (OTL_RCAST(void*,&sl[cur_col]), OTL_RCAST(void*,this->adb), OTL_RCAST(void*,this), this->cur_row, otl_lob_stream_read_mode); delay_next=1; }else{ char tmp_var_info[256]; otl_var_info_col (sl[cur_col].get_pos(), sl[cur_col].get_ftype(), otl_var_long_string, tmp_var_info, sizeof(tmp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_0, otl_error_code_0, this->stm_label?this->stm_label: this->stm_text, tmp_var_info); } return *this; } #endif int check_in_type_throw(int type_code) { otl_var_info_var (this->vl[cur_in]->get_name(), this->vl[cur_in]->get_ftype(), type_code, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw OTL_TMPL_EXCEPTION (otl_error_msg_0, otl_error_code_0, this->stm_label?this->stm_label: this->stm_text, var_info); } int check_in_type(int type_code,int tsize) { switch(this->vl[cur_in]->get_ftype()){ case otl_var_char: if(type_code==otl_var_char) return 1; case otl_var_db2date: case otl_var_db2time: case otl_var_timestamp: case otl_var_tz_timestamp: case otl_var_ltz_timestamp: if(type_code==otl_var_timestamp) return 1; default: if(this->vl[cur_in]->get_ftype()==type_code && this->vl[cur_in]->get_elem_size()==tsize) return 1; } return check_in_type_throw(type_code); } void check_in_var_throw(void) { if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (otl_error_msg_1, otl_error_code_1, this->stm_label?this->stm_label: this->stm_text, 0); } void check_in_var(void) { if(this->vl_len==0) check_in_var_throw(); } void get_in_next(void) { if(cur_in==this->vl_len-1) rewind(); else{ ++cur_in; executed=0; } } OTL_TMPL_SELECT_STREAM& operator<<(const otl_null& /* n */) { check_in_var(); this->vl[cur_in]->set_null(0); get_in_next(); return *this; } OTL_TMPL_SELECT_STREAM& operator<<(const char c) { check_in_var(); if(check_in_type(otl_var_char,1)){ char* tmp=OTL_RCAST(char*,this->vl[cur_in]->val()); tmp[0]=c; tmp[1]=0; this->vl[cur_in]->set_not_null(0); } get_in_next(); return *this; } OTL_TMPL_SELECT_STREAM& operator<<(const unsigned char c) { check_in_var(); if(check_in_type(otl_var_char,1)){ unsigned char* tmp= OTL_RCAST(unsigned char*,this->vl[cur_in]->val()); tmp[0]=c; tmp[1]=0; this->vl[cur_in]->set_not_null(0); } get_in_next(); return *this; } OTL_TMPL_SELECT_STREAM& operator<<(const char* s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy (OTL_RCAST(unsigned char*,this->vl[cur_in]->val()), OTL_RCAST(unsigned char*,OTL_CCAST(char*,s)), overflow, this->vl[cur_in]->get_elem_size() ); if(overflow){ char tmp_var_info[256]; otl_var_info_var (this->vl[cur_in]->get_name(), this->vl[cur_in]->get_ftype(), otl_var_char, tmp_var_info, sizeof(tmp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_4, otl_error_code_4, this->stm_label?this->stm_label: this->stm_text, tmp_var_info); } this->vl[cur_in]->set_not_null(0); } get_in_next(); return *this; } OTL_TMPL_SELECT_STREAM& operator<<(const otl_long_string& s) { check_in_var(); switch(this->vl[cur_in]->get_ftype()){ case otl_var_varchar_long: { unsigned char* c=OTL_RCAST(unsigned char*,this->vl[cur_in]->val(0)); int len=OTL_CCAST(otl_long_string*,&s)->len(); this->vl[cur_in]->set_not_null(0); if(len>this->vl[cur_in]->actual_elem_size()){ otl_var_info_var (this->vl[cur_in]->get_name(), this->vl[cur_in]->get_ftype(), otl_var_long_string, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } otl_memcpy(c,s.v,len,this->vl[cur_in]->get_ftype()); this->vl[cur_in]->set_len(len,0); } break; case otl_var_raw_long: { unsigned char* c=OTL_RCAST(unsigned char*,this->vl[cur_in]->val(0)); int len=OTL_CCAST(otl_long_string*,&s)->len(); if(len>this->vl[cur_in]->actual_elem_size()){ otl_var_info_var (this->vl[cur_in]->get_name(), this->vl[cur_in]->get_ftype(), otl_var_char, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_in]->set_not_null(0); otl_memcpy(c,s.v,len,this->vl[cur_in]->get_ftype()); this->vl[cur_in]->set_len(len,0); } break; case otl_var_raw: { unsigned char* c=OTL_RCAST(unsigned char*,this->vl[cur_in]->val(0)); int len=OTL_CCAST(otl_long_string*,&s)->len(); if(len>this->vl[cur_in]->actual_elem_size()){ otl_var_info_var (this->vl[cur_in]->get_name(), this->vl[cur_in]->get_ftype(), otl_var_raw, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_in]->set_not_null(0); if((this->vl[cur_in]->get_var_struct().get_otl_adapter()==otl_ora7_adapter|| this->vl[cur_in]->get_var_struct().get_otl_adapter()==otl_ora8_adapter) && this->vl[cur_in]->get_ftype()==otl_var_raw){ otl_memcpy (c+sizeof(unsigned short), s.v, len, this->vl[cur_in]->get_ftype()); *OTL_RCAST(unsigned short*, this->vl[cur_in]->val(0))=OTL_SCAST(unsigned short,len); this->vl[cur_in]->set_len(len,0); }else{ otl_memcpy(c,s.v,len,this->vl[cur_in]->get_ftype()); this->vl[cur_in]->set_len(len,0); } } break; } get_in_next(); return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) OTL_TMPL_SELECT_STREAM& operator<<(const OTL_STRING_CONTAINER& s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy (OTL_RCAST(unsigned char*,this->vl[cur_in]->val()), OTL_RCAST(unsigned char*,OTL_CCAST(char*,s.c_str())), overflow, this->vl[cur_in]->get_elem_size(), OTL_SCAST(int,s.length()) ); if(overflow){ char temp_var_info[256]; otl_var_info_var (this->vl[cur_in]->get_name(), this->vl[cur_in]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_4, otl_error_code_4, this->stm_label?this->stm_label: this->stm_text, temp_var_info); } this->vl[cur_in]->set_not_null(0); } get_in_next(); return *this; } #endif OTL_TMPL_SELECT_STREAM& operator<<(const unsigned char* s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy4 (OTL_RCAST(unsigned char*,this->vl[cur_in]->val()), OTL_CCAST(unsigned char*,s), overflow, this->vl[cur_in]->get_elem_size() ); if(overflow){ char temp_var_info[256]; otl_var_info_var (this->vl[cur_in]->get_name(), this->vl[cur_in]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_4, otl_error_code_4, this->stm_label?this->stm_label: this->stm_text, temp_var_info); } this->vl[cur_in]->set_not_null(0); } get_in_next(); return *this; } #define OTL_D2(T,T_type) \ OTL_TMPL_SELECT_STREAM& operator<<(const T n) \ { \ check_in_var(); \ if(check_in_type(T_type,sizeof(T))){ \ *OTL_RCAST(T*,this->vl[cur_in]->val())=n; \ } \ this->vl[cur_in]->set_not_null(0); \ get_in_next(); \ return *this; \ } #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) OTL_D2(int,otl_var_int) OTL_D2(unsigned,otl_var_unsigned_int) #if defined(OTL_BIGINT) OTL_D2(OTL_BIGINT,otl_var_bigint) #endif OTL_D2(long,otl_var_long_int) OTL_D2(short,otl_var_short) OTL_D2(float,otl_var_float) OTL_D2(double,otl_var_double) #else template OTL_D2(T,T_type) #endif OTL_TMPL_SELECT_STREAM& operator<<(const TTimestampStruct& t) { check_in_var(); if(check_in_type(otl_var_timestamp,sizeof(TTimestampStruct))){ TTimestampStruct* tm= OTL_RCAST(TTimestampStruct*,this->vl[cur_in]->val()); int rc=this->vl[cur_in]->get_var_struct().write_dt (tm,&t,sizeof(TTimestampStruct)); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } private: otl_tmpl_select_stream (const otl_tmpl_select_stream&): OTL_TMPL_SELECT_CURSOR(), sl_desc(0), sl(0), sl_len(0), null_fetched(0), cur_col(0), cur_in(0), executed(0), eof_status(0), var_info(), override(0), delay_next(0), lob_stream_mode(false), _rfc(0) { } otl_tmpl_select_stream& operator=(const otl_tmpl_select_stream&) { return *this; } }; template class otl_tmpl_out_stream: public OTL_TMPL_CURSOR{ protected: int auto_commit_flag; int dirty; int cur_x; int cur_y; otl_stream_buffer_size_type array_size; int in_exception_flag; int in_destruct_flag; int should_delete_flag; char var_info[256]; bool flush_flag; bool flush_flag2; bool lob_stream_mode; void* master_stream_ptr_; public: int get_dirty_buf_len() const { if(cur_y==0) return 0; else return cur_y+1; } void set_flush_flag(const bool aflush_flag) { flush_flag=aflush_flag; } void set_flush_flag2(const bool aflush_flag2) { flush_flag2=aflush_flag2; } void cleanup(void) {int i; if(should_delete_flag){ for(i=0;ivl_len;++i) delete this->vl[i]; } delete[] this->vl; } otl_tmpl_out_stream (otl_stream_buffer_size_type arr_size, const char* sqlstm, OTL_TMPL_CONNECT& db, void* master_stream_ptr, const bool alob_stream_mode=false, const char* sqlstm_label=0): OTL_TMPL_CURSOR(db), auto_commit_flag(0), dirty(0), cur_x(0), cur_y(0), array_size(0), in_exception_flag(0), in_destruct_flag(0), should_delete_flag(0), var_info(), flush_flag(0), flush_flag2(0), lob_stream_mode(0), master_stream_ptr_(master_stream_ptr) { int i; if(sqlstm_label!=0){ if(this->stm_label!=0){ delete[] this->stm_label; this->stm_label=0; } size_t len=strlen(sqlstm_label)+1; this->stm_label=new char[strlen(sqlstm_label)+1]; OTL_STRCPY_S(this->stm_label,len,sqlstm_label); } dirty=0; auto_commit_flag=1; flush_flag=true; flush_flag2=true; lob_stream_mode=alob_stream_mode; this->cursor_struct.last_param_data_token=0; this->cursor_struct.last_sql_param_data_status=0; this->cursor_struct.sql_param_data_count=0; cur_x=-1; cur_y=0; should_delete_flag=1; in_exception_flag=0; in_destruct_flag=0; this->stm_text=0; array_size=arr_size; { int len=strlen(sqlstm)+1; this->stm_text=new char[len]; OTL_STRCPY_S(this->stm_text,len,sqlstm); otl_tmpl_ext_hv_decl hvd(this->stm_text,arr_size); hvd.alloc_host_var_list(this->vl,this->vl_len,db); } try{ this->parse(); for(i=0;ivl_len;++i){ if(this->vl[i]->get_var_struct().otl_adapter==otl_odbc_adapter){ this->vl[i]->get_var_struct().lob_stream_mode=lob_stream_mode; this->vl[i]->get_var_struct().vparam_type=this->vl[i]->get_param_type(); if(this->vl[i]->get_ftype()==otl_var_varchar_long|| this->vl[i]->get_ftype()==otl_var_raw_long){ this->vl[i]->set_not_null(0); } } bind(*(this->vl[i])); } }catch(OTL_CONST_EXCEPTION OTL_TMPL_EXCEPTION&){ cleanup(); if(this->adb)this->adb->increment_throw_count(); throw; } } otl_tmpl_out_stream (OTL_TMPL_CONNECT& pdb, void* master_stream_ptr, const bool alob_stream_mode=false, const char* sqlstm_label=0): OTL_TMPL_CURSOR(pdb), auto_commit_flag(0), dirty(0), cur_x(0), cur_y(0), array_size(0), in_exception_flag(0), in_destruct_flag(0), should_delete_flag(0), var_info(), flush_flag(0), flush_flag2(0), lob_stream_mode(0), master_stream_ptr_(master_stream_ptr) { if(sqlstm_label!=0){ if(this->stm_label!=0){ delete[] this->stm_label; this->stm_label=0; } size_t len=strlen(sqlstm_label)+1; this->stm_label=new char[len]; OTL_STRCPY_S(this->stm_label,len,sqlstm_label); } should_delete_flag=1; in_exception_flag=0; in_destruct_flag=0; dirty=0; auto_commit_flag=1; flush_flag=true; flush_flag2=true; lob_stream_mode=alob_stream_mode; this->cursor_struct.reset_last_param_data_token(); this->cursor_struct.reset_last_sql_param_data_status(); this->cursor_struct.reset_sql_param_data_count(); cur_x=-1; cur_y=0; this->stm_text=0; } virtual ~otl_tmpl_out_stream() {in_destruct_flag=1; this->in_destructor=1; if(dirty&&!in_exception_flag&& flush_flag&&flush_flag2) flush(); cleanup(); in_destruct_flag=0; } void reset_to_last_valid_row() { if(cur_y>0){ --cur_y; this->in_exception_flag=0; cur_x=this->vl_len-1; } } virtual void flush(const int rowoff=0,const bool force_flush=false) {int i,rc; this->_rpc=0; if(!dirty)return; if(!flush_flag2)return; if(force_flush){ if(rowoff>cur_y){ clean(); return; } int temp_rc; OTL_TRACE_STREAM_EXECUTION2 this->exec(OTL_SCAST(otl_stream_buffer_size_type,(cur_y+1)), rowoff, otl_sql_exec_from_cursor_class); for(i=0;ivl_len;++i){ temp_rc=this->vl[i]->get_var_struct().put_blob(); if(temp_rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } } if(auto_commit_flag) this->adb->commit(); clean(); return; } #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) if(otl_uncaught_exception()){ clean(); return; } #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) if(otl_uncaught_exception()){ clean(); return; } #endif if(this->retcode==0||this->adb->get_retcode()==0){ clean(); return; } if(cur_x!=this->vl_len-1){ in_exception_flag=1; if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) if( otl_uncaught_exception()){ clean(); return; } #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) if(otl_uncaught_exception()){ clean(); return; } #endif throw OTL_TMPL_EXCEPTION (otl_error_msg_3, otl_error_code_3, this->stm_label?this->stm_label: this->stm_text, 0); } if(in_destruct_flag){ OTL_TRACE_STREAM_EXECUTION2 this->retcode=this->cursor_struct.exec (cur_y+1, rowoff, otl_sql_exec_from_cursor_class); for(i=0;ivl_len;++i){ rc=this->vl[i]->get_var_struct().put_blob(); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } } if(!this->retcode){ clean(); in_exception_flag=1; if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (this->cursor_struct, this->stm_label?this->stm_label: this->stm_text); } if(auto_commit_flag){ this->adb->set_retcode(this->adb->get_connect_struct().commit()); if(!this->adb->get_retcode()){ clean(); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } } }else{ int temp_rc; OTL_TRACE_STREAM_EXECUTION2 this->exec(OTL_SCAST(otl_stream_buffer_size_type,(cur_y+1)), rowoff, otl_sql_exec_from_cursor_class); for(i=0;ivl_len;++i){ temp_rc=this->vl[i]->get_var_struct().put_blob(); if(temp_rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } } if(auto_commit_flag) this->adb->commit(); if(rowoff>0) clean(); else clean(0); } } virtual void clean(const int clean_up_error_flag=0) { if(clean_up_error_flag){ this->retcode=1; this->in_exception_flag=0; } if(!dirty)return; cur_x=-1; cur_y=0; dirty=0; } void set_commit(int auto_commit=0) { auto_commit_flag=auto_commit; } void get_next(void) { if(cur_xvl_len-1) ++cur_x; else{ if(cur_yvl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), type_code, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw OTL_TMPL_EXCEPTION (otl_error_msg_0, otl_error_code_0, this->stm_label?this->stm_label: this->stm_text, var_info); } int check_type(int type_code, int tsize) { switch(this->vl[cur_x]->get_ftype()){ case otl_var_char: if(type_code==otl_var_char)return 1; case otl_var_db2time: case otl_var_tz_timestamp: case otl_var_ltz_timestamp: case otl_var_db2date: if(type_code==otl_var_timestamp)return 1; case otl_var_refcur: if(type_code==otl_var_refcur)return 1; default: if(this->vl[cur_x]->get_ftype()==type_code && this->vl[cur_x]->get_elem_size()==tsize) return 1; } return check_type_throw(type_code); } void check_buf(void) { if(cur_x==this->vl_len-1 && cur_y==array_size-1) flush(); } OTL_TMPL_OUT_STREAM& operator<<(const char c) { if(this->vl_len>0){ get_next(); if(check_type(otl_var_char,1)){ char* tmp=OTL_RCAST(char*,this->vl[cur_x]->val(cur_y)); tmp[0]=c; tmp[1]=0; this->vl[cur_x]->set_not_null(cur_y); } check_buf(); } return *this; } OTL_TMPL_OUT_STREAM& operator<<(const unsigned char c) { if(this->vl_len>0){ get_next(); if(check_type(otl_var_char,1)){ unsigned char* tmp=OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y)); tmp[0]=c; tmp[1]=0; this->vl[cur_x]->set_not_null(cur_y); } check_buf(); } return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) OTL_TMPL_OUT_STREAM& operator<<(const OTL_STRING_CONTAINER& s) { if(this->vl_len>0){ get_next(); switch(this->vl[cur_x]->get_ftype()){ case otl_var_char: { int overflow; otl_strcpy (OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y)), OTL_RCAST(unsigned char*,OTL_CCAST(char*,s.c_str())), overflow, this->vl[cur_x]->get_elem_size(), OTL_SCAST(int,s.length())); if(overflow){ otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_char, var_info, sizeof(var_info)); in_exception_flag=1; if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_4, otl_error_code_4, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_x]->set_not_null(cur_y); } break; #if defined(OTL_USER_DEFINED_STRING_CLASS_ON) || \ defined(OTL_STL) || defined(OTL_ACE) case otl_var_varchar_long: case otl_var_raw_long: { unsigned char* c=OTL_RCAST(unsigned char*, this->vl[cur_x]->val(cur_y)); int len=OTL_SCAST(int,s.length()); this->vl[cur_x]->set_not_null(cur_y); if(len>this->vl[cur_x]->actual_elem_size()){ otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_char, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } otl_memcpy(c, OTL_RCAST(unsigned char*, OTL_CCAST(char*,s.c_str())), len, this->vl[cur_x]->get_ftype()); this->vl[cur_x]->set_len(len,cur_y); } break; case otl_var_blob: case otl_var_clob: { int len=OTL_SCAST(int,s.length()); if(len>this->vl[cur_x]->actual_elem_size()){ otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_char, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_x]->set_not_null(cur_y); this->vl[cur_x]->get_var_struct().save_blob (OTL_RCAST(unsigned char*,OTL_CCAST(char*,s.c_str())),len,0); } break; #endif default: check_type(otl_var_char,1); } // switch check_buf(); } return *this; } #endif #if defined(OTL_UNICODE_STRING_TYPE) OTL_TMPL_OUT_STREAM& operator<<(const OTL_UNICODE_STRING_TYPE& s) { if(this->vl_len>0){ get_next(); switch(this->vl[cur_x]->get_ftype()){ case otl_var_char: { int overflow; otl_strcpy4 (OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y)), OTL_RCAST(unsigned char*, OTL_CCAST(OTL_UNICODE_CHAR_TYPE*,s.c_str())), overflow, this->vl[cur_x]->get_elem_size(), OTL_SCAST(int,s.length()) ); if(overflow){ otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_char, var_info, sizeof(var_info)); in_exception_flag=1; if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_4, otl_error_code_4, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_x]->set_not_null(cur_y); break; } case otl_var_varchar_long: { unsigned char* c=OTL_RCAST(unsigned char*, this->vl[cur_x]->val(cur_y)); int len=OTL_SCAST(int,s.length()); this->vl[cur_x]->set_not_null(cur_y); if(len>this->vl[cur_x]->actual_elem_size()){ otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_char, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } otl_memcpy(c, OTL_RCAST(unsigned char*, OTL_CCAST(OTL_UNICODE_CHAR_TYPE*,s.c_str())), len, this->vl[cur_x]->get_ftype()); this->vl[cur_x]->set_len(len,cur_y); break; } case otl_var_clob: { int len=OTL_SCAST(int,s.length()); if(len>this->vl[cur_x]->actual_elem_size()){ otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_char, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_x]->set_not_null(cur_y); this->vl[cur_x]->get_var_struct().save_blob (OTL_RCAST(const unsigned char*,s.c_str()), len, 0); } break; default: check_type(otl_var_char,1); } check_buf(); } return *this; } #endif OTL_TMPL_OUT_STREAM& operator<<(const char* s) { if(this->vl_len>0){ get_next(); if(check_type(otl_var_char,1)){ int overflow; otl_strcpy (OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y)), OTL_RCAST(unsigned char*,OTL_CCAST(char*,s)), overflow, this->vl[cur_x]->get_elem_size() ); if(overflow){ otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_char, var_info, sizeof(var_info)); in_exception_flag=1; if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_4, otl_error_code_4, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_x]->set_not_null(cur_y); } check_buf(); } return *this; } OTL_TMPL_OUT_STREAM& operator<<(const unsigned char* s) { if(this->vl_len>0){ get_next(); if(check_type(otl_var_char,1)){ int overflow; otl_strcpy4 (OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y)), OTL_CCAST(unsigned char*,s), overflow, this->vl[cur_x]->get_elem_size() ); if(overflow){ otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_char, var_info, sizeof(var_info)); in_exception_flag=1; if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_4, otl_error_code_4, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_x]->set_not_null(cur_y); } check_buf(); } return *this; } #define OTL_D3(T,T_type) \ OTL_TMPL_OUT_STREAM& operator<<(const T n) \ { \ if(this->vl_len>0){ \ get_next(); \ if(check_type(T_type,sizeof(T))){ \ *OTL_RCAST(T*,this->vl[cur_x]->val(cur_y))=n; \ this->vl[cur_x]->set_not_null(cur_y); \ } \ check_buf(); \ } \ return *this; \ } #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) OTL_D3(int,otl_var_int) #if defined(OTL_BIGINT) OTL_D3(OTL_BIGINT,otl_var_bigint) #endif OTL_D3(unsigned,otl_var_unsigned_int) OTL_D3(long,otl_var_long_int) OTL_D3(short,otl_var_short) OTL_D3(float,otl_var_float) OTL_D3(double,otl_var_double) #else template OTL_D3(T,T_type) #endif #if defined(OTL_PL_TAB) OTL_TMPL_OUT_STREAM& operator<<(otl_pl_tab_generic& tab) { if(this->vl_len>0){ get_next(); if(check_type(tab.get_vtype(),tab.get_elem_size())){ int i,tmp_len; if(tab.len()<=this->vl[cur_x]->get_array_size()) tmp_len=tab.len(); else tmp_len=this->vl[cur_x]->get_array_size(); this->vl[cur_x]->set_pl_tab_len(tmp_len); if(tab.get_vtype()==otl_var_char){ int i2; for(i2=0;i2vl[cur_x]->val(i2)), OTL_RCAST(unsigned char*,tab.val(i2)), overflow, this->vl[cur_x]->get_elem_size() ); if(overflow){ char tmp_var_info[256]; otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_char, tmp_var_info, sizeof(tmp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_4, otl_error_code_4, this->stm_label?this->stm_label: this->stm_text, tmp_var_info); } } }else if(tab.get_vtype()==otl_var_timestamp){ otl_datetime* ext_dt=OTL_RCAST(otl_datetime*,tab.get_p_v()); otl_oracle_date* int_dt=OTL_RCAST(otl_oracle_date*, this->vl[cur_x]->val()); int j; for(j=0;jvl[cur_x]->val()), OTL_RCAST(char*,tab.val()), tab.get_elem_size()*tmp_len); for(i=0;ivl[cur_x]->set_null(i); else this->vl[cur_x]->set_not_null(i); } } check_buf(); } return *this; } #endif #if defined(OTL_PL_TAB) && defined(OTL_STL) OTL_TMPL_OUT_STREAM& operator<<(otl_pl_vec_generic& vec) { if(this->vl_len>0){ get_next(); if(check_type(vec.get_vtype(),vec.get_elem_size())){ int i,tmp_len; if(vec.len()<=this->vl[cur_x]->get_array_size()) tmp_len=vec.len(); else tmp_len=this->vl[cur_x]->get_array_size(); this->vl[cur_x]->set_pl_tab_len(tmp_len); switch(vec.get_vtype()){ case otl_var_char: int i2; for(i2=0;i2vl[cur_x]->val(i2)), OTL_RCAST(unsigned char*, OTL_CCAST(char*,(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[i2].c_str())), overflow, this->vl[cur_x]->get_elem_size(), OTL_SCAST(int,(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[i2].length()) ); if(overflow){ char temp_var_info[256]; otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_4, otl_error_code_4, this->stm_label?this->stm_label: this->stm_text, temp_var_info); } } break; case otl_var_timestamp: { otl_oracle_date* int_dt=OTL_RCAST(otl_oracle_date*,this->vl[cur_x]->val()); int j; otl_datetime* ext_dt; for(j=0;j*, vec.get_p_v()))[j]); convert_date(*int_dt,*ext_dt); ++int_dt; } } break; case otl_var_int: if(tmp_len>0) memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()), OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), sizeof(int)*tmp_len); break; case otl_var_double: if(tmp_len>0) memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()), OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), sizeof(double)*tmp_len); break; case otl_var_float: if(tmp_len>0) memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()), OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), sizeof(float)*tmp_len); break; case otl_var_unsigned_int: if(tmp_len>0) memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()), OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), sizeof(unsigned)*tmp_len); break; case otl_var_short: if(tmp_len>0) memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()), OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), sizeof(short)*tmp_len); break; case otl_var_long_int: if(tmp_len>0) memcpy(OTL_RCAST(char*,this->vl[cur_x]->val()), OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), sizeof(long int)*tmp_len); break; } for(i=0;ivl[cur_x]->set_null(i); else this->vl[cur_x]->set_not_null(i); } } check_buf(); } return *this; } #endif OTL_TMPL_OUT_STREAM& operator<<(const otl_null& /* n */) { if(this->vl_len>0){ get_next(); this->vl[cur_x]->set_null(cur_y); check_buf(); } return *this; } OTL_TMPL_OUT_STREAM& operator<<(const TTimestampStruct& t) { if(this->vl_len>0){ get_next(); if(check_type(otl_var_timestamp,sizeof(TTimestampStruct))){ TTimestampStruct* tm= OTL_RCAST(TTimestampStruct*,this->vl[cur_x]->val(cur_y)); this->vl[cur_x]->set_not_null(cur_y); int rc=this->vl[cur_x]->get_var_struct().write_dt (tm,&t,sizeof(TTimestampStruct)); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } } check_buf(); } return *this; } OTL_TMPL_OUT_STREAM& operator<<(const otl_long_string& s) { if(this->vl_len>0){ get_next(); switch(this->vl[cur_x]->get_ftype()){ case otl_var_varchar_long: case otl_var_raw_long: case otl_var_raw: { unsigned char* c=OTL_RCAST(unsigned char*,this->vl[cur_x]->val(cur_y)); int len=OTL_CCAST(otl_long_string*,&s)->len(); this->vl[cur_x]->set_not_null(cur_y); if(len>this->vl[cur_x]->actual_elem_size()){ otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_long_string, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } if((this->vl[cur_x]->get_var_struct().get_otl_adapter()==otl_ora7_adapter|| this->vl[cur_x]->get_var_struct().get_otl_adapter()==otl_ora8_adapter) && this->vl[cur_x]->get_ftype()==otl_var_raw){ otl_memcpy (c+sizeof(unsigned short), s.v, len, this->vl[cur_x]->get_ftype()); *OTL_RCAST(unsigned short*, this->vl[cur_x]->val(cur_y))=OTL_SCAST(unsigned short,len); this->vl[cur_x]->set_len(len,cur_y); }else{ otl_memcpy(c,s.v,len,this->vl[cur_x]->get_ftype()); this->vl[cur_x]->set_len(len,cur_y); } } break; case otl_var_blob: case otl_var_clob: { int len=OTL_CCAST(otl_long_string*,&s)->len(); if(len>this->vl[cur_x]->actual_elem_size()){ otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_long_string, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_x]->set_not_null(cur_y); this->vl[cur_x]->get_var_struct().save_blob (s.v,len,s.get_extern_buffer_flag()); } break; } check_buf(); } return *this; } #if defined(OTL_ORA8)||defined(OTL_ODBC) #define OTL_TMPL_CUR_DUMMY OTL_TMPL_CURSOR OTL_TMPL_OUT_STREAM& operator<< (otl_lob_stream_generic& s) { if(this->vl_len>0){ get_next(); if(((s.get_ora_lob() && this->vl[cur_x]->get_ftype()==otl_var_blob)|| this->vl[cur_x]->get_ftype()==otl_var_clob)|| (this->vl[cur_x]->get_ftype()==otl_var_varchar_long|| this->vl[cur_x]->get_ftype()==otl_var_raw_long)){ s.init (this->vl[cur_x], this->adb, OTL_RCAST(OTL_TMPL_CUR_DUMMY*,this), 0, otl_lob_stream_write_mode); if(!s.get_ora_lob()) this->vl[cur_x]->set_not_null(cur_y); } check_buf(); }else{ char temp_var_info[256]; otl_var_info_var (this->vl[cur_x]->get_name(), this->vl[cur_x]->get_ftype(), otl_var_long_string, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_0, otl_error_code_0, this->stm_label?this->stm_label: this->stm_text, temp_var_info); } return *this; } #undef OTL_TMPL_CUR_DUMMY #endif otl_tmpl_out_stream(): OTL_TMPL_CURSOR(), auto_commit_flag(0), dirty(0), cur_x(0), cur_y(0), array_size(0), in_exception_flag(0), in_destruct_flag(0), should_delete_flag(0), var_info(), flush_flag(0), flush_flag2(0), lob_stream_mode(0), master_stream_ptr_(0) { } private: otl_tmpl_out_stream (const otl_tmpl_out_stream&): OTL_TMPL_CURSOR(), auto_commit_flag(0), dirty(0), cur_x(0), cur_y(0), array_size(0), in_exception_flag(0), in_destruct_flag(0), should_delete_flag(0), var_info(), flush_flag(0), flush_flag2(0), lob_stream_mode(0), master_stream_ptr_(0) { } otl_tmpl_out_stream& operator= (const otl_tmpl_out_stream&) { return *this; } }; template class otl_tmpl_inout_stream: public OTL_TMPL_OUT_STREAM{ protected: otl_tmpl_variable** in_vl; int iv_len; int cur_in_x; int cur_in_y; int in_y_len; int null_fetched; otl_tmpl_variable** avl; int avl_len; char var_info[256]; public: int get_iv_len() const {return iv_len;} otl_tmpl_variable** get_in_vl(){return in_vl;} void cleanup(void) {int i; for(i=0;idirty=0; this->auto_commit_flag=1; this->adb=&pdb; this->in_exception_flag=0; this->stm_text=0; this->array_size=arr_size; this->should_delete_flag=0; { size_t len=strlen(sqlstm)+1; this->stm_text=new char[len]; OTL_STRCPY_S(this->stm_text,len,sqlstm); otl_tmpl_ext_hv_decl hvd(this->stm_text,arr_size); if(hvd.has_plsql_tabs_or_refcur() && arr_size>1){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (otl_error_msg_33, otl_error_code_33, this->stm_label?this->stm_label: this->stm_text); } if(hvd.get_vst(otl_tmpl_ext_hv_decl ::def)==hvd.get_len()){ this->should_delete_flag=1; hvd.alloc_host_var_list(this->vl,this->vl_len,pdb); }else{ for(i=0;i::in) ++this->vl_len; else if(hvd.get_inout(i)== otl_tmpl_ext_hv_decl ::out) ++iv_len; else if(hvd.get_inout(i)== otl_tmpl_ext_hv_decl ::io){ ++this->vl_len; ++iv_len; } } if(this->vl_len>0){ this->vl=new otl_tmpl_variable*[this->vl_len]; } if(iv_len>0){ in_vl=new otl_tmpl_variable*[iv_len]; } if(hvd.get_len()>0){ avl=new otl_tmpl_variable*[hvd.get_len()]; } iv_len=0; this->vl_len=0; avl_len=hvd.get_len(); for(j=0;j32767){ char tmp_var_info[256]; otl_var_info_var (hvd[j], otl_var_none, otl_var_none, tmp_var_info, sizeof(tmp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (otl_error_msg_6, otl_error_code_6, this->stm_label?this->stm_label: this->stm_text, tmp_var_info); } #endif otl_tmpl_variable* v=hvd.alloc_var (hvd[j], hvd.get_inout(j), otl_tmpl_ext_hv_decl ::def, pdb, hvd.get_pl_tab_size(j)); if(v==0){ int k; for(k=0;kvl_len=0; throw OTL_TMPL_EXCEPTION (otl_error_msg_12, otl_error_code_12, hvd.stm_label()?hvd.stm_label():hvd.stm_text(), hvd[j]); } v->set_name_pos(j+1); avl[j]=v; if(hvd.get_inout(j)== otl_tmpl_ext_hv_decl ::in){ ++this->vl_len; this->vl[this->vl_len-1]=v; v->set_param_type(otl_input_param); }else if(hvd.get_inout(j)== otl_tmpl_ext_hv_decl ::out){ ++iv_len; in_vl[iv_len-1]=v; v->set_param_type(otl_output_param); }else if(hvd.get_inout(j)== otl_tmpl_ext_hv_decl ::io){ ++this->vl_len; ++iv_len; this->vl[this->vl_len-1]=v; in_vl[iv_len-1]=v; v->set_param_type(otl_inout_param); } } } } try{ this->parse(); for(i=0;ivl_len;++i){ if(this->vl[i]->get_var_struct().get_otl_adapter()==otl_odbc_adapter){ this->vl[i]->get_var_struct().set_lob_stream_mode(this->lob_stream_mode); this->vl[i]->get_var_struct().set_vparam_type(this->vl[i]->get_param_type()); if(this->vl[i]->get_ftype()==otl_var_varchar_long|| this->vl[i]->get_ftype()==otl_var_raw_long){ this->vl[i]->set_not_null(0); } } this->bind(*(this->vl[i])); } for(j=0;jbind(*in_vl[j]); rewind(); }catch(OTL_CONST_EXCEPTION OTL_TMPL_EXCEPTION&){ cleanup(); if(this->adb)this->adb->increment_throw_count(); throw; } } virtual ~otl_tmpl_inout_stream() {this->in_destructor=1; if(!this->in_exception_flag) flush(); cleanup(); } int eof(void) { if(iv_len==0)return 1; if(in_y_len==0)return 1; if(cur_in_y<=in_y_len-1)return 0; return 1; } void flush(const int rowoff=0, const bool force_flush=false) { if(this->vl_len==0)return; in_y_len=this->cur_y+1; cur_in_y=0; cur_in_x=0; if(!this->in_exception_flag) OTL_TMPL_OUT_STREAM::flush(rowoff,force_flush); } void clean(const int clean_up_error_flag=0) { if(this->vl_len!=0) { in_y_len=this->cur_y+1; cur_in_y=0; cur_in_x=0; } OTL_TMPL_OUT_STREAM::clean(clean_up_error_flag); } void rewind(void) { flush(); cur_in_x=0; cur_in_y=0; this->cur_x=-1; this->cur_y=0; in_y_len=0; null_fetched=0; if(this->vl_len==0){ this->exec(this->array_size,0,otl_sql_exec_from_cursor_class); in_y_len=this->array_size; cur_in_y=0; cur_in_x=0; } } int is_null(void) { return null_fetched; } void skip_to_end_of_row() { if(eof())return; if(iv_len==0)return; if(in_y_len==0)return; if(cur_in_yin_exception_flag=1; otl_var_info_var (in_vl[cur_in_x]->get_name(), in_vl[cur_in_x]->get_ftype(), type_code, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw OTL_TMPL_EXCEPTION (otl_error_msg_0, otl_error_code_0, this->stm_label?this->stm_label: this->stm_text, var_info); } int check_in_type(int type_code,int tsize) { switch(in_vl[cur_in_x]->get_ftype()){ case otl_var_refcur: if(type_code==otl_var_refcur) return 1; case otl_var_db2time: case otl_var_db2date: if(type_code==otl_var_timestamp) return 1; case otl_var_char: if(type_code==otl_var_char) return 1; default: if(in_vl[cur_in_x]->get_ftype()==type_code && in_vl[cur_in_x]->get_elem_size()==tsize) return 1; } return check_in_type_throw(type_code); } int is_null_intern(void) { if(iv_len==0)return 0; if(in_y_len==0)return 0; if(in_y_len>0) return in_vl[cur_in_x]->is_null(cur_in_y); return 0; } OTL_TMPL_INOUT_STREAM& operator>>(char& c) { if(eof())return *this; if(check_in_type(otl_var_char,1)){ c=*OTL_RCAST(char*,in_vl[cur_in_x]->val(cur_in_y)); null_fetched=is_null_intern(); } get_in_next(); return *this; } OTL_TMPL_INOUT_STREAM& operator>>(unsigned char& c) { if(eof())return *this; if(check_in_type(otl_var_char,1)){ c=*OTL_RCAST(unsigned char*,in_vl[cur_in_x]->val(cur_in_y)); null_fetched=is_null_intern(); } get_in_next(); return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) OTL_TMPL_INOUT_STREAM& operator>>(OTL_STRING_CONTAINER& s) { if(eof())return *this; switch(in_vl[cur_in_x]->get_ftype()){ case otl_var_char: { #if defined(OTL_ACE) s.set(OTL_RCAST(char*,in_vl[cur_in_x]->val(cur_in_y)),1); #else s=OTL_RCAST(char*,in_vl[cur_in_x]->val(cur_in_y)); #endif null_fetched=is_null_intern(); } break; #if defined(USER_DEFINED_STRING_CLASS) || \ defined(OTL_STL) || defined(OTL_ACE) case otl_var_varchar_long: case otl_var_raw_long: { unsigned char* c= OTL_RCAST(unsigned char*,in_vl[cur_in_x]->val(cur_in_y)); int len=in_vl[cur_in_x]->get_len(); #if (defined(USER_DEFINED_STRING_CLASS) || defined(OTL_STL)) && !defined(OTL_ACE) s.assign(OTL_RCAST(char*,c),len); #elif defined(OTL_ACE) s.set(OTL_RCAST(char*,c),len,1); #endif null_fetched=is_null_intern(); } break; case otl_var_blob: case otl_var_clob: { int len=0; int max_long_sz=this->adb->get_max_long_size(); otl_auto_array_ptr loc_ptr(max_long_sz); unsigned char* temp_buf=loc_ptr.get_ptr(); int rc=in_vl[cur_in_x]->get_var_struct().get_blob (cur_in_y, temp_buf, max_long_sz, len); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } #if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE) s.assign(OTL_RCAST(char*,temp_buf),len); #elif defined(OTL_ACE) s.set(OTL_RCAST(char*,temp_buf),len,1); #endif null_fetched=is_null_intern(); } break; #endif default: check_in_type(otl_var_char,1); } // switch get_in_next(); return *this; } #endif OTL_TMPL_INOUT_STREAM& operator>>(char* s) { if(eof())return *this; if(check_in_type(otl_var_char,1)){ otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,in_vl[cur_in_x]->val(cur_in_y))); null_fetched=is_null_intern(); } get_in_next(); return *this; } #if defined(OTL_UNICODE_STRING_TYPE) OTL_TMPL_INOUT_STREAM& operator>>(OTL_UNICODE_STRING_TYPE& s) { if(eof())return *this; if(check_in_type(otl_var_char,1)){ #if defined(OTL_ODBC) || defined(DB2_CLI) s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,in_vl[cur_in_x]->val(cur_in_y)); #else #if defined(OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR) OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST (OTL_UNICODE_CHAR_TYPE*,in_vl[cur_in_x]->val(cur_in_y)); OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR(s,temp_s+1,*temp_s); #else OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST (OTL_UNICODE_CHAR_TYPE*,in_vl[cur_in_x]->val(cur_in_y)); s.assign(temp_s+1,*temp_s); #endif #endif null_fetched=is_null_intern(); } get_in_next(); return *this; } #endif OTL_TMPL_INOUT_STREAM& operator>>(unsigned char* s) { if(eof())return *this; if(check_in_type(otl_var_char,1)){ otl_strcpy2(OTL_RCAST(unsigned char*,s), OTL_RCAST(unsigned char*,in_vl[cur_in_x]->val(cur_in_y)), in_vl[cur_in_x]->get_len(cur_in_y) ); null_fetched=is_null_intern(); } get_in_next(); return *this; } #define OTL_D4(T,T_type) \ OTL_TMPL_INOUT_STREAM& operator>>(T& n) \ { \ if(eof())return *this; \ if(check_in_type(T_type,sizeof(T))){ \ n=*OTL_RCAST(T*,in_vl[cur_in_x]->val(cur_in_y)); \ null_fetched=is_null_intern(); \ } \ get_in_next(); \ return *this; \ } #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) OTL_D4(int,otl_var_int) OTL_D4(unsigned,otl_var_unsigned_int) #if defined(OTL_BIGINT) OTL_D4(OTL_BIGINT,otl_var_bigint) #endif OTL_D4(long,otl_var_long_int) OTL_D4(short,otl_var_short) OTL_D4(float,otl_var_float) OTL_D4(double,otl_var_double) #else template OTL_D4(T,T_type) #endif #if defined(OTL_PL_TAB) OTL_TMPL_INOUT_STREAM& operator>>(otl_pl_tab_generic& tab) { if(eof())return *this; if(check_in_type(tab.get_vtype(),tab.get_elem_size())){ int i,tmp_len; tmp_len=in_vl[cur_in_x]->get_pl_tab_len(); if(tab.get_tab_size()val(i)), in_vl[cur_in_x]->get_len(i), overflow, tab.get_elem_size() ); } }else if(tab.get_vtype()==otl_var_timestamp){ otl_datetime* ext_dt=OTL_RCAST(otl_datetime*,tab.get_p_v()); otl_oracle_date* int_dt= OTL_RCAST(otl_oracle_date*,in_vl[cur_in_x]->val()); int j; for(j=0;jval()), tab.get_elem_size()*tmp_len); for(i=0;iis_null(i)) tab.set_null(i); else tab.set_non_null(i); } null_fetched=0; } get_in_next(); return *this; } #endif #if defined(OTL_PL_TAB) && defined(OTL_STL) OTL_TMPL_INOUT_STREAM& operator>>(otl_pl_vec_generic& vec) { if(eof())return *this; if(check_in_type(vec.get_vtype(),vec.get_elem_size())){ int i,tmp_len; tmp_len=in_vl[cur_in_x]->get_pl_tab_len(); vec.set_len(tmp_len); if(tmp_len>0){ switch(vec.get_vtype()){ case otl_var_char: for(i=0;i*,vec.get_p_v()))[i]= OTL_RCAST(char*,in_vl[cur_in_x]->val(i)); } break; case otl_var_timestamp: { otl_datetime* ext_dt; otl_oracle_date* int_dt= OTL_RCAST(otl_oracle_date*,in_vl[cur_in_x]->val()); int j; for(j=0;j*,vec.get_p_v()))[j]); convert_date(*ext_dt,*int_dt); ++int_dt; } } break; case otl_var_int: memcpy(OTL_RCAST (char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*,vec.get_p_v()))[0]), OTL_RCAST(char*,in_vl[cur_in_x]->val()), sizeof(int)*tmp_len); break; case otl_var_double: memcpy(OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), OTL_RCAST(char*,in_vl[cur_in_x]->val()), sizeof(double)*tmp_len); break; case otl_var_float: memcpy(OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), OTL_RCAST(char*,in_vl[cur_in_x]->val()), sizeof(float)*tmp_len); break; case otl_var_unsigned_int: memcpy(OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), OTL_RCAST(char*,in_vl[cur_in_x]->val()), sizeof(unsigned)*tmp_len); break; case otl_var_short: memcpy(OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), OTL_RCAST(char*,in_vl[cur_in_x]->val()), sizeof(short)*tmp_len); break; case otl_var_long_int: memcpy(OTL_RCAST(char*, &(*OTL_RCAST(STD_NAMESPACE_PREFIX vector*, vec.get_p_v()))[0]), OTL_RCAST(char*,in_vl[cur_in_x]->val()), sizeof(long int)*tmp_len); break; } } for(i=0;iis_null(i)) vec.set_null(i); else vec.set_non_null(i); } null_fetched=0; } get_in_next(); return *this; } #endif OTL_TMPL_INOUT_STREAM& operator>>(TTimestampStruct& t) { if(eof())return *this; if(check_in_type(otl_var_timestamp,sizeof(TTimestampStruct))){ TTimestampStruct* tm= OTL_RCAST(TTimestampStruct*,in_vl[cur_in_x]->val(cur_in_y)); int rc=in_vl[cur_in_x]->get_var_struct().read_dt (&t,tm,sizeof(TTimestampStruct)); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } null_fetched=is_null_intern(); } get_in_next(); return *this; } OTL_TMPL_INOUT_STREAM& operator>>(otl_long_string& s) { int len=0; if(eof())return *this; switch(in_vl[cur_in_x]->get_ftype()){ case otl_var_raw: case otl_var_varchar_long: case otl_var_raw_long: { unsigned char* c=OTL_RCAST(unsigned char*,in_vl[cur_in_x]->val(cur_in_y)); len=in_vl[cur_in_x]->get_len(); if(len>s.get_buf_size()) len=s.get_buf_size(); otl_memcpy(s.v,c,len,in_vl[cur_in_x]->get_ftype()); s.set_len(len); if(in_vl[cur_in_x]->get_ftype()==otl_var_varchar_long) s.null_terminate_string(len); null_fetched=is_null_intern(); } break; case otl_var_clob: case otl_var_blob: { int rc=in_vl[cur_in_x]->get_var_struct().get_blob (cur_in_y,s.v,s.get_buf_size(),len); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } if(len>s.get_buf_size()) len=s.get_buf_size(); s.set_len(len); if(in_vl[cur_in_x]->get_ftype()==otl_var_clob) s.null_terminate_string(len); null_fetched=is_null_intern(); } break; default: { char temp_var_info[256]; otl_var_info_var (in_vl[cur_in_x]->get_name(), in_vl[cur_in_x]->get_ftype(), otl_var_long_string, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_0, otl_error_code_0, this->stm_label?this->stm_label: this->stm_text, temp_var_info); } } get_in_next(); return *this; } #if defined(OTL_ORA8)||defined(OTL_ODBC) OTL_TMPL_INOUT_STREAM& operator>> (otl_lob_stream_generic& s) { if(eof())return *this; if((s.get_ora_lob() && in_vl[cur_in_x]->get_ftype()==otl_var_clob)|| in_vl[cur_in_x]->get_ftype()==otl_var_blob){ null_fetched=is_null_intern(); s.init (OTL_RCAST(void*,in_vl[cur_in_x]), OTL_RCAST(void*,this->adb), OTL_RCAST(void*,this), 0, otl_lob_stream_read_mode, this->is_null()); }else if(in_vl[cur_in_x]->get_ftype()==otl_var_varchar_long|| in_vl[cur_in_x]->get_ftype()==otl_var_raw_long){ s.init (OTL_RCAST(void*,in_vl[cur_in_x]), OTL_RCAST(void*,this->adb), OTL_RCAST(void*,this), 0, otl_lob_stream_read_mode); }else{ char tmp_var_info[256]; otl_var_info_var (in_vl[cur_in_x]->get_name(), in_vl[cur_in_x]->get_ftype(), otl_var_long_string, tmp_var_info, sizeof(tmp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_0, otl_error_code_0, this->stm_label?this->stm_label: this->stm_text, tmp_var_info); } get_in_next(); return *this; } #endif otl_tmpl_inout_stream(): OTL_TMPL_OUT_STREAM(), in_vl(0), iv_len(0), cur_in_x(0), cur_in_y(0), in_y_len(0), null_fetched(0), avl(0), avl_len(0), var_info() { } private: otl_tmpl_inout_stream (const otl_tmpl_inout_stream&): OTL_TMPL_OUT_STREAM(), in_vl(0), iv_len(0), cur_in_x(0), cur_in_y(0), in_y_len(0), null_fetched(0), avl(0), avl_len(0), var_info() { } otl_tmpl_inout_stream& operator=(const otl_tmpl_inout_stream&) { return *this; } }; // ==================== OTL-Adapter for ODBC/CLI ========================= #if defined(OTL_ODBC) #if !defined(OTL_DB2_CLI) && !defined(OTL_ODBC_zOS) // in case if it's ODBC for Windows (!OTL_ODBC_UNIX), and windows.h is // not included yet (_WINDOWS_ not defined yet), then include the file // explicitly #if !defined(OTL_ODBC_UNIX) && !defined(_WINDOWS_) #include #endif #if defined(OTL_ODBC_UNIX) && defined(OTL_INFORMIX_CLI) #include #define OTL_HENV SQLHANDLE #define OTL_HDBC SQLHANDLE #define OTL_SQLHANDLE SQLHANDLE #define OTL_SQLRETURN SQLRETURN #define OTL_SQLSMALLINT SQLSMALLINT #define OTL_SQLCHAR_PTR SQLCHAR* #define OTL_SQLINTEGER_PTR SQLINTEGER* #define OTL_SQLSMALLINT_PTR SQLSMALLINT* #define OTL_SQLINTEGER SQLINTEGER #define OTL_SQLHSTMT SQLHSTMT #define OTL_SQLUSMALLINT SQLUSMALLINT #define OTL_SQLPOINTER SQLPOINTER #define OTL_SQLCHAR SQLCHAR #define OTL_SQLUINTEGER SQLUINTEGER #define OTL_SQLLEN SQLINTEGER #define OTL_SQLLEN_PTR SQLINTEGER* #define OTL_SQLULEN SQLUINTEGER #define OTL_SQLULEN_PTR SQLUINTEGER* #else #include #include #endif #else #include #endif #if defined(OTL_ODBC) && !defined(OTL_DB2_CLI) #define OTL_SQL_XML (-152) #endif #if defined(OTL_ODBC) && defined(OTL_DB2_CLI) #if defined(SQL_XML) #define OTL_SQL_XML SQL_XML #else #define OTL_SQL_XML (-370) #endif #endif #if defined(OTL_ODBC) #if (ODBCVER >= 0x0300) #define OTL_SQL_TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT #define OTL_SQL_TIME_STRUCT SQL_TIME_STRUCT #define OTL_SQL_DATE_STRUCT SQL_DATE_STRUCT #else #define OTL_SQL_TIMESTAMP_STRUCT TIMESTAMP_STRUCT #define OTL_SQL_TIME_STRUCT TIME_STRUCT #define OTL_SQL_DATE_STRUCT DATE_STRUCT #endif #if defined(OTL_DB2_CLI) #define OTL_HENV SQLHANDLE #define OTL_HDBC SQLHANDLE #define OTL_SQLHANDLE SQLHANDLE #define OTL_SQLRETURN SQLRETURN #define OTL_SQLSMALLINT SQLSMALLINT #define OTL_SQLCHAR_PTR SQLCHAR* #define OTL_SQLINTEGER_PTR SQLINTEGER* #define OTL_SQLSMALLINT_PTR SQLSMALLINT* #define OTL_SQLINTEGER SQLINTEGER #define OTL_SQLHSTMT SQLHSTMT #define OTL_SQLUSMALLINT SQLUSMALLINT #define OTL_SQLPOINTER SQLPOINTER #define OTL_SQLCHAR SQLCHAR #define OTL_SQLUINTEGER SQLUINTEGER #if defined(OTL_IODBC_BSD) #define OTL_SQLLEN SQLLEN #define OTL_SQLULEN SQLULEN #define OTL_SQLULEN_PTR SQLULEN* #define OTL_SQLLEN_PTR SQLLEN* #else // #if defined(OTL_IODBC_BSD) #define OTL_SQLLEN SQLINTEGER #define OTL_SQLLEN_PTR SQLINTEGER* #define OTL_SQLULEN SQLUINTEGER #define OTL_SQLULEN_PTR SQLUINTEGER* #endif // #if defined(OTL_IODBC_BSD) #else // #if defined(OTL_DB2_CLI) #if (ODBCVER >= 0x0300) #define OTL_HENV SQLHANDLE #define OTL_HDBC SQLHANDLE #define OTL_SQLHANDLE SQLHANDLE #define OTL_SQLRETURN SQLRETURN #define OTL_SQLSMALLINT SQLSMALLINT #define OTL_SQLCHAR_PTR SQLCHAR* #define OTL_SQLINTEGER_PTR SQLINTEGER* #define OTL_SQLSMALLINT_PTR SQLSMALLINT* #define OTL_SQLINTEGER SQLINTEGER #define OTL_SQLHSTMT SQLHSTMT #define OTL_SQLUSMALLINT SQLUSMALLINT #define OTL_SQLPOINTER SQLPOINTER #define OTL_SQLCHAR SQLCHAR #define OTL_SQLUINTEGER SQLUINTEGER #if defined(OTL_IODBC_BSD) #define OTL_SQLLEN SQLLEN #define OTL_SQLLEN_PTR SQLLEN* #define OTL_SQLULEN SQLULEN #define OTL_SQLULEN_PTR SQLULEN* #else // #if defined(OTL_IODBC_BSD) #if (defined(_MSC_VER)&&(_MSC_VER==1200)) // VC 6++ #define OTL_SQLLEN SQLINTEGER #define OTL_SQLLEN_PTR SQLINTEGER* #define OTL_SQLULEN SQLUINTEGER #define OTL_SQLULEN_PTR SQLUINTEGER* #else #if !defined(OTL_SQLLEN) #define OTL_SQLLEN SQLLEN #define OTL_SQLLEN_PTR SQLLEN* #define OTL_SQLULEN SQLULEN #define OTL_SQLULEN_PTR SQLULEN* #endif #endif #endif // #if defined(OTL_IODBC_BSD) #else // #if (ODBCVER >= 0x0300) #define OTL_HENV HENV #define OTL_HDBC HDBC #define OTL_SQLHANDLE HSTMT #define OTL_SQLRETURN SQLRETURN #define OTL_SQLSMALLINT SQLSMALLINT #define OTL_SQLCHAR_PTR SQLCHAR* #define OTL_SQLINTEGER_PTR SQLINTEGER* #define OTL_SQLSMALLINT_PTR SQLSMALLINT* #define OTL_SQLINTEGER SQLINTEGER #define OTL_SQLHSTMT SQLHSTMT #define OTL_SQLUSMALLINT SQLUSMALLINT #define OTL_SQLPOINTER SQLPOINTER #define OTL_SQLCHAR SQLCHAR #define OTL_SQLUINTEGER SQLUINTEGER #if defined(OTL_IODBC_BSD) #define OTL_SQLLEN SQLLEN #define OTL_SQLLEN_PTR SQLLEN* #define OTL_SQLULEN SQLULEN #define OTL_SQLULEN_PTR SQLULEN* #else // #if defined(OTL_IODBC_BSD) #if (defined(_MSC_VER)&&(_MSC_VER==1200)) // VC 6++ #define OTL_SQLLEN SQLINTEGER #define OTL_SQLLEN_PTR SQLINTEGER* #define OTL_SQLULEN SQLUINTEGER #define OTL_SQLULEN_PTR SQLUINTEGER* #else #define OTL_SQLLEN SQLLEN #define OTL_SQLLEN_PTR SQLLEN* #define OTL_SQLULEN SQLULEN #define OTL_SQLULEN_PTR SQLULEN* #endif #endif // #if defined(OTL_IODBC_BSD) #endif #endif #endif OTL_ODBC_NAMESPACE_BEGIN #if (defined(UNICODE) || defined(_UNICODE)) && defined(OTL_ODBC) inline void otl_convert_char_to_SQLWCHAR(SQLWCHAR* dst, const unsigned char* src) { while(*src) *dst++=OTL_SCAST(SQLWCHAR,*src++); *dst=0; } inline void otl_convert_SQLWCHAR_to_char(unsigned char* dst, const SQLWCHAR*src) { while(*src) *dst++=OTL_SCAST(unsigned char,*src++); *dst=0; } inline size_t otl_strlen(const SQLWCHAR* s) { size_t len=0; while(*s){ ++s; ++len; } return len; } #endif typedef OTL_SQL_TIMESTAMP_STRUCT otl_time; const int otl_odbc_date_prec=23; #if defined(OTL_ODBC_MSSQL_2008) const int otl_odbc_date_scale=7; #elif defined(OTL_ODBC_MSSQL_2005) const int otl_odbc_date_scale=3; #else const int otl_odbc_date_scale=0; #endif const int OTL_MAX_MSG_ARR=512; class otl_exc{ public: #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) SQLWCHAR msg[1000]; SQLWCHAR sqlstate[1000]; #else unsigned char msg[1000]; unsigned char sqlstate[1000]; #endif int code; #if defined(OTL_EXTENDED_EXCEPTION) #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) SQLWCHAR** msg_arr; SQLWCHAR** sqlstate_arr; #else char** msg_arr; char** sqlstate_arr; #endif int* code_arr; int arr_len; #endif enum{disabled=0,enabled=1}; otl_exc(): msg(), sqlstate(), code(0) #if defined(OTL_EXTENDED_EXCEPTION) #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) ,msg_arr(0), sqlstate_arr(0), #else ,msg_arr(0), sqlstate_arr(0), #endif code_arr(0), arr_len(0) #endif { sqlstate[0]=0; msg[0]=0; } #if defined(OTL_EXTENDED_EXCEPTION) otl_exc(const otl_exc& ex): #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) msg(), sqlstate(), #else msg(), sqlstate(), #endif code(0), #if defined(OTL_EXTENDED_EXCEPTION) #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) msg_arr(0), sqlstate_arr(0), #else msg_arr(0), sqlstate_arr(0), #endif code_arr(0), arr_len(0) #endif { #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) otl_strcpy(OTL_RCAST(unsigned char*,msg), OTL_RCAST(const unsigned char*, OTL_CCAST(SQLWCHAR*,ex.msg))); otl_strcpy(OTL_RCAST(unsigned char*, OTL_CCAST(SQLWCHAR*,sqlstate)), OTL_RCAST(const unsigned char*, OTL_CCAST(SQLWCHAR*,ex.sqlstate))); code=ex.code; arr_len=0; msg_arr=0; sqlstate_arr=0; code_arr=0; if(ex.arr_len>0){ sqlstate_arr=new SQLWCHAR*[ex.arr_len]; msg_arr=new SQLWCHAR*[ex.arr_len]; code_arr=new int[ex.arr_len]; int i; size_t msg_len, sqlstate_len; for(i=0;i0){ sqlstate_arr=new char*[ex.arr_len]; msg_arr=new char*[ex.arr_len]; code_arr=new int[ex.arr_len]; int i; size_t msg_len, sqlstate_len; for(i=0;i0){ for(i=0;i= 0x0300) #if defined(OTL_EXTENDED_EXCEPTION) inline void otl_fill_exception( otl_exc& exception_struct, OTL_SQLHANDLE handle, OTL_SQLSMALLINT htype ) { #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) OTL_SQLRETURN rc; OTL_SQLSMALLINT msg_len=0; SQLWCHAR* tmp_msg_arr[OTL_MAX_MSG_ARR]; SQLWCHAR* tmp_sqlstate_arr[OTL_MAX_MSG_ARR]; int tmp_code_arr[OTL_MAX_MSG_ARR]; int tmp_arr_len=0; OTL_SQLSMALLINT tmp_msg_len=0; OTL_SQLSMALLINT tmp_sqlstate_len=0; int tmp_code; SQLWCHAR tmp_msg[SQL_MAX_MESSAGE_LENGTH]; SQLWCHAR tmp_sqlstate[1000]; otl_strcpy(OTL_RCAST(unsigned char*,tmp_msg), OTL_RCAST(const unsigned char*, OTL_CCAST(SQLWCHAR*,exception_struct.msg))); otl_strcpy(OTL_RCAST(unsigned char*,tmp_sqlstate), OTL_RCAST(const unsigned char*, OTL_CCAST(SQLWCHAR*,exception_struct.sqlstate))); tmp_code=exception_struct.code; do{ tmp_sqlstate_len=OTL_SCAST(OTL_SQLSMALLINT,otl_strlen(tmp_sqlstate)); tmp_msg_len=OTL_SCAST(OTL_SQLSMALLINT,otl_strlen(tmp_msg)); ++tmp_arr_len; tmp_msg_arr[tmp_arr_len-1]=new SQLWCHAR[tmp_msg_len+1]; tmp_sqlstate_arr[tmp_arr_len-1]=new SQLWCHAR[tmp_sqlstate_len+1]; otl_strcpy(OTL_RCAST(unsigned char*,tmp_msg_arr[tmp_arr_len-1]), OTL_RCAST(const unsigned char*, OTL_CCAST(SQLWCHAR*,tmp_msg))); otl_strcpy(OTL_RCAST(unsigned char*,tmp_sqlstate_arr[tmp_arr_len-1]), OTL_RCAST(const unsigned char*, OTL_CCAST(SQLWCHAR*,tmp_sqlstate))); tmp_code_arr[tmp_arr_len-1]=tmp_code; rc=SQLGetDiagRec (htype, handle, OTL_SCAST(OTL_SQLSMALLINT,tmp_arr_len+1), OTL_RCAST(SQLWCHAR*,tmp_sqlstate), OTL_RCAST(OTL_SQLINTEGER_PTR,&tmp_code), OTL_RCAST(SQLWCHAR*,tmp_msg), SQL_MAX_MESSAGE_LENGTH-1, OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len)); tmp_msg[msg_len]=0; if((rc==SQL_NO_DATA||rc==SQL_INVALID_HANDLE|| rc==SQL_ERROR)&&tmp_arr_len==1){ int i; for(i=0;i0){ status=SQLSetConnectAttr (hdbc, SQL_ATTR_LOGIN_TIMEOUT, OTL_RCAST(void*,OTL_SCAST(size_t,timeout)), 0); if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; } #if defined(OTL_DB2_CLI) status=SQLSetConnectAttr (hdbc, SQL_ATTR_LONGDATA_COMPAT, OTL_RCAST(SQLPOINTER,SQL_LD_COMPAT_YES), SQL_IS_INTEGER); if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; #endif #if defined(OTL_ENABLE_MSSQL_MARS) #define OTL_SQL_COPT_SS_BASE 1200 #define OTL_SQL_COPT_SS_MARS_ENABLED (OTL_SQL_COPT_SS_BASE+24) #define OTL_SQL_MARS_ENABLED_YES 1L #if !defined(OTL_DB2_CLI) && (ODBCVER >= 0x0300) SQLSetConnectAttr (hdbc, OTL_SQL_COPT_SS_MARS_ENABLED, OTL_RCAST(SQLPOINTER,OTL_SQL_MARS_ENABLED_YES), SQL_IS_UINTEGER); #endif #endif status=SQLConnect (hdbc, OTL_CCAST(SQLWCHAR*,tnsname),SQL_NTS, OTL_CCAST(SQLWCHAR*,username),SQL_NTS, OTL_CCAST(SQLWCHAR*,passwd),SQL_NTS); if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; } #endif int ext_logon(OTL_HENV ahenv, OTL_HDBC ahdbc, const int #ifndef OTL_ODBC_MYSQL auto_commit #endif ) { if(!extern_lda){ #if (ODBCVER >= 0x0300) if(hdbc!=0){ status=SQLFreeHandle(SQL_HANDLE_DBC,hdbc); } #else if(hdbc!=0) status=SQLFreeConnect(hdbc); #endif hdbc=0; #if (ODBCVER >= 0x0300) if(henv!=0){ status=SQLFreeHandle(SQL_HANDLE_ENV,henv); } #else if(henv!=0) status=SQLFreeEnv(henv); #endif henv=0; } extern_lda=true; henv=ahenv; hdbc=ahdbc; #ifndef OTL_ODBC_MYSQL #if (ODBCVER >= 0x0300) if(auto_commit) status=SQLSetConnectAttr (hdbc, SQL_ATTR_AUTOCOMMIT, OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_ON), SQL_IS_POINTER); else status=SQLSetConnectAttr (hdbc, SQL_ATTR_AUTOCOMMIT, OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_OFF), SQL_IS_POINTER); #else if(auto_commit) status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,1); else status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,0); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; #endif #if defined(OTL_DB2_CLI) status=SQLSetConnectAttr (hdbc, SQL_ATTR_LONGDATA_COMPAT, OTL_RCAST(SQLPOINTER,SQL_LD_COMPAT_YES), SQL_IS_INTEGER); if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; #endif return 1; } virtual ~otl_conn() { if(extern_lda){ hdbc=0; henv=0; extern_lda=false; }else{ #if (ODBCVER >= 0x0300) if(hdbc!=0){ status=SQLFreeHandle(SQL_HANDLE_DBC,hdbc); } #else if(hdbc!=0) status=SQLFreeConnect(hdbc); #endif hdbc=0; #if (ODBCVER >= 0x0300) if(henv!=0){ status=SQLFreeHandle(SQL_HANDLE_ENV,henv); } #else if(henv!=0) status=SQLFreeEnv(henv); #endif henv=0; } } void set_timeout(const int atimeout=0) { timeout=atimeout; } void set_cursor_type(const int acursor_type=0) { cursor_type=acursor_type; } int rlogon(const char* connect_str, const int #ifndef OTL_ODBC_MYSQL auto_commit #endif ) { char username[256]; char passwd[256]; char tnsname[1024]; char* tnsname_ptr=0; char* c=OTL_CCAST(char*,connect_str); char* username_ptr=username; char* passwd_ptr=passwd; char temp_connect_str[512]; if(extern_lda){ extern_lda=false; henv=0; hdbc=0; } memset(username,0,sizeof(username)); memset(passwd,0,sizeof(passwd)); memset(tnsname,0,sizeof(tnsname)); char* c1=OTL_CCAST(char*,connect_str); int oracle_format=0; char prev_c=' '; while(*c1){ if(*c1=='@' && prev_c!='\\'){ oracle_format=1; break; } prev_c=*c1; ++c1; } if(oracle_format){ while(*c && *c!='/' && (OTL_SCAST(unsigned,username_ptr-username)< sizeof(username)-1)){ *username_ptr=*c; ++c; ++username_ptr; } *username_ptr=0; if(*c=='/')++c; prev_c=' '; while(*c && !(*c=='@' && prev_c!='\\') && (OTL_SCAST(unsigned,passwd_ptr-passwd)= 0x0300) status=SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&henv); #else status=SQLAllocEnv(&henv); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; #if (ODBCVER >= 0x0300) status=SQLSetEnvAttr (henv, SQL_ATTR_ODBC_VERSION, OTL_RCAST(void*,SQL_OV_ODBC3), SQL_NTS); if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; #endif #if (ODBCVER >= 0x0300) status=SQLAllocHandle(SQL_HANDLE_DBC,henv,&hdbc); #else status=SQLAllocConnect(henv, &hdbc); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; }else status=SQL_SUCCESS; #ifndef OTL_ODBC_MYSQL #if (ODBCVER >= 0x0300) if(auto_commit) status=SQLSetConnectAttr (hdbc, SQL_ATTR_AUTOCOMMIT, OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_ON), SQL_IS_POINTER); else status=SQLSetConnectAttr (hdbc, SQL_ATTR_AUTOCOMMIT, OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_OFF), SQL_IS_POINTER); #else if(auto_commit) status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,1); else status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,0); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; #endif #if (ODBCVER >= 0x0300) if(timeout>0) status=SQLSetConnectAttr (hdbc, SQL_ATTR_LOGIN_TIMEOUT, OTL_RCAST(void*,OTL_SCAST(size_t,timeout)), 0); #else if (timeout>0) status=SQLSetConnectOption(hdbc,SQL_LOGIN_TIMEOUT,timeout); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; #if defined(OTL_DB2_CLI) status=SQLSetConnectAttr (hdbc, SQL_ATTR_LONGDATA_COMPAT, OTL_RCAST(SQLPOINTER,SQL_LD_COMPAT_YES), SQL_IS_INTEGER); if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; #endif #if defined(OTL_ENABLE_MSSQL_MARS) #define OTL_SQL_COPT_SS_BASE 1200 #define OTL_SQL_COPT_SS_MARS_ENABLED (OTL_SQL_COPT_SS_BASE+24) #define OTL_SQL_MARS_ENABLED_YES 1L #if !defined(OTL_DB2_CLI) && (ODBCVER >= 0x0300) SQLSetConnectAttr (hdbc, OTL_SQL_COPT_SS_MARS_ENABLED, OTL_RCAST(SQLPOINTER,OTL_SQL_MARS_ENABLED_YES), SQL_IS_UINTEGER); #endif #endif if(oracle_format){ #if defined(OTL_ODBC_zOS) if(tnsname[0]==0 && username[0]==0 && passwd[0]==0){ status=SQLConnect (hdbc, 0L,SQL_NTS, 0L,SQL_NTS, 0L,SQL_NTS); logoff_commit = false; }else status=SQLConnect (hdbc, OTL_RCAST(unsigned char*,tnsname),SQL_NTS, OTL_RCAST(unsigned char*,username),SQL_NTS, OTL_RCAST(unsigned char*,passwd),SQL_NTS); #else #if defined(UNICODE) || defined(_UNICODE) { SQLWCHAR* temp_tnsname=new SQLWCHAR[strlen(tnsname)+1]; SQLWCHAR* temp_username=new SQLWCHAR[strlen(username)+1]; SQLWCHAR* temp_passwd=new SQLWCHAR[strlen(passwd)+1]; otl_convert_char_to_SQLWCHAR(temp_tnsname,OTL_RCAST(unsigned char*,tnsname)); otl_convert_char_to_SQLWCHAR(temp_username,OTL_RCAST(unsigned char*,username)); otl_convert_char_to_SQLWCHAR(temp_passwd,OTL_RCAST(unsigned char*,passwd)); status=SQLConnect (hdbc, temp_tnsname,SQL_NTS, temp_username,SQL_NTS, temp_passwd,SQL_NTS); delete[] temp_tnsname; delete[] temp_username; delete[] temp_passwd; } #else status=SQLConnect (hdbc, OTL_RCAST(unsigned char*,tnsname),SQL_NTS, OTL_RCAST(unsigned char*,username),SQL_NTS, OTL_RCAST(unsigned char*,passwd),SQL_NTS); #endif #endif }else{ char* tc2=temp_connect_str; const char* tc1=connect_str; prev_c=' '; while(*tc1 && (OTL_SCAST(unsigned,tc2-temp_connect_str)< sizeof(temp_connect_str)-1)){ if(*tc1=='@' && prev_c=='\\') --tc2; *tc2=*tc1; prev_c=*tc1; ++tc1; ++tc2; } *tc2=0; SQLSMALLINT out_len=0; #if (defined(UNICODE)||defined(_UNICODE)) { size_t len=strlen(temp_connect_str); SQLWCHAR* temp_connect_str2=new SQLWCHAR[len+1]; SQLWCHAR out_str[2048]; otl_convert_char_to_SQLWCHAR(temp_connect_str2,OTL_RCAST(unsigned char*,temp_connect_str)); status=SQLDriverConnect (hdbc, 0, temp_connect_str2, OTL_SCAST(short,len), out_str, sizeof(out_str)/sizeof(SQLWCHAR), &out_len, SQL_DRIVER_NOPROMPT); delete[] temp_connect_str2; } #else SQLCHAR out_str[2048]; status=SQLDriverConnect (hdbc, 0, OTL_RCAST(SQLCHAR*,OTL_CCAST(char*,temp_connect_str)), OTL_SCAST(short,strlen(temp_connect_str)), out_str, sizeof(out_str), &out_len, SQL_DRIVER_NOPROMPT); #endif } if(status == SQL_SUCCESS_WITH_INFO || status == SQL_SUCCESS) return 1; else return 0; } int set_transaction_isolation_level (const long int #ifndef OTL_ODBC_MYSQL level #endif ) { #ifndef OTL_ODBC_MYSQL #if (ODBCVER >= 0x0300) status=SQLSetConnectAttr (hdbc, SQL_ATTR_TXN_ISOLATION, OTL_RCAST(SQLPOINTER,OTL_SCAST(size_t,level)), SQL_IS_POINTER); #else status=SQLSetConnectOption(hdbc,SQL_TXN_ISOLATION,level); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; #else return 1; #endif } int auto_commit_on(void) { #if defined(OTL_ODBC_MYSQL) return 1; #else #if (ODBCVER >= 0x0300) status=SQLSetConnectAttr (hdbc, SQL_ATTR_AUTOCOMMIT, OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_ON), SQL_IS_POINTER); #else status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,1); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; #endif } int auto_commit_off(void) { #if defined(OTL_ODBC_MYSQL) return 1; #else #if (ODBCVER >= 0x0300) status=SQLSetConnectAttr (hdbc, SQL_ATTR_AUTOCOMMIT, OTL_RCAST(SQLPOINTER,SQL_AUTOCOMMIT_OFF), SQL_IS_POINTER); #else status=SQLSetConnectOption(hdbc,SQL_AUTOCOMMIT,0); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; #endif } int logoff(void) { if(extern_lda){ extern_lda=false; henv=0; hdbc=0; return 1; }else{ #if defined(OTL_ODBC_zOS) if(logoff_commit) commit(); #else commit(); #endif status=SQLDisconnect(hdbc); #if defined(OTL_ODBC_LOGOFF_FREES_HANDLES) #if (ODBCVER >= 0x0300) if(hdbc!=0){ SQLFreeHandle(SQL_HANDLE_DBC, hdbc); hdbc=0; } if(henv!=0){ SQLFreeHandle(SQL_HANDLE_ENV, henv); henv=0; } #else if(hdbc!=0){ SQLFreeConnect(hdbc); hdbc=0; } if(henv!=0){ SQLFreeEnv(henv); henv=0; } #endif #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; } } void error(otl_exc& exception_struct) {OTL_SQLRETURN rc; OTL_SQLSMALLINT msg_len=0; #if (ODBCVER >= 0x0300) #if (defined(UNICODE)||defined(_UNICODE)) #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) rc=SQLGetDiagRec #if defined(OTL_ODBC_zOS) (hdbc==0?SQL_HANDLE_ENV:SQL_HANDLE_DBC, hdbc==0?henv:hdbc, #else (SQL_HANDLE_DBC, hdbc, #endif 1, &exception_struct.sqlstate[0], OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code), &exception_struct.msg[0], SQL_MAX_MESSAGE_LENGTH-1, OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len)); exception_struct.msg[msg_len]=0; #else { SQLWCHAR temp_msg[SQL_MAX_MESSAGE_LENGTH]; SQLWCHAR temp_sqlstate[1000]; rc=SQLGetDiagRec #if defined(OTL_ODBC_zOS) (hdbc==0?SQL_HANDLE_ENV:SQL_HANDLE_DBC, hdbc==0?henv:hdbc, #else (SQL_HANDLE_DBC, hdbc, #endif 1, temp_sqlstate, OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code), temp_msg, SQL_MAX_MESSAGE_LENGTH-1, OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len)); temp_msg[msg_len]=0; otl_convert_SQLWCHAR_to_char (OTL_RCAST(unsigned char*,&exception_struct.sqlstate[0]), temp_sqlstate); otl_convert_SQLWCHAR_to_char (OTL_RCAST(unsigned char*,&exception_struct.msg[0]), temp_msg); } #endif #else void* temp_ptr=&exception_struct.code; rc=SQLGetDiagRec #if defined(OTL_ODBC_zOS) (hdbc==0?SQL_HANDLE_ENV:SQL_HANDLE_DBC, hdbc==0?henv:hdbc, #else (SQL_HANDLE_DBC, hdbc, #endif 1, OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.sqlstate[0]), OTL_RCAST(OTL_SQLINTEGER_PTR,temp_ptr), OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.msg[0]), SQL_MAX_MESSAGE_LENGTH-1, OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len)); #endif #else rc=SQLError(henv, hdbc, 0, // hstmt OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.sqlstate[0]), OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code), OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.msg[0]), SQL_MAX_MESSAGE_LENGTH-1, OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len)); #endif exception_struct.msg[msg_len]=0; if(rc==SQL_INVALID_HANDLE||rc==SQL_ERROR) exception_struct.msg[0]=0; #if (ODBCVER >= 0x0300) #if defined(OTL_EXTENDED_EXCEPTION) else if(rc!=SQL_NO_DATA) #if defined(OTL_ODBC_zOS) { if(hdbc) otl_fill_exception(exception_struct,hdbc,SQL_HANDLE_DBC); else otl_fill_exception(exception_struct,henv,SQL_HANDLE_ENV); } #else otl_fill_exception(exception_struct,hdbc,SQL_HANDLE_DBC); #endif #endif #endif } int commit(void) { #ifndef OTL_ODBC_MYSQL #if (ODBCVER >= 0x0300) status=SQLEndTran(SQL_HANDLE_DBC,hdbc,SQL_COMMIT); #else status=SQLTransact(henv,hdbc,SQL_COMMIT); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; #else return 1; #endif } int rollback(void) { #ifndef OTL_ODBC_MYSQL #if (ODBCVER >= 0x0300) status=SQLEndTran(SQL_HANDLE_DBC,hdbc,SQL_ROLLBACK); #else status=SQLTransact(henv,hdbc,SQL_ROLLBACK); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; #else return 1; #endif } private: otl_conn(const otl_conn&): henv(0), hdbc(0), timeout(0), cursor_type(0), status(SQL_SUCCESS), long_max_size(32760), extern_lda(false) #if defined(OTL_ODBC_zOS) ,logoff_commit(true) #endif #if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO) ,throws_on_sql_success_with_info(false) #endif ,connection_type(OTL_DEFAULT_ODBC_CONNECT) { } otl_conn& operator=(const otl_conn&) { return *this; } }; class otl_var; class otl_cur; class otl_sel; class otl_cur0{ protected: friend class otl_sel; friend class otl_var; OTL_SQLHSTMT cda; int last_param_data_token; int last_sql_param_data_status; int sql_param_data_count; public: otl_cur0(): cda(0), last_param_data_token(0), last_sql_param_data_status(0), sql_param_data_count(0) { } virtual ~otl_cur0(){} OTL_SQLHSTMT get_cda(){return cda;} private: otl_cur0(const otl_cur0&): cda(0), last_param_data_token(0), last_sql_param_data_status(0), sql_param_data_count(0) { } otl_cur0& operator=(const otl_cur0&) { return *this; } }; class otl_cur; class otl_var{ private: friend class otl_cur; unsigned char* p_v; OTL_SQLLEN_PTR p_len; int ftype; int act_elem_size; bool lob_stream_mode; int lob_stream_flag; int vparam_type; int lob_len; int lob_pos; int lob_ftype; int otl_adapter; bool charz_flag; public: int get_otl_adapter() const {return otl_adapter;} void set_lob_stream_mode(const bool alob_stream_mode) { lob_stream_mode=alob_stream_mode; } void set_vparam_type(const int avparam_type) { vparam_type=avparam_type; } void set_charz_flag(const bool acharz_flag) { charz_flag=acharz_flag; } otl_var(): p_v(0), p_len(0), ftype(0), act_elem_size(0), lob_stream_mode(false), lob_stream_flag(0), vparam_type(-1), lob_len(0), lob_pos(0), lob_ftype(0), otl_adapter(otl_odbc_adapter), charz_flag(false) { } virtual ~otl_var() { delete[] p_v; delete[] p_len; } int write_dt(void* trg, const void* src, const int sz) { memcpy(trg,src,sz); return 1; } int read_dt(void* trg, const void* src, const int sz) { memcpy(trg,src,sz); return 1; } void set_lob_stream_flag(const int flg=1) { lob_stream_flag=flg; } int get_pl_tab_len(void) { return 0; } int get_max_pl_tab_len(void) { return 0; } void set_pl_tab_len(const int /* pl_tab_len */) { } int write_blob (const otl_long_string& s, const int /* alob_len */, int& aoffset, otl_cur0& cur) { SQLRETURN rc=0; SQLINTEGER temp_len=0; SQLPOINTER pToken=0; int param_number=0; if(!lob_stream_flag&&!lob_stream_mode)return 1; if(aoffset==1){ if(cur.sql_param_data_count==0){ rc=SQLParamData(cur.cda, &pToken); param_number=OTL_SCAST(int,OTL_RCAST(size_t,pToken)); ++cur.sql_param_data_count; cur.last_sql_param_data_status=rc; cur.last_param_data_token=param_number; if(rc!=SQL_SUCCESS&&rc!=SQL_SUCCESS_WITH_INFO&& rc!=SQL_NEED_DATA) return 0; } } if(ftype==otl_var_raw_long) temp_len=s.len(); else temp_len=s.len()*sizeof(OTL_CHAR); rc=SQLPutData(cur.cda,s.v,temp_len); if(rc!=SQL_SUCCESS&&rc!=SQL_SUCCESS_WITH_INFO) return 0; else{ aoffset+=s.len(); return 1; } } int clob_blob(otl_cur0& cur) { SQLRETURN rc=0; SQLPOINTER pToken=0; int param_number=0; if(!(cur.last_param_data_token==0&&cur.sql_param_data_count>0)){ rc=SQLParamData(cur.cda, &pToken); param_number=OTL_SCAST(int,OTL_RCAST(size_t,pToken)); ++cur.sql_param_data_count; cur.last_sql_param_data_status=rc; cur.last_param_data_token=param_number; if(rc!=SQL_SUCCESS&&rc!=SQL_SUCCESS_WITH_INFO&& #if (ODBCVER >= 0x0300) rc!=SQL_NO_DATA && #endif rc!=SQL_NEED_DATA) return 0; } return 1; } int read_blob (otl_cur0& cur, otl_long_string& s, const int andx, int& aoffset, int& eof_flag) { SQLRETURN rc=0; OTL_SQLLEN retLen=0; int chunkLen=0; if(!lob_stream_flag&&!lob_stream_mode)return 1; int buf_size=s.get_buf_size()*sizeof(OTL_CHAR); if(ftype==otl_var_raw_long) buf_size=s.get_buf_size(); rc=SQLGetData (cur.cda, OTL_SCAST(SQLSMALLINT,lob_pos), OTL_SCAST(SQLSMALLINT,lob_ftype), s.v, buf_size, &retLen); if(rc==SQL_SUCCESS_WITH_INFO||rc==SQL_SUCCESS){ if(retLen==SQL_NULL_DATA){ chunkLen=0; p_len[andx]=SQL_NULL_DATA; }else if(retLen>buf_size||retLen==SQL_NO_TOTAL) chunkLen=s.get_buf_size(); else{ if(ftype==otl_var_raw_long) chunkLen=OTL_SCAST(int,retLen); else chunkLen=OTL_SCAST(int,retLen)/sizeof(OTL_CHAR); } #if defined(OTL_UNICODE) if(lob_ftype==SQL_C_WCHAR) s.set_len(chunkLen-1); #else if(lob_ftype==SQL_C_CHAR) s.set_len(chunkLen-1); #endif else s.set_len(chunkLen); if(lob_len==0&&aoffset==1&& retLen!=SQL_NULL_DATA&& retLen!=SQL_NO_TOTAL) lob_len=OTL_SCAST(int,retLen); aoffset+=chunkLen; if(chunkLen= 0x0300) else if(rc==SQL_NO_DATA) #else else if(rc==SQL_NO_DATA_FOUND) #endif return 1; else return 0; } int get_blob_len(const int /* ndx */,int& alen) { alen=lob_len; return 1; } int put_blob(void) { return 1; } int get_blob (const int /* ndx */, unsigned char* /* abuf */, const int /* buf_size */, int& /* len */) { return 1; } int save_blob (const unsigned char* /* abuf */, const int /* len */, const int /* extern_buffer_flag */) { return 1; } int actual_elem_size(void) { return act_elem_size; } void init (const bool, const int aftype, int& aelem_size, const otl_stream_buffer_size_type aarray_size, const void* /* connect_struct */=0, const int /*apl_tab_size*/=0) {int i; size_t byte_size=0; ftype=aftype; act_elem_size=aelem_size; byte_size=aelem_size*OTL_SCAST(size_t,aarray_size); #if defined(OTL_UNICODE) if(aftype==otl_var_char||aftype==otl_var_varchar_long){ byte_size*=sizeof(OTL_CHAR); p_v=new unsigned char[byte_size]; } else p_v=new unsigned char[byte_size]; #else p_v=new unsigned char[byte_size]; #endif p_len=new OTL_SQLLEN[aarray_size]; memset(p_v,0,byte_size); for(i=0;i= 0x0300) case SQL_TYPE_DATE: return SQL_C_TIMESTAMP; case SQL_TYPE_TIMESTAMP: return SQL_C_TIMESTAMP; case SQL_TYPE_TIME: return SQL_C_TIMESTAMP; case OTL_SQL_SS_TIME2: return SQL_C_TIMESTAMP; #if defined(OTL_UNICODE) case OTL_SQL_SS_TIMESTAMPOFFSET: return SQL_C_WCHAR; #else case OTL_SQL_SS_TIMESTAMPOFFSET: return SQL_C_CHAR; #endif #else case SQL_DATE: return SQL_C_TIMESTAMP; case SQL_TIMESTAMP: return SQL_C_TIMESTAMP; case SQL_TIME: return SQL_C_TIMESTAMP; #endif #if defined(OTL_BIGINT) case SQL_BIGINT: return SQL_C_SBIGINT; #else case SQL_BIGINT: return SQL_C_DOUBLE; #endif case SQL_DECIMAL: return SQL_C_DOUBLE; case SQL_DOUBLE: return SQL_C_DOUBLE; case SQL_FLOAT: return SQL_C_DOUBLE; case SQL_INTEGER: return SQL_C_SLONG; case SQL_NUMERIC: return SQL_C_DOUBLE; case SQL_REAL: return SQL_C_DOUBLE; case SQL_SMALLINT: return SQL_C_SSHORT; case SQL_BIT: return SQL_C_SSHORT; case SQL_TINYINT: return SQL_C_SSHORT; case SQL_LONGVARBINARY: return SQL_LONGVARBINARY; #if defined(OTL_MAP_SQL_VARBINARY_TO_RAW_LONG) case SQL_VARBINARY: return SQL_LONGVARBINARY; #else case SQL_VARBINARY: return SQL_C_BINARY; #endif #if (ODBCVER >= 0x0350) #if defined(OTL_MAP_SQL_GUID_TO_CHAR) #if defined(OTL_UNICODE) case SQL_GUID: return SQL_C_WCHAR; #else case SQL_GUID: return SQL_C_CHAR; #endif #else case SQL_GUID: return SQL_C_BINARY; #endif #endif #if defined(OTL_MAP_SQL_BINARY_TO_CHAR) #if defined(OTL_UNICODE) case SQL_BINARY: // MS SQL TIMESTAMP, BINARY return SQL_C_WCHAR; #else case SQL_BINARY: // MS SQL TIMESTAMP, BINARY return SQL_C_CHAR; #endif #else case SQL_BINARY: return SQL_C_BINARY; #endif #if (ODBCVER >= 0x0350) case OTL_SQL_XML: #if defined(OTL_UNICODE) return SQL_C_WCHAR; #else return SQL_C_CHAR; #endif #endif default: return otl_unsupported_type; } } static int datatype_size(int ftype,int maxsz,int int_type,int max_long_size) { switch(ftype){ #if defined(OTL_UNICODE) case SQL_C_WCHAR: #endif case SQL_C_CHAR: switch(int_type){ case SQL_BINARY: // MS SQL TIMESTAMP return 17; #if defined(OTL_UNICODE) case SQL_WLONGVARCHAR: #endif case SQL_LONGVARCHAR: return max_long_size*sizeof(OTL_CHAR); case SQL_LONGVARBINARY: return max_long_size; case SQL_DATE: return 40; #if (ODBCVER >= 0x0300) case SQL_TYPE_TIMESTAMP: #else case SQL_TIMESTAMP: #endif return 40; #if (ODBCVER >= 0x0300) case SQL_TYPE_TIME: #else case SQL_TIME: #endif return 40; #if (ODBCVER >= 0x0350) #if defined(OTL_MAP_SQL_GUID_TO_SQL_VARBINARY) case SQL_GUID: return 16; #else case SQL_GUID: return 40; #endif #endif default: return (maxsz+1); } #if defined(OTL_BIGINT) case SQL_C_SBIGINT: return sizeof(OTL_BIGINT); #endif case SQL_C_DOUBLE: return sizeof(double); case SQL_C_SLONG: return sizeof(int); case SQL_C_SSHORT: return sizeof(short int); case SQL_C_TIMESTAMP: return sizeof(OTL_SQL_TIMESTAMP_STRUCT); case SQL_C_TIME: return sizeof(OTL_SQL_TIME_STRUCT); case SQL_C_DATE: return sizeof(OTL_SQL_DATE_STRUCT); #if defined(OTL_UNICODE) case SQL_WLONGVARCHAR: return max_long_size; #endif case SQL_LONGVARCHAR: return max_long_size; case SQL_LONGVARBINARY: return max_long_size; case SQL_C_BINARY: return maxsz; default: return 0; } } static void map_ftype (otl_column_desc& desc, const int max_long_size, int& ftype, int& elem_size, otl_select_struct_override& override, const int column_ndx, const int #if !defined(OTL_ODBC_TIMESTEN) && defined(OTL_ODBC_MULTI_MODE) connection_type #endif ) { int ndx=override.find(column_ndx); if(ndx==-1){ #if defined(OTL_ODBC_MSSQL_2005) && !defined(OTL_ODBC_MULTI_MODE) if(desc.prec==0 && desc.dbtype==SQL_VARBINARY) ftype=SQL_LONGVARBINARY; else #elif defined(OTL_ODBC_MULTI_MODE) if((connection_type==OTL_MSSQL_2005_ODBC_CONNECT || connection_type==OTL_MSSQL_2008_ODBC_CONNECT)&& desc.prec==0 && desc.dbtype==SQL_VARBINARY) ftype=SQL_LONGVARBINARY; else #endif ftype=int2ext(desc.dbtype); if(desc.dbsize==0){ #if !defined(OTL_UNICODE) if(ftype==SQL_C_CHAR) ftype=SQL_LONGVARCHAR; #else if(ftype==SQL_C_CHAR) ftype=SQL_LONGVARCHAR; else if(ftype==SQL_C_WCHAR) ftype=SQL_WLONGVARCHAR; #endif elem_size=max_long_size*sizeof(OTL_CHAR); }else{ elem_size=datatype_size (ftype, OTL_SCAST(int,desc.dbsize), desc.dbtype, max_long_size); } switch(ftype){ #if defined(OTL_UNICODE) case SQL_C_WCHAR: ftype=otl_var_char; break; case SQL_WLONGVARCHAR: ftype=otl_var_varchar_long; break; #else case SQL_C_CHAR: ftype=otl_var_char; break; case SQL_LONGVARCHAR: ftype=otl_var_varchar_long; break; #endif case SQL_C_DOUBLE: if(override.get_all_mask() & otl_all_num2str){ ftype=otl_var_char; elem_size=otl_num_str_size; }else ftype=otl_var_double; break; #if defined(OTL_BIGINT) case SQL_C_SBIGINT: if(override.get_all_mask() & otl_all_num2str){ ftype=otl_var_char; elem_size=otl_num_str_size; }else ftype=otl_var_bigint; break; #endif case SQL_C_SLONG: if(override.get_all_mask() & otl_all_num2str){ ftype=otl_var_char; elem_size=otl_num_str_size; }else ftype=otl_var_int; break; case SQL_C_SSHORT: if(override.get_all_mask() & otl_all_num2str){ ftype=otl_var_char; elem_size=otl_num_str_size; }else ftype=otl_var_short; break; case SQL_LONGVARBINARY: ftype=otl_var_raw_long; break; case SQL_C_DATE: case SQL_C_TIME: case SQL_C_TIMESTAMP: if(override.get_all_mask() & otl_all_date2str){ ftype=otl_var_char; elem_size=otl_date_str_size; }else ftype=otl_var_timestamp; break; case SQL_C_BINARY: ftype=otl_var_raw; break; default: ftype=0; break; } }else{ ftype=override.get_col_type(ndx); switch(ftype){ case otl_var_char: elem_size=override.get_col_size(ndx)*sizeof(OTL_CHAR); break; case otl_var_raw: elem_size=override.get_col_size(ndx); break; case otl_var_double: elem_size=sizeof(double); break; case otl_var_float: elem_size=sizeof(float); break; case otl_var_int: elem_size=sizeof(int); break; #if defined(OTL_BIGINT) case otl_var_bigint: elem_size=sizeof(OTL_BIGINT); break; #endif case otl_var_unsigned_int: elem_size=sizeof(unsigned); break; case otl_var_short: elem_size=sizeof(short); break; case otl_var_long_int: elem_size=sizeof(double); break; default: elem_size=override.get_col_size(ndx); break; } } desc.otl_var_dbtype=ftype; } private: otl_var(const otl_var&): p_v(0), p_len(0), ftype(0), act_elem_size(0), lob_stream_mode(false), lob_stream_flag(0), vparam_type(-1), lob_len(0), lob_pos(0), lob_ftype(0), otl_adapter(otl_odbc_adapter), charz_flag(false) { } otl_var& operator=(const otl_var&) { return *this; } }; #if defined(OTL_ODBC_zOS)||defined(OTL_ODBC_TIMESTEN)|| \ (defined(SQL_TXN_READ_COMMITTED) && \ !defined(SQL_TRANSACTION_READ_COMMITTED)) const long otl_tran_read_uncommitted=SQL_TXN_READ_UNCOMMITTED; const long otl_tran_read_committed=SQL_TXN_READ_COMMITTED; const long otl_tran_repeatable_read=SQL_TXN_REPEATABLE_READ; const long otl_tran_serializable=SQL_TXN_SERIALIZABLE; #else const long otl_tran_read_uncommitted=SQL_TRANSACTION_READ_UNCOMMITTED; const long otl_tran_read_committed=SQL_TRANSACTION_READ_COMMITTED; const long otl_tran_repeatable_read=SQL_TRANSACTION_REPEATABLE_READ; const long otl_tran_serializable=SQL_TRANSACTION_SERIALIZABLE; #endif class otl_sel; class otl_cur: public otl_cur0{ private: friend class otl_sel; int status; otl_conn* adb; int direct_exec_flag; long _rpc; bool canceled; int last_iters; public: void set_canceled(const bool acanceled) { canceled=acanceled; } void reset_last_param_data_token() { last_param_data_token=0; } void reset_last_sql_param_data_status() { last_sql_param_data_status=0; } void reset_sql_param_data_count() { sql_param_data_count=0; } otl_cur(): otl_cur0(), status(0), adb(0), direct_exec_flag(0), _rpc(0), canceled(false), last_iters(0) { cda=0; last_param_data_token=0; last_sql_param_data_status=0; sql_param_data_count=0; } virtual ~otl_cur(){} int cancel(void) { status=SQLCancel(cda); canceled=true; if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; } int open(otl_conn& /* connect */,otl_var* /* var */) { return 1; } void set_direct_exec(const int flag) { direct_exec_flag=flag; } void set_parse_only(const int /*flag*/){} int open(otl_conn& connect) { last_iters=0; direct_exec_flag=0; adb=&connect; #if (ODBCVER >= 0x0300) status=SQLAllocHandle(SQL_HANDLE_STMT,connect.hdbc,&cda); #else status=SQLAllocStmt(connect.hdbc,&cda); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; if(connect.timeout>0){ #if (ODBCVER >= 0x0300) status=SQLSetStmtAttr (cda, SQL_ATTR_QUERY_TIMEOUT, OTL_RCAST(void*,OTL_SCAST(size_t,connect.timeout)), SQL_NTS); #else status=SQLSetStmtOption(cda,SQL_QUERY_TIMEOUT,connect.timeout); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; } if(connect.cursor_type!=0){ // other than default #if (ODBCVER >= 0x0300) status=SQLSetStmtAttr (cda, SQL_ATTR_CURSOR_TYPE, OTL_RCAST(void*,OTL_SCAST(size_t,connect.cursor_type)), SQL_NTS); #else status=SQLSetStmtOption(cda,SQL_CURSOR_TYPE,connect.cursor_type); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; } return 1; } int close(void) { last_iters=0; #if (ODBCVER >= 0x0300) status=SQLFreeHandle(SQL_HANDLE_STMT,cda); #else status=SQLFreeStmt(cda,SQL_DROP); #endif adb=0; cda=0; if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; } SQLRETURN sql_row_count(OTL_SQLLEN* total_rpc) { #if defined(OTL_ODBC_ALTERNATE_RPC) OTL_SQLLEN rpc=0; SQLRETURN rc; do{ rc=SQLRowCount(cda,&rpc); if(rc!=SQL_SUCCESS) return rc; *total_rpc+=rpc; rc=SQLMoreResults(cda); }while(rc==SQL_SUCCESS); return SQL_SUCCESS; #else return SQLRowCount(cda,total_rpc); #endif } int parse(char* stm_text) { #if !defined(OTL_ODBC_TIMESTEN) short in_str=0; #endif bool do_not_call_sql_row_count=false; #if defined(OTL_ODBC_SQL_STATEMENT_WITH_DIAG_REC_OUTPUT) if(OTL_ODBC_SQL_STATEMENT_WITH_DIAG_REC_OUTPUT (stm_text)){ do_not_call_sql_row_count=true; direct_exec_flag=1; } #endif char *c=stm_text; if(*c=='$'){ ++c; _rpc=0; direct_exec_flag=1; const int ctl_arr_size=6; struct{ OTL_SQLCHAR_PTR name_ptr; OTL_SQLSMALLINT name_len; OTL_SQLCHAR name[512]; } ctl_arr[ctl_arr_size]; #if (defined(UNICODE)||defined(_UNICODE)) struct{ SQLWCHAR name_ptr; OTL_SQLSMALLINT name_len; SQLWCHAR name[512]; } ctl_arr_W[ctl_arr_size]; #endif int i=0; for(i=0;istm_text && *(c-1)!='\\' )|| c==stm_text)){ ++c; while(*c && *c==' ')++c; if(*c=='\''){ par_val_len=0; ++c; while(*c && *c!='\'' && par_val_len=0 && par_numthrows_on_sql_success_with_info && status==SQL_SUCCESS_WITH_INFO) return 0; #endif if(status!=SQL_SUCCESS&& status!=SQL_SUCCESS_WITH_INFO&& #if (ODBCVER >= 0x0300) status!=SQL_NO_DATA #else status!=SQL_NO_DATA_FOUND #endif ) return 0; else{ _rpc=0; if(!do_not_call_sql_row_count){ OTL_SQLLEN tmp_rpc=0; SQLRETURN diag_status=sql_row_count(&tmp_rpc); if(diag_status==SQL_SUCCESS|| diag_status==SQL_SUCCESS_WITH_INFO) _rpc=OTL_SCAST(long,tmp_rpc); } return 1; } } #if !defined(OTL_ODBC_TIMESTEN) // Converting : notation into ODBC's native notation ? while(*c){ if(*c=='\''){ if(!in_str) in_str=1; else{ if(c[1]=='\'') ++c; else in_str=0; } } if(*c==':' && !in_str && ((c>stm_text && *(c-1)!='\\' )|| c==stm_text)){ *c='?'; ++c; while(isdigit(*c)||isalpha(*c)||*c=='_'){ *c=' '; ++c; } }else if(*c==':' && !in_str && ((c>stm_text && *(c-1)=='\\' )|| c==stm_text)){ char* c_1=c-1; char* c_=c; while(*c_){ *c_1=*c_; ++c_1; ++c_; } if(c_1>c-1) *c_1=0; --c; } ++c; } #endif #if defined(OTL_DB2_CLI) OTL_SQLINTEGER temp_isolation_level=0; status=SQLGetStmtAttr (cda, SQL_ATTR_TXN_ISOLATION, OTL_RCAST(SQLPOINTER,&temp_isolation_level), SQL_IS_POINTER, 0); if(OTL_SCAST(long,temp_isolation_level)==otl_tran_read_committed|| OTL_SCAST(long,temp_isolation_level)==otl_tran_read_uncommitted){ status=SQLSetStmtAttr (cda, SQL_ATTR_CLOSE_BEHAVIOR, OTL_RCAST(void*,SQL_CC_RELEASE), SQL_NTS); if(status!=SQL_SUCCESS&& status!=SQL_SUCCESS_WITH_INFO) return 0; } #endif #if (defined(UNICODE)||defined(_UNICODE)) { SQLWCHAR* temp_stm_text=new SQLWCHAR[strlen(stm_text)+1]; otl_convert_char_to_SQLWCHAR(temp_stm_text,OTL_RCAST(unsigned char*,stm_text)); status=SQLPrepare (cda, temp_stm_text, SQL_NTS); delete[] temp_stm_text; } #else status=SQLPrepare (cda, OTL_RCAST(OTL_SQLCHAR_PTR,stm_text), SQL_NTS); #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; } int exec(const int iters, const int /*rowoff*/, #if defined(OTL_ODBC_ALTERNATE_RPC) const int otl_sql_exec_from_class) #else const int /*otl_sql_exec_from_class*/) #endif { #if (ODBCVER >= 0x0300) #else OTL_SQLUINTEGER irows; #endif if(direct_exec_flag){ return 1; }else{ #if !defined(OTL_ODBC_MYSQL) && !defined(OTL_ODBC_XTG_IBASE6) #if (ODBCVER >= 0x0300) if(last_iters>1||iters>1||_rpc>1){ last_iters=iters; size_t temp_iters=OTL_SCAST(size_t,iters); status=SQLSetStmtAttr (cda, SQL_ATTR_PARAMSET_SIZE, OTL_RCAST(void*,temp_iters), SQL_NTS); if(status!=SQL_SUCCESS&& status!=SQL_SUCCESS_WITH_INFO) return 0; } #else if(last_iters>1||iters>1||_rpc>1){ last_iters=iters; status=SQLParamOptions (cda, OTL_SCAST(OTL_SQLUINTEGER,iters), &irows); if(status!=SQL_SUCCESS&& status!=SQL_SUCCESS_WITH_INFO) return 0; } #endif #endif _rpc=0; last_param_data_token=0; last_sql_param_data_status=0; sql_param_data_count=0; status=SQLExecute(cda); if(canceled)return 0; #if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO) if(adb && adb->throws_on_sql_success_with_info && status==SQL_SUCCESS_WITH_INFO) return 0; #endif if(status!=SQL_SUCCESS&& status!=SQL_SUCCESS_WITH_INFO&& #if (ODBCVER >= 0x0300) status!=SQL_NO_DATA&& #else status!=SQL_NO_DATA_FOUND&& #endif status!=SQL_NEED_DATA)return 0; if(status==SQL_NEED_DATA){ _rpc=iters; return 1; } OTL_SQLLEN tmp_rpc=0; SQLRETURN diag_status=0; #if defined(OTL_ODBC_ALTERNATE_RPC) if(otl_sql_exec_from_class==otl_sql_exec_from_cursor_class){ diag_status=sql_row_count(&tmp_rpc); if(diag_status==SQL_SUCCESS||diag_status==SQL_SUCCESS_WITH_INFO) _rpc=OTL_SCAST(long,tmp_rpc); return 1; }else{ _rpc=0; return 1; } #else diag_status=sql_row_count(&tmp_rpc); if(diag_status==SQL_SUCCESS||diag_status==SQL_SUCCESS_WITH_INFO) _rpc=OTL_SCAST(long,tmp_rpc); return 1; #endif } } long get_rpc() { return _rpc; } int tmpl_ftype2odbc_ftype(const int ftype) { switch(ftype){ #if defined(OTL_UNICODE) case otl_var_char: return SQL_C_WCHAR; case otl_var_varchar_long: return SQL_WLONGVARCHAR; #else case otl_var_char: return SQL_C_CHAR; case otl_var_varchar_long: return SQL_LONGVARCHAR; #endif case otl_var_double: return SQL_C_DOUBLE; #if defined(OTL_BIGINT) case otl_var_bigint: return SQL_C_SBIGINT; #endif case otl_var_float: return SQL_C_FLOAT; case otl_var_int: return SQL_C_SLONG; case otl_var_long_int: #if defined(OTL_MAP_LONG_TO_SQL_C_SBIGINT) && \ ((ODBCVER >= 0x0300) || defined(OTL_ODBC_TIMESTEN)) { static bool long_is_8_bytes=sizeof(long)==8; if(long_is_8_bytes) return SQL_C_SBIGINT; else return SQL_C_SLONG; } #else return SQL_C_SLONG; #endif case otl_var_unsigned_int: return SQL_C_ULONG; case otl_var_short: return SQL_C_SSHORT; case otl_var_timestamp: case otl_var_db2time: case otl_var_db2date: return SQL_C_TIMESTAMP; case otl_var_raw_long: return SQL_LONGVARBINARY; case otl_var_raw: return SQL_C_BINARY; default: return 0; } } int otl_map_ext2int(int ftype) { switch(ftype){ #if defined(OTL_UNICODE) case SQL_WLONGVARCHAR: return SQL_WLONGVARCHAR; case SQL_C_WCHAR: return SQL_WVARCHAR; #else case SQL_LONGVARCHAR: return SQL_LONGVARCHAR; case SQL_C_CHAR: return SQL_VARCHAR; #endif case SQL_LONGVARBINARY: return SQL_LONGVARBINARY; case SQL_C_DATE: return SQL_DATE; #if (ODBCVER >= 0x0300) case SQL_C_TIME: return SQL_TYPE_TIME; case SQL_C_TIMESTAMP: return SQL_TYPE_TIMESTAMP; #else case SQL_C_TIME: return SQL_TIME; case SQL_C_TIMESTAMP: return SQL_TIMESTAMP; #endif case SQL_C_DOUBLE: return SQL_DOUBLE; #if defined(OTL_BIGINT) case SQL_C_SBIGINT: return SQL_BIGINT; #endif case SQL_C_FLOAT: return SQL_FLOAT; case SQL_C_SLONG: return SQL_INTEGER; case SQL_C_SSHORT: return SQL_SMALLINT; case SQL_C_ULONG: return SQL_DOUBLE; case SQL_C_BINARY: return SQL_VARBINARY; default: return -1; } } int bind (const char* /* name */, otl_var& v, const int aelem_size, const int aftype, const int aparam_type, const int name_pos, const int #if !defined(OTL_ODBC_TIMESTEN) && defined(OTL_ODBC_MULTI_MODE) connection_type #endif , const int /* apl_tab_size */) {OTL_SQLSMALLINT ftype=OTL_SCAST(OTL_SQLSMALLINT,tmpl_ftype2odbc_ftype(aftype)); OTL_SQLSMALLINT ftype_save=ftype; int param_type; int parm_pos=name_pos; v.vparam_type=aparam_type; switch(aparam_type){ case otl_input_param: param_type=SQL_PARAM_INPUT; break; case otl_output_param: param_type=SQL_PARAM_OUTPUT; break; case otl_inout_param: param_type=SQL_PARAM_INPUT_OUTPUT; break; default: param_type=SQL_PARAM_INPUT; break; } #if defined(OTL_UNICODE) if(ftype==SQL_WLONGVARCHAR){ ftype=SQL_C_WCHAR; #else if(ftype==SQL_LONGVARCHAR){ ftype=SQL_C_CHAR; #endif }else if(ftype==SQL_LONGVARBINARY){ ftype=SQL_C_BINARY; } int sqltype=otl_map_ext2int(ftype_save); int mapped_sqltype=sqltype; if(aftype==otl_var_db2date) #if (ODBCVER >= 0x0300) mapped_sqltype=SQL_TYPE_DATE; #else mapped_sqltype=SQL_DATE; #endif else if(aftype==otl_var_db2time) #if (ODBCVER >= 0x0300) mapped_sqltype=SQL_TYPE_TIME; #else mapped_sqltype=SQL_TIME; #endif if(v.lob_stream_mode&& (ftype_save==SQL_LONGVARBINARY|| #if defined(OTL_UNICODE) ftype_save==SQL_WLONGVARCHAR)){ #else ftype_save==SQL_LONGVARCHAR)){ #endif // in case of "stream mode" the variable // gets bound in a special way #if defined(OTL_ODBC_MSSQL_2005) && !defined(OTL_ODBC_MULTI_MODE) switch(ftype_save){ case SQL_LONGVARBINARY: mapped_sqltype=SQL_VARBINARY; break; #if defined(OTL_UNICODE) case SQL_WLONGVARCHAR: mapped_sqltype=SQL_WVARCHAR; break; #else case SQL_LONGVARCHAR: mapped_sqltype=SQL_VARCHAR; break; #endif } #elif defined(OTL_ODBC_MULTI_MODE) if(connection_type==OTL_MSSQL_2005_ODBC_CONNECT|| connection_type==OTL_MSSQL_2008_ODBC_CONNECT){ switch(ftype_save){ case SQL_LONGVARBINARY: mapped_sqltype=SQL_VARBINARY; break; #if defined(OTL_UNICODE) case SQL_WLONGVARCHAR: mapped_sqltype=SQL_WVARCHAR; break; #else case SQL_LONGVARCHAR: mapped_sqltype=SQL_VARCHAR; break; #endif } } #endif status=SQLBindParameter (cda, OTL_SCAST(OTL_SQLUSMALLINT,parm_pos), OTL_SCAST(OTL_SQLSMALLINT,param_type), ftype, OTL_SCAST(OTL_SQLSMALLINT,mapped_sqltype), #if (ODBCVER >= 0x0300) #if defined(OTL_ODBC_MSSQL_2005) && !defined(OTL_ODBC_MULTI_MODE) 0, #elif defined(OTL_ODBC_MULTI_MODE) (connection_type==OTL_MSSQL_2005_ODBC_CONNECT|| connection_type==OTL_MSSQL_2008_ODBC_CONNECT) ? 0 : (sqltype==SQL_TYPE_TIMESTAMP?otl_odbc_date_prec:aelem_size), #else sqltype==SQL_TYPE_TIMESTAMP?otl_odbc_date_prec:aelem_size, #endif #else sqltype==SQL_TIMESTAMP?otl_odbc_date_prec:aelem_size, #endif #if (ODBCVER >= 0x0300) sqltype==SQL_TYPE_TIMESTAMP ? #if defined(OTL_ODBC_MULTI_MODE) ((connection_type==OTL_MSSQL_2008_ODBC_CONNECT)? 7 : (connection_type==OTL_MSSQL_2005_ODBC_CONNECT)? 3 : otl_odbc_date_scale) : 0, #else otl_odbc_date_scale : 0, #endif #else sqltype==SQL_TIMESTAMP?otl_odbc_date_scale:0, #endif OTL_RCAST(OTL_SQLPOINTER,OTL_SCAST(size_t,parm_pos)), 0, v.p_len); }else{ int temp_column_size=0; #if (ODBCVER >= 0x0300) if(sqltype==SQL_TYPE_TIMESTAMP) temp_column_size=otl_odbc_date_prec; #if defined(OTL_UNICODE) else if(ftype==SQL_C_WCHAR) temp_column_size=(aelem_size-1)*sizeof(OTL_CHAR); #else else if(ftype==SQL_C_CHAR) temp_column_size=aelem_size-1; #endif else temp_column_size=aelem_size; #else if(sqltype==SQL_TIMESTAMP) temp_column_size=otl_odbc_date_prec; else if(ftype==SQL_C_CHAR) temp_column_size=aelem_size-1; else temp_column_size=aelem_size; #endif OTL_SQLINTEGER buflen=0; #if defined(OTL_UNICODE) if(ftype==SQL_C_WCHAR) buflen=aelem_size*sizeof(OTL_CHAR); else #endif buflen=aelem_size; status=SQLBindParameter (cda, OTL_SCAST(OTL_SQLUSMALLINT,parm_pos), OTL_SCAST(OTL_SQLSMALLINT,param_type), ftype, OTL_SCAST(OTL_SQLSMALLINT,mapped_sqltype), temp_column_size, #if (ODBCVER >= 0x0300) sqltype==SQL_TYPE_TIMESTAMP ? #if defined(OTL_ODBC_MULTI_MODE) ((connection_type==OTL_MSSQL_2008_ODBC_CONNECT)? 7 : (connection_type==OTL_MSSQL_2005_ODBC_CONNECT)? 3 : otl_odbc_date_scale) : 0, #else otl_odbc_date_scale : 0, #endif #else sqltype==SQL_TIMESTAMP?otl_odbc_date_scale:0, #endif OTL_RCAST(OTL_SQLPOINTER,v.p_v), buflen, v.p_len); } if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; } int bind (const int column_num, otl_var& v, const int elem_size, const int aftype, const int param_type) {SWORD ftype=OTL_SCAST(SWORD,tmpl_ftype2odbc_ftype(aftype)); v.vparam_type=param_type; SWORD ftype_save=ftype; #if defined(OTL_UNICODE) if(ftype==SQL_WLONGVARCHAR){ ftype=SQL_C_WCHAR; #else if(ftype==SQL_LONGVARCHAR){ ftype=SQL_C_CHAR; #endif }else if(ftype==SQL_LONGVARBINARY){ ftype=SQL_C_BINARY; } if(v.lob_stream_mode&& (ftype_save==SQL_LONGVARBINARY|| #if defined(OTL_UNICODE) ftype_save==SQL_WLONGVARCHAR)){ #else ftype_save==SQL_LONGVARCHAR)){ #endif // in case of "stream mode" the variable // remains unbound v.lob_ftype=ftype; v.lob_pos=column_num; return 1; }else{ SQLINTEGER buflen=elem_size; #if defined(OTL_UNICODE) if(ftype==SQL_C_WCHAR||ftype==SQL_WLONGVARCHAR) buflen=elem_size*sizeof(OTL_CHAR); #endif status=SQLBindCol (cda, OTL_SCAST(unsigned short,column_num), ftype, OTL_RCAST(PTR,v.p_v), buflen, &v.p_len[0]); if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO) return 0; else return 1; } } int describe_column (otl_column_desc& col, const int column_num, int& eof_desc) { OTL_SQLCHAR name[256]; OTL_SQLSMALLINT nlen; OTL_SQLSMALLINT dbtype; OTL_SQLLEN dbsize; OTL_SQLSMALLINT scale; OTL_SQLULEN prec; OTL_SQLSMALLINT nullok; OTL_SQLSMALLINT icols; eof_desc=0; status=SQLNumResultCols(cda,&icols); if(status!=SQL_SUCCESS&& status!=SQL_SUCCESS_WITH_INFO) return 0; if(column_num>icols){ eof_desc=1; return 0; } #if (defined(UNICODE)||defined(_UNICODE)) { SQLWCHAR temp_name[256]; status=SQLDescribeCol (cda, OTL_SCAST(unsigned short,column_num), temp_name, sizeof(temp_name), &nlen, &dbtype, &prec, &scale, &nullok); otl_convert_SQLWCHAR_to_char(OTL_RCAST(unsigned char*,name),temp_name); } #else status=SQLDescribeCol (cda, OTL_SCAST(unsigned short,column_num), name, sizeof(name), &nlen, &dbtype, &prec, &scale, &nullok); #endif if(!(status == SQL_SUCCESS || status == SQL_SUCCESS_WITH_INFO)) return 0; dbsize=prec; col.set_name(OTL_RCAST(char*,name)); #if defined(OTL_DB2_CLI) && defined(OTL_DB2_CLI_MAP_LONG_VARCHAR_TO_VARCHAR) #if defined(OTL_UNICODE) #error OTL_DB2_CLI_MAP_LONG_VARCHAR_TO_VARCHAR is not supported when \ OTL_UNICODE is defined #else if(dbtype==SQL_LONGVARCHAR && dbsize <= OTL_DB2_CLI_MAP_LONG_VARCHAR_TO_VARCHAR){ dbtype=SQL_VARCHAR; } #endif #endif col.dbtype=dbtype; col.dbsize=dbsize; col.scale=scale; col.prec=prec; col.nullok=nullok; return 1; } void error(otl_exc& exception_struct) {OTL_SQLRETURN rc; OTL_SQLSMALLINT msg_len=0; #if (ODBCVER >= 0x0300) #if (defined(UNICODE)||defined(_UNICODE)) { #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) rc=SQLGetDiagRec (SQL_HANDLE_STMT, cda, 1, &exception_struct.sqlstate[0], OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code), &exception_struct.msg[0], SQL_MAX_MESSAGE_LENGTH-1, OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len)); exception_struct.msg[msg_len]=0; #else SQLWCHAR temp_sqlstate[1000]; SQLWCHAR temp_msg[SQL_MAX_MESSAGE_LENGTH]; rc=SQLGetDiagRec (SQL_HANDLE_STMT, cda, 1, temp_sqlstate, OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code), temp_msg, SQL_MAX_MESSAGE_LENGTH-1, OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len)); temp_msg[msg_len]=0; otl_convert_SQLWCHAR_to_char (OTL_RCAST(unsigned char*,&exception_struct.sqlstate[0]), temp_sqlstate); otl_convert_SQLWCHAR_to_char (OTL_RCAST(unsigned char*,&exception_struct.msg[0]), temp_msg); #endif } #else void* temp_ptr=&exception_struct.code; rc=SQLGetDiagRec (SQL_HANDLE_STMT, cda, 1, OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.sqlstate[0]), OTL_RCAST(OTL_SQLINTEGER_PTR,temp_ptr), OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.msg[0]), SQL_MAX_MESSAGE_LENGTH-1, OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len)); #endif #else rc=SQLError(adb->henv, adb->hdbc, cda, OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.sqlstate[0]), OTL_RCAST(OTL_SQLINTEGER_PTR,&exception_struct.code), OTL_RCAST(OTL_SQLCHAR_PTR,&exception_struct.msg[0]), SQL_MAX_MESSAGE_LENGTH-1, OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len)); #endif exception_struct.msg[msg_len]=0; if(rc==SQL_INVALID_HANDLE||rc==SQL_ERROR) exception_struct.msg[0]=0; #if (ODBCVER >= 0x0300) #if defined(OTL_EXTENDED_EXCEPTION) else if(rc!=SQL_NO_DATA) otl_fill_exception(exception_struct,cda,SQL_HANDLE_STMT); #endif #endif } private: otl_cur(const otl_cur&): otl_cur0(), status(0), adb(0), direct_exec_flag(0), _rpc(0), canceled(false), last_iters(0) { } otl_cur& operator=(const otl_cur&) { return *this; } }; class otl_sel{ private: int implicit_cursor; int status; int prefetch_array_size; #if defined(OTL_ODBC_UNIX) #if defined(SIZEOF_LONG) #if (SIZEOF_LONG==8) #if !defined(BUILD_REAL_64_BIT_MODE) OTL_SQLULEN crow; #else OTL_SQLUINTEGER crow; #endif #else // (SIZEOF_LONG==8) OTL_SQLULEN crow; #endif #else // defined(SIZEOF_LONG) OTL_SQLULEN crow; #endif #else // defined(OTL_ODBC_UNIX) OTL_SQLULEN crow; #endif int in_sequence; #if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) || (ODBCVER<0x0300) OTL_SQLUSMALLINT* row_status; int row_status_arr_size; #endif public: int get_implicit_cursor() const {return implicit_cursor; } void set_arr_size (const int input_arr_size, int& out_array_size, int& out_prefetch_array_size) { #if defined(OTL_ODBC_TIMESTEN) out_array_size=1; out_prefetch_array_size=input_arr_size; #else out_array_size=input_arr_size; out_prefetch_array_size=0; #endif } int close_select(otl_cur& cur) { if(!in_sequence)return 1; #if defined(OTL_DB2_CLI) status=SQLCloseCursor(cur.cda); #else status=SQLFreeStmt(cur.cda,SQL_CLOSE); #endif in_sequence=0; if(status==SQL_ERROR) return 0; else return 1; } otl_sel(): implicit_cursor(0), status(0), prefetch_array_size(0), crow(0), in_sequence(0) #if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) || (ODBCVER<0x0300) ,row_status(0) ,row_status_arr_size(0) #endif { } virtual ~otl_sel() { #if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) || (ODBCVER<0x0300) if(row_status!=0){ delete[] row_status; row_status=0; row_status_arr_size=0; } #endif } #if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) || (ODBCVER<0x0300) void alloc_row_status(const int array_size) { if(row_status==0){ row_status=new OTL_SQLUSMALLINT[array_size]; row_status_arr_size=array_size; memset(row_status,0,sizeof(OTL_SQLUSMALLINT)*array_size); }else if(row_status!=0 && array_size!=row_status_arr_size){ delete[] row_status; row_status=new OTL_SQLUSMALLINT[array_size]; row_status_arr_size=array_size; memset(row_status,0,sizeof(OTL_SQLUSMALLINT)*array_size); } } #endif void set_select_type(const int atype) { implicit_cursor=atype; } void init(const int /* array_size */) { } void set_prefetch_size(const int aprefetch_array_size) { prefetch_array_size=aprefetch_array_size; } int first (otl_cur& cur, int& cur_row, int& cur_size, int& row_count, int& eof_data, const int #if !defined(OTL_ODBC_XTG_IBASE6) array_size #endif ) { #if defined(OTL_ODBC_XTG_IBASE6) cur_row=-1; eof_data=0; if(!implicit_cursor){ status=SQLExecute(cur.cda); if(cur.canceled)return 0; #if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO) if(cur.adb && cur.adb->throws_on_sql_success_with_info && status==SQL_SUCCESS_WITH_INFO) return 0; #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; } crow=0; status=SQLFetch(cur.cda); if(cur.canceled)return 0; if(status==SQL_SUCCESS||status==SQL_SUCCESS_WITH_INFO){ crow=1; in_sequence=1; } #else #if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) alloc_row_status(array_size); #endif cur_row=-1; eof_data=0; #if (ODBCVER >= 0x0300) status=SQLSetStmtAttr (cur.cda, SQL_ATTR_ROW_ARRAY_SIZE, OTL_RCAST(void*,OTL_SCAST(size_t,array_size)), SQL_NTS); #else #if defined(OTL_ODBC_TIMESTEN) status=SQLSetStmtOption(cur.cda,TT_PREFETCH_COUNT,prefetch_array_size); #else status=SQLSetStmtOption(cur.cda,SQL_ROWSET_SIZE,array_size); #endif #endif if(cur.canceled)return 0; if(status!=SQL_SUCCESS&& status!=SQL_SUCCESS_WITH_INFO) return 0; #if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) #else #if (ODBCVER >= 0x0300) status=SQLSetStmtAttr(cur.cda,SQL_ATTR_ROWS_FETCHED_PTR,&crow,SQL_NTS); if(cur.canceled)return 0; if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; #else #endif #endif if(!implicit_cursor){ status=SQLExecute(cur.cda); if(cur.canceled)return 0; #if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO) if(cur.adb && cur.adb->throws_on_sql_success_with_info && status==SQL_SUCCESS_WITH_INFO) return 0; #endif if(status!=SQL_SUCCESS&&status!=SQL_SUCCESS_WITH_INFO)return 0; } #if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) if(array_size==1){ crow=0; status=SQLFetch(cur.cda); if(cur.canceled)return 0; if(status==SQL_SUCCESS||status==SQL_SUCCESS_WITH_INFO){ crow=1; in_sequence=1; } }else{ status=SQLExtendedFetch (cur.cda, SQL_FETCH_NEXT, 1, &crow, row_status); } #else #if (ODBCVER >= 0x0300) status=SQLFetchScroll(cur.cda,SQL_FETCH_NEXT,1); #else { alloc_row_status(array_size); status=SQLExtendedFetch (cur.cda, SQL_FETCH_NEXT, 1, &crow, row_status); } #endif #endif #endif in_sequence=1; if(cur.canceled)return 0; if(status==SQL_ERROR|| status==SQL_INVALID_HANDLE) return 0; if(status==SQL_NO_DATA_FOUND){ eof_data=1; cur_row=-1; crow=0; row_count=0; cur_size=0; #if defined(OTL_DB2_CLI) status=SQLCloseCursor(cur.cda); #else status=SQLFreeStmt(cur.cda,SQL_CLOSE); #endif in_sequence=0; if(status==SQL_ERROR)return 0; return 1; } row_count=OTL_SCAST(int,crow); cur_size=row_count; if(cur_size!=0)cur_row=0; return 1; } #if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) int next (otl_cur& cur, int& cur_row, int& cur_size, int& row_count, int& eof_data, const int array_size) { alloc_row_status(array_size); #else int next (otl_cur& cur, int& cur_row, int& cur_size, int& row_count, int& eof_data, #if (ODBCVER >= 0x0300) const int /* array_size */) #else const int array_size) #endif { #endif if(cur_row= 0x0300) status=SQLFetchScroll(cur.cda,SQL_FETCH_NEXT,1); #else { alloc_row_status(array_size); status=SQLExtendedFetch (cur.cda, SQL_FETCH_NEXT, 1, &crow, row_status); } #endif #endif in_sequence=1; if(cur.canceled)return 0; if(status==SQL_ERROR|| // status==SQL_SUCCESS_WITH_INFO|| status==SQL_INVALID_HANDLE) return 0; if(status==SQL_NO_DATA_FOUND){ eof_data=1; cur_row=-1; cur_size=0; in_sequence=0; #if defined(OTL_DB2_CLI) status=SQLCloseCursor(cur.cda); #else status=SQLFreeStmt(cur.cda,SQL_CLOSE); #endif if(status==SQL_ERROR)return 0; return 1; } cur_size=OTL_SCAST(int,crow); row_count+=OTL_SCAST(int,crow); if(cur_size!=0)cur_row=0; return 1; } } private: otl_sel(const otl_sel&): implicit_cursor(0), status(0), prefetch_array_size(0), crow(0), in_sequence(0) #if defined(OTL_ODBC_SQL_EXTENDED_FETCH_ON) || (ODBCVER<0x0300) ,row_status(0) ,row_status_arr_size(0) #endif { } otl_sel& operator=(const otl_sel&) { return *this; } }; typedef otl_tmpl_connect otl_odbc_connect; typedef otl_tmpl_cursor otl_cursor; typedef otl_tmpl_exception otl_exception; typedef otl_tmpl_select_stream otl_select_stream; typedef otl_tmpl_inout_stream otl_inout_stream; class otl_stream; class otl_connect: public otl_odbc_connect{ public: void set_connection_mode(const int connection_mode) { connect_struct.connection_type=connection_mode; } int get_connection_mode(void) { return connect_struct.connection_type; } protected: friend class otl_stream; #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) otl_stream_pool sc; #endif public: #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) void set_stream_pool_size(const int max_size=otl_max_default_pool_size) { sc.init(max_size); } #endif void commit(void) { #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(!auto_commit_){ (*this)<<"commit tran"; otl_odbc_connect::commit(); (*this)<<"begin tran"; } #else otl_odbc_connect::commit(); #endif } void rollback(void) { #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(!auto_commit_){ (*this)<<"rollback tran"; otl_odbc_connect::rollback(); (*this)<<"begin tran"; } #else otl_odbc_connect::rollback(); #endif } long direct_exec (const char* sqlstm, const int exception_enabled=1) OTL_THROWS_OTL_EXCEPTION { return otl_cursor::direct_exec(*this,sqlstm,exception_enabled); } void syntax_check(const char* sqlstm) OTL_THROWS_OTL_EXCEPTION { otl_cursor::syntax_check(*this,sqlstm); } otl_connect() OTL_NO_THROW : otl_odbc_connect(), #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) sc(), #endif cmd_(0) #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) ,auto_commit_(false) #endif { } otl_connect(const char* connect_str, const int aauto_commit=0) OTL_THROWS_OTL_EXCEPTION: otl_odbc_connect(connect_str, aauto_commit), #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) sc(), #endif cmd_(0) #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) ,auto_commit_(false) #endif { #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(aauto_commit) auto_commit_=true; else auto_commit_=false; #endif } otl_connect(OTL_HENV ahenv,OTL_HDBC ahdbc,const int auto_commit=0) OTL_THROWS_OTL_EXCEPTION: otl_odbc_connect(), #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) sc(), #endif cmd_(0) #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) ,auto_commit_(false) #endif { #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(auto_commit) auto_commit_=true; else auto_commit_=false; #endif rlogon(ahenv,ahdbc,auto_commit); } const char* getCmd(void) const { return cmd_; } otl_connect& operator<<(const char* cmd) { if(!connected){ this->rlogon(cmd); }else{ otl_cursor::direct_exec(*this,cmd); } return *this; } otl_connect& operator<<=(const char* cmd) { if(cmd_){ delete[] cmd_; cmd_=0; } size_t cmd_len=strlen(cmd); cmd_=new char[cmd_len+1]; OTL_STRCPY_S(cmd_,cmd_len+1,cmd); return *this; } #if defined(OTL_THROWS_ON_SQL_SUCCESS_WITH_INFO) void set_throw_on_sql_success_with_info(const bool throw_flag=false) { this->get_connect_struct().throws_on_sql_success_with_info=throw_flag; } #endif void rlogon(OTL_HENV ahenv,OTL_HDBC ahdbc,const int auto_commit=0) OTL_THROWS_OTL_EXCEPTION { if(this->connected){ throw otl_exception(otl_error_msg_30,otl_error_code_30); } if(cmd_){ delete[] cmd_; cmd_=0; } #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(auto_commit) auto_commit_=true; else auto_commit_=false; #endif retcode=connect_struct.ext_logon(ahenv,ahdbc,auto_commit); if(retcode) connected=1; else{ connected=0; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(!auto_commit_){ (*this)<<"begin tran"; } #endif } #if defined(OTL_UNICODE_EXCEPTION_AND_RLOGON) void rlogon(const OTL_UNICODE_CHAR_TYPE* username, const OTL_UNICODE_CHAR_TYPE* passwd, const OTL_UNICODE_CHAR_TYPE* dns, const int auto_commit=0) OTL_THROWS_OTL_EXCEPTION { if(this->connected){ throw otl_exception(otl_error_msg_30,otl_error_code_30); } #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(auto_commit) auto_commit_=true; else auto_commit_=false; #endif retcode=connect_struct.rlogon (OTL_RCAST(const SQLWCHAR*,username), OTL_RCAST(const SQLWCHAR*,passwd), OTL_RCAST(const SQLWCHAR*,dns), auto_commit); if(retcode) connected=1; else{ connected=0; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(!auto_commit_){ (*this)<<"begin tran"; } #endif } #endif virtual ~otl_connect() #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) OTL_THROWS_OTL_EXCEPTION #endif { if(cmd_){ delete[] cmd_; cmd_=0; } #if defined(OTL_DESTRUCTORS_DO_NOT_THROW) try{ logoff(); }catch(OTL_CONST_EXCEPTION otl_exception&){ } #endif } void rlogon(const char* connect_str, const int aauto_commit=0) OTL_THROWS_OTL_EXCEPTION { if(this->connected){ throw otl_exception(otl_error_msg_30,otl_error_code_30); } if(cmd_){ delete[] cmd_; cmd_=0; } #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(aauto_commit) auto_commit_=true; else auto_commit_=false; #endif otl_odbc_connect::rlogon(connect_str,aauto_commit); #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(!auto_commit_){ (*this)<<"begin tran"; } #endif } void logoff(void) OTL_THROWS_OTL_EXCEPTION { #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) if(connected) sc.init(sc.get_max_size()); #endif #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) if(!auto_commit_) rollback(); #endif otl_odbc_connect::logoff(); } void set_transaction_isolation_level(const long int level) OTL_THROWS_OTL_EXCEPTION { retcode=connect_struct.set_transaction_isolation_level(level); if(!retcode){ increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } } private: char* cmd_; #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) bool auto_commit_; #endif otl_connect(const otl_connect&) OTL_NO_THROW : otl_odbc_connect(), #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) sc(), #endif cmd_(0) #if defined(OTL_FREETDS_ODBC_WORKAROUNDS) ,auto_commit_(false) #endif { } otl_connect& operator=(const otl_connect&) { return *this; } }; const int otl_odbc_no_stream=0; const int otl_odbc_io_stream=1; const int otl_odbc_select_stream=2; class otl_stream_shell: public otl_stream_shell_generic{ public: otl_select_stream* ss; otl_inout_stream* io; otl_connect* adb; int auto_commit_flag; otl_var_desc* iov; int iov_len; int next_iov_ndx; otl_var_desc* ov; int ov_len; int next_ov_ndx; bool flush_flag; int stream_type; bool lob_stream_flag; otl_select_struct_override override; #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) OTL_STRING_CONTAINER orig_sql_stm; #endif otl_stream_shell(): otl_stream_shell_generic(), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), flush_flag(false), stream_type(otl_odbc_no_stream), lob_stream_flag(0), override() #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) ,orig_sql_stm() #endif { should_delete=0; } otl_stream_shell(const int ashould_delete): otl_stream_shell_generic(), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), flush_flag(true), stream_type(otl_odbc_no_stream), lob_stream_flag(false), override() #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) ,orig_sql_stm() #endif { should_delete=ashould_delete; } virtual ~otl_stream_shell() { if(should_delete){ delete[] iov; delete[] ov; iov=0; iov_len=0; ov=0; ov_len=0; next_iov_ndx=0; next_ov_ndx=0; override.setLen(0); flush_flag=true; delete ss; delete io; ss=0; io=0; adb=0; } } private: otl_stream_shell(const otl_stream_shell&): otl_stream_shell_generic(), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), flush_flag(false), stream_type(otl_odbc_no_stream), lob_stream_flag(0), override() #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) ,orig_sql_stm() #endif { should_delete=0; } otl_stream_shell& operator=(const otl_stream_shell&) { return *this; } }; template class otl_tmpl_lob_stream: public otl_lob_stream_generic{ public: typedef otl_tmpl_exception otl_exception; typedef otl_tmpl_variable* p_bind_var; typedef otl_tmpl_connect * p_connect; typedef otl_tmpl_cursor * p_cursor; private: p_bind_var bind_var; p_connect connect; p_cursor cursor; otl_long_string* temp_buf; char* temp_char_buf; bool written_to_flag; bool closed_flag; public: void init (void* avar,void* aconnect,void* acursor, int andx,int amode,const int alob_is_null=0) OTL_THROWS_OTL_EXCEPTION { closed_flag=false; if(written_to_flag){ retcode=bind_var->get_var_struct().clob_blob(cursor->get_cursor_struct()); written_to_flag=false; if(!retcode){ if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (cursor->get_cursor_struct(), cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text()); } } connect=OTL_RCAST(p_connect,aconnect); bind_var=OTL_RCAST(p_bind_var,avar); cursor=OTL_RCAST(p_cursor,acursor); mode=amode; retcode=0; lob_is_null=alob_is_null; ndx=andx; offset=0; lob_len=0; eof_flag=0; in_destructor=0; if(bind_var) bind_var->get_var_struct().set_lob_stream_flag(); } void set_len(void) OTL_NO_THROW { } void set_len(const int /*new_len*/) OTL_NO_THROW { } otl_tmpl_lob_stream() OTL_NO_THROW: otl_lob_stream_generic(false), bind_var(0), connect(0), cursor(0), temp_buf(0), temp_char_buf(0), written_to_flag(false), closed_flag(false) { init(0,0,0,0,otl_lob_stream_zero_mode); } ~otl_tmpl_lob_stream() #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) OTL_THROWS_OTL_EXCEPTION #endif { in_destructor=1; if(temp_buf){ delete temp_buf; temp_buf=0; } if(temp_char_buf){ delete[] temp_char_buf; temp_char_buf=0; } #if defined(OTL_DESTRUCTORS_DO_NOT_THROW) try{ if(!closed_flag) close(); }catch(OTL_CONST_EXCEPTION otl_exception&){ } #else if(!closed_flag) close(); #endif } #if (defined(OTL_STL) || defined(OTL_ACE) || \ defined(OTL_USER_DEFINED_STRING_CLASS_ON)) && !defined(OTL_UNICODE) otl_lob_stream_generic& operator<<(const OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION { otl_long_string temp_s(s.c_str(), OTL_SCAST(int,s.length()), OTL_SCAST(int,s.length())); (*this)<>(OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION { const int TEMP_BUF_SIZE=4096; if(!temp_char_buf)temp_char_buf=new char[TEMP_BUF_SIZE]; if(!temp_buf)temp_buf=new otl_long_string(temp_char_buf,TEMP_BUF_SIZE-1); int iters=0; while(!this->eof()){ ++iters; (*this)>>(*temp_buf); temp_char_buf[temp_buf->len()]=0; if(iters>1) s+=temp_char_buf; else s=temp_char_buf; } return *this; } #endif otl_lob_stream_generic& operator<<(const otl_long_string& s) OTL_THROWS_OTL_EXCEPTION { if(mode!=otl_lob_stream_write_mode){ const char* stm=0; char var_info[256]; var_info[0]=0; if(cursor!=0){ if(cursor->get_stm_label()) stm=cursor->get_stm_label(); else stm=cursor->get_stm_text(); } if(bind_var!=0){ otl_var_info_var (bind_var->get_name(), bind_var->get_ftype(), otl_var_long_string, var_info, sizeof(var_info)); } char* vinfo=0; if(var_info[0]!=0) vinfo=&var_info[0]; if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_tmpl_exception (otl_error_msg_9, otl_error_code_9, stm, vinfo); } if(offset==0)offset=1; retcode=bind_var->get_var_struct().write_blob (s,lob_len,offset,cursor->get_cursor_struct()); written_to_flag=true; if(retcode) return *this; if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (cursor->get_cursor_struct(), cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text()); } otl_lob_stream_generic& operator>>(otl_long_string& s) OTL_THROWS_OTL_EXCEPTION { if(mode!=otl_lob_stream_read_mode){ const char* stm=0; char var_info[256]; var_info[0]=0; if(cursor!=0){ if(cursor->get_stm_label()) stm=cursor->get_stm_label(); else stm=cursor->get_stm_text(); } if(bind_var!=0){ otl_var_info_var (bind_var->get_name(), bind_var->get_ftype(), otl_var_long_string, var_info, sizeof(var_info)); } char* vinfo=0; if(var_info[0]!=0) vinfo=&var_info[0]; if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (otl_error_msg_10, otl_error_code_10, stm, vinfo); } if(offset==0)offset=1; retcode=bind_var->get_var_struct().read_blob (cursor->get_cursor_struct(),s,ndx,offset,eof_flag); if(retcode){ if(eof()) close(); return *this; } if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw OTL_TMPL_EXCEPTION (cursor->get_cursor_struct(), cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text()); } int eof(void) OTL_NO_THROW { if(mode!=otl_lob_stream_read_mode)return 1; if(lob_is_null)return 1; return eof_flag; } int len(void) OTL_THROWS_OTL_EXCEPTION { if(cursor==0||connect==0||bind_var==0||lob_is_null)return 0; int alen; retcode=bind_var->get_var_struct().get_blob_len(ndx,alen); if(retcode)return alen; if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw OTL_TMPL_EXCEPTION (connect->get_connect_struct(), cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text()); } bool is_initialized(void) OTL_THROWS_OTL_EXCEPTION { if(cursor==0||connect==0||bind_var==0||lob_is_null) return false; else return true; } void close(void) OTL_THROWS_OTL_EXCEPTION { if(in_destructor){ if(mode==otl_lob_stream_read_mode){ bind_var->get_var_struct().set_lob_stream_flag(0); bind_var->set_not_null(0); } if(mode==otl_lob_stream_write_mode){ retcode=bind_var->get_var_struct().clob_blob(cursor->get_cursor_struct()); closed_flag=true; written_to_flag=false; if(!retcode){ if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (cursor->get_cursor_struct(), cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text()); } } return; } if(mode==otl_lob_stream_zero_mode)return; if(mode==otl_lob_stream_read_mode){ bind_var->get_var_struct().set_lob_stream_flag(0); bind_var->set_not_null(0); init(0,0,0,0,otl_lob_stream_zero_mode); }else{ // write mode if(mode==otl_lob_stream_write_mode){ retcode=bind_var->get_var_struct().clob_blob(cursor->get_cursor_struct()); written_to_flag=false; closed_flag=true; if(!retcode){ if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw OTL_TMPL_EXCEPTION (cursor->get_cursor_struct(), cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text()); } } bind_var->get_var_struct().set_lob_stream_flag(0); bind_var->set_not_null(0); } } private: otl_tmpl_lob_stream(const otl_tmpl_lob_stream&) OTL_NO_THROW: otl_lob_stream_generic(false), bind_var(0), connect(0), cursor(0), temp_buf(0), temp_char_buf(0), written_to_flag(false), closed_flag(false) { } otl_tmpl_lob_stream& operator=(const otl_tmpl_lob_stream&) { return *this; } }; typedef otl_tmpl_lob_stream otl_lob_stream; class otl_stream{ private: otl_stream_shell* shell; otl_ptr shell_pt; int connected; otl_select_stream** ss; otl_inout_stream** io; otl_connect** adb; int* auto_commit_flag; otl_var_desc** iov; int* iov_len; int* next_iov_ndx; otl_var_desc** ov; int* ov_len; int* next_ov_ndx; otl_select_struct_override* override; int end_marker; int oper_int_called; int last_eof_rc; bool last_oper_was_read_op; public: #if defined(OTL_ODBC_SQL_STATEMENT_WITH_DIAG_REC_OUTPUT) OTL_SQLHSTMT get_stm_handle(){return (*io)->get_cursor_struct().get_cda();} #if defined(_UNICODE) || defined(UNICODE) typedef SQLWCHAR sqlchar_type; #else typedef SQLCHAR sqlchar_type; #endif bool get_next_diag_rec (short int& rec_ndx, sqlchar_type* sqlstate_buf, sqlchar_type* msg_buf, short int msg_buf_size, int& native_err) { OTL_SQLINTEGER rc; SQLSMALLINT msg_len; rc=SQLGetDiagRec (SQL_HANDLE_STMT, get_stm_handle(), OTL_SCAST(OTL_SQLSMALLINT,rec_ndx), OTL_RCAST(sqlchar_type*,sqlstate_buf), OTL_RCAST(OTL_SQLINTEGER_PTR,&native_err), OTL_RCAST(sqlchar_type*,msg_buf), msg_buf_size, OTL_RCAST(OTL_SQLSMALLINT_PTR,&msg_len)); bool result=rc==SQL_NO_DATA||rc<0; msg_buf[msg_len]=0; ++rec_ndx; return result; } #endif protected: int buf_size_; void reset_end_marker(void) { last_eof_rc=0; end_marker=-1; oper_int_called=0; } void throw_end_of_row() #if defined(__GNUC__) && (__GNUC__>=4) __attribute__ ((noreturn)) #endif { throw otl_exception (otl_error_msg_34, otl_error_code_34, this->get_stm_text()); } public: int get_prefetched_row_count() const { if(*ss){ (*adb)->reset_throw_count(); return (*ss)->get_prefetched_row_count(); } return 0; } bool get_lob_stream_flag() const { if(!shell) return false; else return shell->lob_stream_flag; } int get_adb_max_long_size() const { return this->shell->adb->get_max_long_size(); } void check_end_of_row() { if(next_ov_ndx==0||(*next_ov_ndx)!=0) throw_end_of_row(); if(next_iov_ndx==0||(*next_iov_ndx)!=0) throw_end_of_row(); } otl_stream_shell* get_shell(){return shell;} int get_connected() const {return connected;} int get_dirty_buf_len() const { switch(shell->stream_type){ case otl_odbc_no_stream: return 0; case otl_odbc_io_stream: return (*io)->get_dirty_buf_len(); case otl_odbc_select_stream: return (*ss)->get_select_row_count(); default: return 0; } } const char* get_stm_text(void) { const char* no_stm_text=OTL_NO_STM_TEXT; switch(shell->stream_type){ case otl_odbc_no_stream: return no_stm_text; case otl_odbc_io_stream: return (*io)->get_stm_label()?(*io)->get_stm_label():(*io)->get_stm_text(); case otl_odbc_select_stream: return (*ss)->get_stm_label()?(*ss)->get_stm_label():(*ss)->get_stm_text(); default: return no_stm_text; } } void setBufSize(int buf_size) { buf_size_=buf_size; } int getBufSize(void) const { return buf_size_; } long get_rpc() OTL_THROWS_OTL_EXCEPTION { if((*io)){ (*adb)->reset_throw_count(); return (*io)->get_rpc(); }else if((*ss)){ (*adb)->reset_throw_count(); return (*ss)->get_rfc(); }else return 0; } void skip_to_end_of_row() { if(next_ov_ndx==0) return; if((*ov_len)==0)return; last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->skip_to_end_of_row(); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->skip_to_end_of_row(); break; } while ((*next_ov_ndx)<(*ov_len)-1) ++(*next_ov_ndx); } operator int(void) OTL_THROWS_OTL_EXCEPTION { if(shell && shell->lob_stream_flag){ if(this->adb&&*this->adb)(*this->adb)->increment_throw_count(); if(this->adb&&*this->adb&&(*this->adb)->get_throw_count()>1)return 0; const char* stm_label=0; const char* stm_text=0; if((*io)){ stm_label=(*io)->get_stm_label(); stm_text=(*io)->get_stm_text(); }else if((*ss)){ stm_label=(*ss)->get_stm_label(); stm_text=(*ss)->get_stm_text(); } throw otl_exception (otl_error_msg_24, otl_error_code_24, stm_label?stm_label:stm_text); } if(!last_oper_was_read_op){ if(this->adb&&*this->adb)(*this->adb)->increment_throw_count(); if(this->adb&&*this->adb&&(*this->adb)->get_throw_count()>1)return 0; const char* stm_label=0; const char* stm_text=0; if((*io)){ stm_label=(*io)->get_stm_label(); stm_text=(*io)->get_stm_text(); }else if((*ss)){ stm_label=(*ss)->get_stm_label(); stm_text=(*ss)->get_stm_text(); } throw otl_exception (otl_error_msg_18, otl_error_code_18, stm_label?stm_label:stm_text); } if(end_marker==1)return 0; int rc=0; int temp_eof=eof(); if(temp_eof && end_marker==-1 && oper_int_called==0){ end_marker=1; if(last_eof_rc==1) rc=0; else rc=1; }else if(!temp_eof && end_marker==-1) rc=1; else if(temp_eof && end_marker==-1){ end_marker=0; rc=1; }else if(temp_eof && end_marker==0){ end_marker=1; rc=0; } if(!oper_int_called)oper_int_called=1; return rc; } void cancel(void) OTL_THROWS_OTL_EXCEPTION { if((*ss)){ (*adb)->reset_throw_count(); int status=(*ss)->get_cursor_struct().cancel(); if(status==0) throw otl_exception((*ss)->get_cursor_struct()); }else if((*io)){ (*adb)->reset_throw_count(); int status=(*io)->get_cursor_struct().cancel(); if(status==0) throw otl_exception((*io)->get_cursor_struct()); } } void create_var_desc(void) {int i; delete[] (*iov); delete[] (*ov); (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; if((*ss)){ if((*ss)->get_vl_len()>0){ (*iov)=new otl_var_desc[(*ss)->get_vl_len()]; (*iov_len)=(*ss)->get_vl_len(); for(i=0;i<(*ss)->get_vl_len();++i) (*ss)->get_vl()[i]->copy_var_desc((*iov)[i]); } if((*ss)->get_sl_len()>0){ (*ov)=new otl_var_desc[(*ss)->get_sl_len()]; (*ov_len)=(*ss)->get_sl_len(); for(i=0;i<(*ss)->get_sl_len();++i){ (*ss)->get_sl()[i].copy_var_desc((*ov)[i]); if((*ss)->get_sl_desc()!=0) (*ov)[i].copy_name((*ss)->get_sl_desc()[i].name); } } }else if((*io)){ if((*io)->get_vl_len()>0){ (*iov)=new otl_var_desc[(*io)->get_vl_len()]; (*iov_len)=(*io)->get_vl_len(); for(i=0;i<(*io)->get_vl_len();++i) (*io)->get_vl()[i]->copy_var_desc((*iov)[i]); } if((*io)->get_iv_len()>0){ (*ov)=new otl_var_desc[(*io)->get_iv_len()]; (*ov_len)=(*io)->get_iv_len(); for(i=0;i<(*io)->get_iv_len();++i) (*io)->get_in_vl()[i]->copy_var_desc((*ov)[i]); } } } void set_column_type(const int column_ndx, const int col_type, const int col_size=0) OTL_NO_THROW { if(shell==0){ init_stream(); shell->flush_flag=true; } override->add_override(column_ndx,col_type,col_size); } void set_all_column_types(const unsigned mask=0) OTL_NO_THROW { if(shell==0){ init_stream(); shell->flush_flag=true; } override->set_all_column_types(mask); } void set_flush(const bool flush_flag=true) OTL_NO_THROW { if(shell==0)init_stream(); shell->flush_flag=flush_flag; } void set_lob_stream_mode(const bool lob_stream_flag=false) OTL_NO_THROW { if(shell==0)return; shell->lob_stream_flag=lob_stream_flag; } void inc_next_ov(void) { if((*ov_len)==0)return; if((*next_ov_ndx)<(*ov_len)-1) ++(*next_ov_ndx); else (*next_ov_ndx)=0; } void inc_next_iov(void) { if((*iov_len)==0)return; if((*next_iov_ndx)<(*iov_len)-1) ++(*next_iov_ndx); else (*next_iov_ndx)=0; } otl_var_desc* describe_in_vars(int& desc_len) OTL_NO_THROW { desc_len=0; if(shell==0)return 0; if(shell->iov==0)return 0; desc_len=shell->iov_len; return shell->iov; } otl_var_desc* describe_out_vars(int& desc_len) OTL_NO_THROW { desc_len=0; if(shell==0)return 0; if(shell->ov==0)return 0; desc_len=shell->ov_len; return shell->ov; } otl_var_desc* describe_next_in_var(void) OTL_NO_THROW { if(shell==0)return 0; if(shell->iov==0)return 0; return &(shell->iov[shell->next_iov_ndx]); } otl_var_desc* describe_next_out_var(void) OTL_NO_THROW { if(shell==0)return 0; if(shell->ov==0)return 0; return &(shell->ov[shell->next_ov_ndx]); } void init_stream(void) { buf_size_=1; last_oper_was_read_op=false; shell=0; shell=new otl_stream_shell(0); shell_pt.assign(&shell); connected=0; ss=&(shell->ss); io=&(shell->io); adb=&(shell->adb); auto_commit_flag=&(shell->auto_commit_flag); iov=&(shell->iov); iov_len=&(shell->iov_len); next_iov_ndx=&(shell->next_iov_ndx); ov=&(shell->ov); ov_len=&(shell->ov_len); next_ov_ndx=&(shell->next_ov_ndx); override=&(shell->override); (*io)=0; (*ss)=0; (*adb)=0; (*ov)=0; (*ov_len)=0; (*next_iov_ndx)=0; (*next_ov_ndx)=0; (*auto_commit_flag)=1; (*iov)=0; (*iov_len)=0; } otl_stream (const otl_stream_buffer_size_type arr_size, const char* sqlstm, otl_connect& db, const int implicit_select=otl_explicit_select, const char* sqlstm_label=0) OTL_THROWS_OTL_EXCEPTION: shell(0), shell_pt(), connected(0), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), override(0), end_marker(0), oper_int_called(0), last_eof_rc(0), last_oper_was_read_op(false), buf_size_(0) { init_stream(); (*io)=0; (*ss)=0; (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; (*auto_commit_flag)=1; (*next_iov_ndx)=0; (*next_ov_ndx)=0; (*adb)=&db; shell->flush_flag=true; open(arr_size,sqlstm,db,implicit_select,sqlstm_label); } otl_stream() OTL_NO_THROW: shell(0), shell_pt(), connected(0), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), override(0), end_marker(0), oper_int_called(0), last_eof_rc(0), last_oper_was_read_op(false), buf_size_(0) { init_stream(); shell->flush_flag=true; } virtual ~otl_stream() #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) OTL_THROWS_OTL_EXCEPTION #endif { if(!connected)return; try{ if((*io)!=0&&shell->flush_flag==false) (*io)->set_flush_flag2(false); close(); if(shell!=0){ if((*io)!=0) (*io)->set_flush_flag2(true); } }catch(OTL_CONST_EXCEPTION otl_exception&){ if(shell!=0){ if((*io)!=0) (*io)->set_flush_flag2(true); } #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) clean(1); if(shell!=0) shell->set_should_delete(1); shell_pt.destroy(); #else shell_pt.destroy(); #endif #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) throw; #endif } #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) if((adb && (*adb) && (*adb)->get_throw_count()>0) #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) || otl_uncaught_exception() #endif ){ // } #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) if(otl_uncaught_exception()){ // } #else shell_pt.destroy(); #endif } int eof(void) OTL_NO_THROW { if((*io)){ (*adb)->reset_throw_count(); return (*io)->eof(); }else if((*ss)){ (*adb)->reset_throw_count(); return (*ss)->eof(); }else return 1; } void reset_to_last_valid_row() { if((*io)){ (*adb)->reset_throw_count(); (*io)->reset_to_last_valid_row(); } } void flush(void) OTL_THROWS_OTL_EXCEPTION { if((*io)){ (*adb)->reset_throw_count(); (*io)->flush(); } } void clean(const int clean_up_error_flag=0) OTL_THROWS_OTL_EXCEPTION { if((*io)){ (*adb)->reset_throw_count(); (*io)->clean(clean_up_error_flag); }else if((*ss)){ (*adb)->reset_throw_count(); (*ss)->clean(); } } void rewind(void) OTL_THROWS_OTL_EXCEPTION { if((*io)){ (*adb)->reset_throw_count(); (*io)->rewind(); }else if((*ss)){ (*adb)->reset_throw_count(); (*ss)->rewind(); } } int is_null(void) OTL_NO_THROW { if((*io)) return (*io)->is_null(); else if((*ss)) return (*ss)->is_null(); else return 0; } void set_commit(int auto_commit=0) OTL_NO_THROW { (*auto_commit_flag)=auto_commit; if((*io)){ (*adb)->reset_throw_count(); (*io)->set_commit(auto_commit); } } const char* assign_stream_type (const char* stm_text, const char* stm_label) { const char* temp_stm_text=0; temp_stm_text=stm_label?stm_label:stm_text; return temp_stm_text; } void open (const otl_stream_buffer_size_type arr_size, const char* sqlstm, otl_connect& db, const int implicit_select=otl_explicit_select, const char* sqlstm_label=0) OTL_THROWS_OTL_EXCEPTION { reset_end_marker(); otl_stream_buffer_size_type temp_arr_size=arr_size; if(this->good()){ const char* temp_stm_text=assign_stream_type(sqlstm,sqlstm_label); throw otl_exception (otl_error_msg_29, otl_error_code_29, temp_stm_text); } if(shell==0) init_stream(); buf_size_=arr_size; OTL_TRACE_STREAM_OPEN #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) char temp_buf[128]; otl_itoa(arr_size,temp_buf); OTL_STRING_CONTAINER sql_stm= OTL_STRING_CONTAINER(temp_buf)+ OTL_STRING_CONTAINER("===>")+ sqlstm; otl_stream_shell* temp_shell=OTL_RCAST(otl_stream_shell*,db.sc.find(sql_stm)); if(temp_shell){ if(shell!=0)shell_pt.destroy(); shell=temp_shell; ss=&(shell->ss); io=&(shell->io); if((*io)!=0)(*io)->set_flush_flag2(true); adb=&(shell->adb); auto_commit_flag=&(shell->auto_commit_flag); iov=&(shell->iov); iov_len=&(shell->iov_len); next_iov_ndx=&(shell->next_iov_ndx); ov=&(shell->ov); ov_len=&(shell->ov_len); next_ov_ndx=&(shell->next_ov_ndx); override=&(shell->override); try{ if((*iov_len)==0)this->rewind(); }catch(OTL_CONST_EXCEPTION otl_exception&){ if((*adb)) (*adb)->sc.remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; throw; } connected=1; return; } shell->orig_sql_stm=sql_stm; #endif delete[] (*iov); delete[] (*ov); (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; (*next_iov_ndx)=0; (*next_ov_ndx)=0; char tmp[7]; char* c=OTL_CCAST(char*,sqlstm); override->set_lob_stream_mode(shell->lob_stream_flag); while(otl_isspace(*c)||(*c)=='(')++c; OTL_STRNCPY_S(tmp,sizeof(tmp),c,6); tmp[6]=0; c=tmp; while(*c){ *c=OTL_SCAST(char,otl_to_upper(*c)); ++c; } if(adb==0)adb=&(shell->adb); (*adb)=&db; (*adb)->reset_throw_count(); try{ #if (defined(OTL_ODBC_POSTGRESQL) && !defined(OTL_ODBC_ALTERNATE_RPC) || \ defined(OTL_ODBC_SELECT_STM_EXECUTE_BEFORE_DESCRIBE)) && \ !defined(OTL_ODBC_MULTI_MODE) if((strncmp(tmp,"SELECT",6)==0|| strncmp(tmp,"WITH",4)==0)){ override->set_master_stream_ptr(OTL_RCAST(void*,this)); (*ss)=new otl_select_stream(override, temp_arr_size, sqlstm, db,otl_implicit_select, sqlstm_label); shell->stream_type=otl_odbc_select_stream; } #elif defined(OTL_ODBC_MULTI_MODE) #if defined(OTL_ODBC_ALTERNATE_RPC) bool alternate_rpc=true; #else bool alternate_rpc=false; #endif int connect_type=(*adb)->get_connect_struct().get_connection_type(); if((connect_type==OTL_POSTGRESQL_ODBC_CONNECT&&!alternate_rpc || connect_type==OTL_ENTERPRISE_DB_ODBC_CONNECT || connect_type==OTL_MYODBC35_ODBC_CONNECT) && (strncmp(tmp,"SELECT",6)==0|| strncmp(tmp,"WITH",4)==0)){ override->set_master_stream_ptr(OTL_RCAST(void*,this)); (*ss)=new otl_select_stream(override, temp_arr_size, sqlstm, db,otl_implicit_select, sqlstm_label); shell->stream_type=otl_odbc_select_stream; }else if((strncmp(tmp,"SELECT",6)==0|| strncmp(tmp,"WITH",4)==0)&& !implicit_select){ (*ss)=new otl_select_stream(override,temp_arr_size,sqlstm, db,otl_explicit_select, sqlstm_label); shell->stream_type=otl_odbc_select_stream; } #else if((strncmp(tmp,"SELECT",6)==0|| strncmp(tmp,"WITH",4)==0)&& !implicit_select){ #if defined(OTL_ODBC_TIMESTEN) if(temp_arr_size>128||temp_arr_size<0){ const char* temp_stm_text=assign_stream_type(sqlstm,sqlstm_label); throw otl_exception (otl_error_msg_31, otl_error_code_31, temp_stm_text); } #endif override->set_master_stream_ptr(OTL_RCAST(void*,this)); (*ss)=new otl_select_stream(override,temp_arr_size,sqlstm, db,otl_explicit_select, sqlstm_label); shell->stream_type=otl_odbc_select_stream; } #endif else if(tmp[0]=='$'){ override->set_master_stream_ptr(OTL_RCAST(void*,this)); (*ss)=new otl_select_stream (override,temp_arr_size, sqlstm,db, 1,sqlstm_label); shell->stream_type=otl_odbc_select_stream; }else{ if(implicit_select){ #if defined(OTL_ODBC_TIMESTEN) if(temp_arr_size>128||temp_arr_size<0){ const char* temp_stm_text=assign_stream_type(sqlstm,sqlstm_label); throw otl_exception (otl_error_msg_31, otl_error_code_31, temp_stm_text); } #endif override->set_master_stream_ptr(OTL_RCAST(void*,this)); (*ss)=new otl_select_stream(override,temp_arr_size, sqlstm,db, 1,sqlstm_label); shell->stream_type=otl_odbc_select_stream; }else{ (*io)=new otl_inout_stream (arr_size,sqlstm,db, OTL_RCAST(void*,this), shell->lob_stream_flag, sqlstm_label); (*io)->set_flush_flag(shell->flush_flag); shell->stream_type=otl_odbc_io_stream; } } }catch(OTL_CONST_EXCEPTION otl_exception&){ shell_pt.destroy(); throw; } if((*io))(*io)->set_commit((*auto_commit_flag)); create_var_desc(); connected=1; } void intern_cleanup(void) { delete[] (*iov); delete[] (*ov); (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; (*next_iov_ndx)=0; (*next_ov_ndx)=0; override->setLen(0); override->set_lob_stream_mode(false); switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: try{ (*io)->flush(); (*io)->close(); }catch(OTL_CONST_EXCEPTION otl_exception&){ clean(1); (*io)->close(); delete (*io); (*io)=0; shell->stream_type=otl_odbc_no_stream; throw; } delete (*io); (*io)=0; shell->stream_type=otl_odbc_no_stream; break; case otl_odbc_select_stream: try{ (*ss)->close(); }catch(OTL_CONST_EXCEPTION otl_exception&){ delete (*ss); (*ss)=0; shell->stream_type=otl_odbc_no_stream; throw; } delete (*ss); (*ss)=0; shell->stream_type=otl_odbc_no_stream; break; } (*ss)=0; (*io)=0; if(adb!=0)(*adb)=0; adb=0; } #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) void close(const bool save_in_stream_pool=true) OTL_THROWS_OTL_EXCEPTION #else void close(void) OTL_THROWS_OTL_EXCEPTION #endif { if(shell==0)return; OTL_TRACE_FUNC(0x4,"otl_stream","close","") #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) if(save_in_stream_pool&&(*adb)&& #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) !(otl_uncaught_exception())&& #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) !(otl_uncaught_exception())&& #endif (*adb)->get_throw_count()==0){ try{ this->flush(); this->clean(1); }catch(OTL_CONST_EXCEPTION otl_exception&){ this->clean(1); throw; } if((*adb) && (*adb)->get_throw_count()>0){ (*adb)->sc.remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; return; } #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) if(otl_uncaught_exception()){ if((*adb)) (*adb)->sc.remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; return; } #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) if(otl_uncaught_exception()){ if((*adb)) (*adb)->sc.remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; return; } #endif (*adb)->sc.add(shell,shell->orig_sql_stm.c_str()); shell_pt.disconnect(); connected=0; }else{ if((*adb)) (*adb)->sc.remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; } #else intern_cleanup(); connected=0; #endif } otl_column_desc* describe_select(int& desc_len) OTL_NO_THROW { desc_len=0; if((*ss)){ (*adb)->reset_throw_count(); desc_len=(*ss)->get_sl_len(); return (*ss)->get_sl_desc(); } return 0; } int good(void) OTL_NO_THROW { if(!connected)return 0; if((*io)||(*ss)){ (*adb)->reset_throw_count(); return 1; }else return 0; } otl_stream& operator<<(otl_lob_stream& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); if((*io)){ (*io)->operator<<(s); inc_next_iov(); } return *this; } otl_stream& operator>>(otl_stream& (*pf) (otl_stream&)) { (*pf)(*this); return *this; } otl_stream& operator<<(otl_stream& (*pf) (otl_stream&)) { (*pf)(*this); return *this; } otl_stream& operator>>(otl_lob_stream& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; } inc_next_ov(); return *this; } otl_stream& operator>>(otl_time& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; } return *this; } otl_stream& operator<<(const otl_time& n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: (*io)->operator<<(n); break; case otl_odbc_select_stream: (*ss)->operator<<(n); if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } return *this; } otl_stream& operator>>(otl_datetime& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; #if defined(OTL_ODBC_STRING_TO_TIMESTAMP) if(describe_next_out_var()->ftype==otl_var_char){ #if defined(OTL_UNICODE) #if defined(OTL_UNICODE_CHAR_TYPE) OTL_UNICODE_CHAR_TYPE tmp_str[100]; #else OTL_CHAR tmp_str[100]; #endif #else char tmp_str[100]; #endif (*this)>>tmp_str; #if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_DATETIME_NULL_TO_VAL; else OTL_ODBC_STRING_TO_TIMESTAMP(tmp_str,s); #else OTL_ODBC_STRING_TO_TIMESTAMP(tmp_str,s); #endif #if defined(OTL_ODBC_TIME_ZONE) OTL_TRACE_WRITE (OTL_TRACE_FORMAT_TZ_DATETIME(s), "operator >>", "otl_datetime&"); #else OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&"); #endif return *this; }else{ otl_time tmp; (*this)>>tmp; #if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_DATETIME_NULL_TO_VAL; else{ s.year=tmp.year; s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour; s.minute=tmp.minute; s.second=tmp.second; s.fraction=otl_from_fraction(tmp.fraction,s.frac_precision); } #else s.year=tmp.year; s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour; s.minute=tmp.minute; s.second=tmp.second; s.fraction=otl_from_fraction(tmp.fraction,s.frac_precision); #endif } #else otl_time tmp; (*this)>>tmp; #if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_DATETIME_NULL_TO_VAL; else{ s.year=tmp.year; s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour; s.minute=tmp.minute; s.second=tmp.second; s.fraction=otl_from_fraction(tmp.fraction,s.frac_precision); } #else s.year=tmp.year; s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour; s.minute=tmp.minute; s.second=tmp.second; s.fraction=otl_from_fraction(tmp.fraction,s.frac_precision); #endif #endif OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&"); inc_next_ov(); return *this; } otl_stream& operator<<(const otl_datetime& s) OTL_THROWS_OTL_EXCEPTION { otl_time tmp; last_oper_was_read_op=false; reset_end_marker(); #if defined(OTL_ODBC_TIMESTAMP_TO_STRING) if(describe_next_in_var()->ftype==otl_var_char){ #if defined(OTL_UNICODE) #if defined(OTL_UNICODE_CHAR_TYPE) OTL_UNICODE_CHAR_TYPE tmp_str[100]; #else OTL_CHAR tmp_str[100]; #endif #else char tmp_str[100]; #endif OTL_ODBC_TIMESTAMP_TO_STRING(s,tmp_str); #if defined(OTL_ODBC_TIME_ZONE) OTL_TRACE_READ (OTL_TRACE_FORMAT_TZ_DATETIME(s), "operator <<", "otl_datetime&"); #else OTL_TRACE_READ (OTL_TRACE_FORMAT_DATETIME(s), "operator <<", "otl_datetime&"); #endif (*this)<>", "otl_datetime&"); inc_next_iov(); return *this; } #else tmp.year=OTL_SCAST(SQLSMALLINT,s.year); tmp.month=OTL_SCAST(SQLSMALLINT,s.month); tmp.day=OTL_SCAST(SQLSMALLINT,s.day); tmp.hour=OTL_SCAST(SQLSMALLINT,s.hour); tmp.minute=OTL_SCAST(SQLSMALLINT,s.minute); tmp.second=OTL_SCAST(SQLSMALLINT,s.second); tmp.fraction=otl_to_fraction(s.fraction,s.frac_precision); (*this)<>(char& c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(c); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(c); break; } #if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL) if((*this).is_null()) c=OTL_DEFAULT_CHAR_NULL_TO_VAL; #endif OTL_TRACE_WRITE("'"<>","char&") inc_next_ov(); return *this; } #endif #if !defined(OTL_UNICODE) otl_stream& operator>>(unsigned char& c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(c); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(c); break; } #if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL) if((*this).is_null()) c=OTL_DEFAULT_CHAR_NULL_TO_VAL; #endif OTL_TRACE_WRITE("'"<>","unsigned char&") inc_next_ov(); return *this; } #endif #if !defined(OTL_UNICODE) #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) otl_stream& operator>>(OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; } #if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL) if((*this).is_null()){ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s); } #elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_STRING_NULL_TO_VAL; #endif OTL_TRACE_WRITE(s,"operator >>","OTL_STRING_CONTAINER&") inc_next_ov(); return *this; } #endif #endif #if !defined(OTL_UNICODE) otl_stream& operator>>(char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; } #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL)); #endif OTL_TRACE_WRITE(s,"operator >>","char*") inc_next_ov(); return *this; } #endif #if defined(OTL_UNICODE_STRING_TYPE) otl_stream& operator>>(OTL_UNICODE_STRING_TYPE& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; } #if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL) if((*this).is_null()){ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s); } #elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,OTL_DEFAULT_STRING_NULL_TO_VAL); #endif OTL_TRACE_WRITE(s.c_str(), "operator >>", "OTL_UNICODE_STRING_TYPE&"); inc_next_ov(); return *this; } #endif otl_stream& operator>>(unsigned char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; } #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy (OTL_RCAST(unsigned char*,s), OTL_RCAST(unsigned char*, OTL_CCAST(char*,OTL_DEFAULT_STRING_NULL_TO_VAL))); #endif #if defined(OTL_UNICODE) OTL_TRACE_WRITE(OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,s), "operator >>", OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*") #else OTL_TRACE_WRITE(s,"operator >>","unsigned char*") #endif inc_next_ov(); return *this; } #if defined(OTL_UNICODE) otl_stream& operator>>(OTL_UNICODE_CHAR_TYPE& c) OTL_THROWS_OTL_EXCEPTION { OTL_UNICODE_CHAR_TYPE s[1024]; last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(OTL_RCAST(unsigned char*,s)); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(OTL_RCAST(unsigned char*,s)); break; } c=s[0]; #if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL) if((*this).is_null()) c=OTL_DEFAULT_CHAR_NULL_TO_VAL; #endif OTL_TRACE_WRITE(c,"operator >>", OTL_UNICODE_CHAR_TYPE_TRACE_NAME "") inc_next_ov(); return *this; } otl_stream& operator>>(OTL_UNICODE_CHAR_TYPE* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(OTL_RCAST(unsigned char*,s)); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(OTL_RCAST(unsigned char*,s)); break; } #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL)); #endif OTL_TRACE_WRITE(OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,s), "operator >>", OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*") inc_next_ov(); return *this; } #endif otl_stream& operator>>(int& n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(n); #else (*io)->operator>>(n); #endif break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(n); #else (*ss)->operator>>(n); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) n=OTL_SCAST(int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(n,"operator >>","int&") inc_next_ov(); return *this; } otl_stream& operator>>(unsigned& u) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(u); #else (*io)->operator>>(u); #endif break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(u); #else (*ss)->operator>>(u); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) u=OTL_SCAST(unsigned int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(u,"operator >>","unsigned&") inc_next_ov(); return *this; } otl_stream& operator>>(short& sh) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(sh); #else (*io)->operator>>(sh); #endif break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(sh); #else (*ss)->operator>>(sh); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) sh=OTL_SCAST(short int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(sh,"operator >>","short int&") inc_next_ov(); return *this; } otl_stream& operator>>(long int& l) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(l); #else (*io)->operator>>(l); #endif break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(l); #else (*ss)->operator>>(l); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) l=OTL_SCAST(long int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(l,"operator >>","long int&") inc_next_ov(); return *this; } #if defined(OTL_BIGINT) otl_stream& operator>>(OTL_BIGINT& l) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_STR_TO_BIGINT) && defined(OTL_BIGINT_TO_STR) { otl_var_desc* var_desc=describe_next_out_var(); if(var_desc){ if(var_desc->ftype==otl_var_char){ char temp_val[otl_bigint_str_size]; #if defined(OTL_UNICODE) OTL_CHAR unitemp_val[otl_bigint_str_size]; (*ss)->operator>>(OTL_RCAST(unsigned char*,unitemp_val)); OTL_CHAR* uc=unitemp_val; char* c=temp_val; while(*uc){ *c=OTL_SCAST(char,*uc); ++c; ++uc; } *c=0; #else (*ss)->operator>>(temp_val); #endif OTL_STR_TO_BIGINT(temp_val,l); }else #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(l); #else (*io)->operator>>(l); #endif } } #else #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(l); #else (*io)->operator>>(l); #endif #endif break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_STR_TO_BIGINT) && defined(OTL_BIGINT_TO_STR) { otl_var_desc* var_desc=describe_next_out_var(); if(var_desc){ if(var_desc->ftype==otl_var_char){ char temp_val[otl_bigint_str_size]; (*ss)->operator>>(temp_val); OTL_STR_TO_BIGINT(temp_val,l); }else #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(l); #else (*ss)->operator>>(l); #endif } } #else #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(l); #else (*ss)->operator>>(l); #endif #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) l=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif #if defined(_MSC_VER) && defined(OTL_TRACE_LEVEL) // VC ++ { char temp_str[otl_bigint_str_size]; _i64toa(l,temp_str,10); OTL_TRACE_WRITE(temp_str,"operator >>","BIGINT&") } #elif !defined(_MSC_VER) && defined(OTL_TRACE_LEVEL) OTL_TRACE_WRITE(l,"operator >>","BIGINT&") #endif inc_next_ov(); return *this; } #endif otl_stream& operator>>(float& f) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(f); #else (*io)->operator>>(f); #endif break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(f); #else (*ss)->operator>>(f); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) f=OTL_SCAST(float,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(f,"operator >>","float&") inc_next_ov(); return *this; } otl_stream& operator>>(double& d) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(d); #else (*io)->operator>>(d); #endif break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(d); #else (*ss)->operator>>(d); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) d=OTL_SCAST(double,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(d,"operator >>","double&") inc_next_ov(); return *this; } otl_stream& operator>>(otl_long_string& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_odbc_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; } OTL_TRACE_WRITE(" string length: "<>","otl_long_string&") inc_next_ov(); return *this; } otl_stream& operator<<(const char c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: (*io)->operator<<(c); break; case otl_odbc_select_stream: (*ss)->operator<<(c); if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } OTL_TRACE_READ("'"<stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: (*io)->operator<<(c); break; case otl_odbc_select_stream: (*ss)->operator<<(c); if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #if defined(OTL_UNICODE) otl_stream& operator<<(const OTL_UNICODE_CHAR_TYPE* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ ("\""<stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: (*io)->operator<<(OTL_RCAST(const unsigned char*,s)); break; case otl_odbc_select_stream: (*ss)->operator<<(OTL_RCAST(const unsigned char*,s)); if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const OTL_UNICODE_CHAR_TYPE c) OTL_THROWS_OTL_EXCEPTION { OTL_UNICODE_CHAR_TYPE s[2]; s[0]=c; s[1]=0; (*this)<stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: (*io)->operator<<(s); break; case otl_odbc_select_stream: (*ss)->operator<<(s); if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #endif #if defined(OTL_UNICODE_STRING_TYPE) otl_stream& operator<<(const OTL_UNICODE_STRING_TYPE& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("\""<stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: (*io)->operator<<(s); break; case otl_odbc_select_stream: (*ss)->operator<<(s); if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #endif #if !defined(OTL_UNICODE) otl_stream& operator<<(const char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("\""<stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: (*io)->operator<<(s); break; case otl_odbc_select_stream: (*ss)->operator<<(s); if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #endif otl_stream& operator<<(const unsigned char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); #if defined(OTL_UNICODE) OTL_TRACE_READ ("\""<stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: (*io)->operator<<(s); break; case otl_odbc_select_stream: (*ss)->operator<<(s); if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const int n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(n,"operator <<","int"); switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(n); #else (*io)->operator<<(n); #endif break; case otl_odbc_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(n); #else (*ss)->operator<<(n); #endif if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #if defined(OTL_BIGINT) otl_stream& operator<<(const OTL_BIGINT n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); #if defined(_MSC_VER) && defined(OTL_TRACE_LEVEL) // VC ++ { char temp_str[otl_bigint_str_size]; _i64toa(n,temp_str,10); OTL_TRACE_READ(temp_str,"operator <<","BIGINT") } #elif !defined(_MSC_VER) && defined(OTL_TRACE_LEVEL) OTL_TRACE_READ(n,"operator <<","BIGINT"); #endif switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: #if defined(OTL_STR_TO_BIGINT) && defined(OTL_BIGINT_TO_STR) { otl_var_desc* var_desc=describe_next_in_var(); if(var_desc){ if(var_desc->ftype==otl_var_char){ char temp_val[otl_bigint_str_size]; OTL_BIGINT_TO_STR(n,temp_val); #if defined(OTL_UNICODE) OTL_CHAR unitemp_val[otl_bigint_str_size]; OTL_CHAR* uc=unitemp_val; char* c=temp_val; while(*c){ *uc=OTL_SCAST(OTL_CHAR,*c); ++c; ++uc; } *uc=0; (*io)->operator<<(OTL_RCAST(const unsigned char*,unitemp_val)); #else (*io)->operator<<(temp_val); #endif }else #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(n); #else (*io)->operator<<(n); #endif } } #else #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(n); #else (*io)->operator<<(n); #endif #endif break; case otl_odbc_select_stream: #if defined(OTL_STR_TO_BIGINT) && defined(OTL_BIGINT_TO_STR) { otl_var_desc* var_desc=describe_next_in_var(); if(var_desc){ if(var_desc->ftype==otl_var_char){ char temp_val[otl_bigint_str_size]; OTL_BIGINT_TO_STR(n,temp_val); (*ss)->operator<<(temp_val); }else #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(n); #else (*ss)->operator<<(n); #endif } } #else #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(n); #else (*ss)->operator<<(n); #endif #endif if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #endif otl_stream& operator<<(const unsigned u) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(u,"operator <<","unsigned int"); switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(u); #else (*io)->operator<<(u); #endif break; case otl_odbc_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(u); #else (*ss)->operator<<(u); #endif if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const short sh) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(sh,"operator <<","short int"); switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(sh); #else (*io)->operator<<(sh); #endif break; case otl_odbc_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(sh); #else (*ss)->operator<<(sh); #endif if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const long int l) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(l,"operator <<","long int"); switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(l); #else (*io)->operator<<(l); #endif break; case otl_odbc_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(l); #else (*ss)->operator<<(l); #endif if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const float f) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(f,"operator <<","float"); switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(f); #else (*io)->operator<<(f); #endif break; case otl_odbc_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(f); #else (*ss)->operator<<(f); #endif if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const double d) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(d,"operator <<","double"); switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(d); #else (*io)->operator<<(d); #endif break; case otl_odbc_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(d); #else (*ss)->operator<<(d); #endif if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const otl_null& n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("NULL","operator <<","otl_null&"); switch(shell->stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: (*io)->operator<<(n); break; case otl_odbc_select_stream: (*ss)->operator<<(n); if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const otl_long_string& d) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(" len= "<stream_type){ case otl_odbc_no_stream: break; case otl_odbc_io_stream: (*io)->operator<<(d); break; case otl_odbc_select_stream: (*ss)->operator<<(d); if(!(*ov)&&(*ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } private: otl_stream& operator=(const otl_stream&) { return *this; } otl_stream(const otl_stream&): shell(0), shell_pt(), connected(0), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), override(0), end_marker(0), oper_int_called(0), last_eof_rc(0), last_oper_was_read_op(false), buf_size_(0) { } #if !defined(OTL_STREAM_NO_PRIVATE_BOOL_OPERATORS) otl_stream& operator>>(bool&) OTL_NO_THROW { return *this; } otl_stream& operator<<(const bool) OTL_NO_THROW { return *this; } #endif #if !defined(OTL_STREAM_NO_PRIVATE_UNSIGNED_LONG_OPERATORS) otl_stream& operator>>(unsigned long int&) OTL_NO_THROW { return *this; } otl_stream& operator<<(const unsigned long int) OTL_NO_THROW { return *this; } #endif }; inline otl_connect& operator>>(otl_connect& connect, otl_stream& s) { const char* cmd=connect.getCmd(); const char* invalid_cmd="*** INVALID COMMAND ***"; if(!cmd) cmd=invalid_cmd; s.open(s.getBufSize(),cmd,connect); return connect; } #if (defined(OTL_STL)||defined(OTL_VALUE_TEMPLATE_ON)) && defined(OTL_VALUE_TEMPLATE) template otl_stream& operator<<(otl_stream& s, const otl_value& var) OTL_THROWS_OTL_EXCEPTION { if(var.ind) s< otl_stream& operator>>(otl_stream& s, otl_value& var) OTL_THROWS_OTL_EXCEPTION { s>>var.v; if(s.is_null()) var.ind=true; else var.ind=false; return s; } #endif class otl_nocommit_stream: public otl_stream{ public: otl_nocommit_stream() OTL_NO_THROW : otl_stream() { set_commit(0); } otl_nocommit_stream (const otl_stream_buffer_size_type arr_size, const char* sqlstm, otl_connect& db, const int implicit_select=otl_explicit_select) OTL_THROWS_OTL_EXCEPTION : otl_stream(arr_size,sqlstm,db,implicit_select) { set_commit(0); } void open (otl_stream_buffer_size_type arr_size, const char* sqlstm, otl_connect& db, const int implicit_select=otl_explicit_select) OTL_THROWS_OTL_EXCEPTION { otl_stream::open(arr_size,sqlstm,db,implicit_select); set_commit(0); } }; inline otl_stream& endr(otl_stream& s) { s.check_end_of_row(); return s; } OTL_ODBC_NAMESPACE_END #endif // ==================== OTL-Adapter for Oracle 7 ===================== #if defined(OTL_ORA7) #if defined(OTL_UNICODE) #error OTL_ORA7 and OTL_UNICODE are incompatible #endif #if defined(OTL_ORA_TEXT_ON) #define text OTL_ORA_TEXT #endif extern "C"{ #include } OTL_ORA7_NAMESPACE_BEGIN const int inVarChar2=1; const int inNumber=2; const int inLong=8; const int inRowId=11; const int inDate=12; const int inRaw=23; const int inLongRaw=24; const int inChar=96; const int inMslabel=106; const int extVarChar2=inVarChar2; const int extNumber=inNumber; const int extInt=3; const int extFloat=4; const int extCChar=5; const int extVarNum=6; const int extLong=inLong; const int extVarChar=9; const int extRowId=inRowId; const int extDate=inDate; const int extVarRaw=15; const int extRaw=extVarRaw; const int extLongRaw=inLongRaw; const int extUInt=68; const int extLongVarChar=94; const int extLongVarRaw=95; const int extChar=inChar; const int extCharZ=97; const int extMslabel=inMslabel; typedef otl_oracle_date otl_time0; class otl_exc{ public: unsigned char msg[1000]; int code; char sqlstate[32]; #if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET) int error_offset; #endif #if defined(OTL_EXTENDED_EXCEPTION) char** msg_arr; char** sqlstate_arr; int* code_arr; int arr_len; #endif enum{disabled=0,enabled=1}; otl_exc(): msg(), code(0), sqlstate() #if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET) ,error_offset(0) #endif #if defined(OTL_EXTENDED_EXCEPTION) ,msg_arr(0), sqlstate_arr(0), code_arr(0), arr_len(0) #endif { sqlstate[0]=0; msg[0]=0; code=0; #if defined(OTL_EXTENDED_EXCEPTION) msg_arr=0; sqlstate_arr=0; code_arr=0; arr_len=0; #endif } virtual ~otl_exc(){} void init(const char* amsg, const int acode) { OTL_STRCPY_S(OTL_RCAST(char*,msg),sizeof(msg),amsg); code=acode; #if defined(OTL_EXTENDED_EXCEPTION) msg_arr=0; sqlstate_arr=0; code_arr=0; arr_len=0; #endif } }; class otl_cur; class otl_conn{ private: friend class otl_cur; Lda_Def* lda; unsigned char hda[512]; int extern_lda; public: int get_connection_type(void) { return 0; } void cleanup(void){} static int initialize(const int threaded_mode=0) { if(threaded_mode) return !opinit(1); else return 1; } otl_conn(): lda(new Lda_Def), hda(), extern_lda(0) { memset(lda,0,sizeof(*lda)); memset(hda,0,sizeof(hda)); } virtual ~otl_conn() { delete lda; } void set_timeout(const int /*atimeout*/=0){} void set_cursor_type(const int /*acursor_type*/=0){} int ext_logon(Lda_Def* ext_lda,const int auto_commit) {int rc; if(!extern_lda)delete lda; lda=ext_lda; extern_lda=1; if(auto_commit){ rc=ocon(lda); if(rc) return 0; else return 1; } return 1; } int rlogon(const char* connect_str,const int auto_commit) { if(!extern_lda)delete lda; OTL_TRACE_RLOGON_ORA7 (0x1, "otl_connect", "rlogon", connect_str, auto_commit) lda=new Lda_Def; extern_lda=0; memset(lda,0,sizeof(*lda)); memset(hda,0,sizeof(hda)); int rc=olog(lda, hda, OTL_RCAST(unsigned char*,OTL_CCAST(char*,connect_str)), -1, 0, -1, 0, -1, 0 ); if(rc)return 0; if(!auto_commit)return 1; rc=ocon(lda); if(rc) return 0; else return 1; } int logoff(void) { if(extern_lda){ lda=0; extern_lda=0; return 1; }else{ if(!lda)return 1; if(lda->rc==3113||lda->rc==1041||lda->rc==1033||lda->rc==1034){ delete lda; lda=0; return 1; } int rc=ologof(lda); delete lda; lda=0; return !rc; } } void error(otl_exc& exception_struct) { if(!lda){ exception_struct.code=3113; OTL_STRCPY_S(OTL_RCAST(char*,exception_struct.msg), sizeof(exception_struct.msg), "ORA-03113: end-of-file on communication channel" ); return; } size_t len; exception_struct.code=lda->rc; oerhms (lda, lda->rc, exception_struct.msg, sizeof(exception_struct.msg) ); len = strlen(OTL_RCAST(const char*,exception_struct.msg)); exception_struct.msg[len]=0; } int commit(void) { return !ocom(lda); } int auto_commit_on(void) { return !ocon(lda); } int auto_commit_off(void) { return !ocof(lda); } int rollback(void) { return !orol(lda); } private: otl_conn(const otl_conn&): lda(0), hda(), extern_lda(0) { } otl_conn& operator=(const otl_conn&) { return *this; } }; class otl_cur; class otl_var{ private: friend class otl_cur; ub1* p_v; sb2* p_ind; ub2* p_rlen; ub2* p_rcode; int ftype; int act_elem_size; int array_size; ub4 max_tab_len; ub4 cur_tab_len; int pl_tab_flag; int vparam_type; int lob_len; int lob_pos; int lob_ftype; int otl_adapter; bool lob_stream_mode; bool charz_flag; sb2 null_ind; public: int get_otl_adapter() const {return otl_adapter;} void set_lob_stream_mode(const bool alob_stream_mode) { lob_stream_mode=alob_stream_mode; } void set_vparam_type(const int avparam_type) { vparam_type=avparam_type; } void set_charz_flag(const bool acharz_flag) { charz_flag=acharz_flag; } otl_var(): p_v(0), p_ind(0), p_rlen(0), p_rcode(0), ftype(0), act_elem_size(0), array_size(0), max_tab_len(0), cur_tab_len(0), pl_tab_flag(0), vparam_type(-1), lob_len(0), lob_pos(0), lob_ftype(0), otl_adapter(otl_ora7_adapter), lob_stream_mode(false), charz_flag(false), null_ind(0) { } virtual ~otl_var() { delete[] p_v; delete[] p_ind; delete[] p_rlen; delete[] p_rcode; } int write_dt(void* trg, const void* src, const int sz) { memcpy(trg,src,sz); return 1; } int read_dt(void* trg, const void* src, const int sz) { memcpy(trg,src,sz); return 1; } int actual_elem_size(void) { return act_elem_size; } void init (const bool, const int aftype, int& aelem_size, const otl_stream_buffer_size_type aarray_size, const void* /*connect_struct*/=0, const int apl_tab_flag=0) { int i,elem_size; ftype=aftype; pl_tab_flag=apl_tab_flag; act_elem_size=aelem_size; if(aftype==otl_var_varchar_long||aftype==otl_var_raw_long){ elem_size=aelem_size+sizeof(sb4); array_size=1; }else if(aftype==otl_var_raw){ elem_size=aelem_size+sizeof(short int); array_size=aarray_size; }else{ elem_size=aelem_size; array_size=aarray_size; } p_v=new ub1[elem_size*OTL_SCAST(unsigned,array_size)]; p_ind=new sb2[array_size]; p_rlen=new ub2[array_size]; p_rcode=new ub2[array_size]; memset(p_v,0,elem_size*OTL_SCAST(unsigned,array_size)); if(aftype==otl_var_varchar_long||aftype==otl_var_raw_long){ if(aelem_size>32760) p_ind[0]=0; else p_ind[0]=OTL_SCAST(short,aelem_size); p_rcode[0]=0; }else{ for(i=0;i otl_ora7_connect; typedef otl_tmpl_cursor otl_cursor; typedef otl_tmpl_exception otl_exception; typedef otl_tmpl_inout_stream otl_inout_stream; typedef otl_tmpl_select_stream otl_select_stream; typedef otl_tmpl_ext_hv_decl otl_ext_hv_decl; class otl_stream_shell; class otl_connect: public otl_ora7_connect{ public: #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) otl_stream_pool sc; void set_stream_pool_size(const int max_size=otl_max_default_pool_size) { sc.init(max_size); } #endif long direct_exec (const char* sqlstm, const int exception_enabled=1) OTL_THROWS_OTL_EXCEPTION { return otl_cursor::direct_exec(*this,sqlstm,exception_enabled); } void syntax_check(const char* sqlstm) OTL_THROWS_OTL_EXCEPTION { otl_cursor::syntax_check(*this,sqlstm); } otl_connect() OTL_NO_THROW : otl_ora7_connect(), cmd_(0) { } otl_connect(const char* connect_str, const int aauto_commit=0) OTL_THROWS_OTL_EXCEPTION : otl_ora7_connect(connect_str, aauto_commit), cmd_(0) { } virtual ~otl_connect() #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) OTL_THROWS_OTL_EXCEPTION #endif { if(cmd_){ delete[] cmd_; cmd_=0; } #if defined(OTL_DESTRUCTORS_DO_NOT_THROW) try{ logoff(); }catch(OTL_CONST_EXCEPTION otl_exception&){ } #endif } void rlogon(Lda_Def* alda) OTL_THROWS_OTL_EXCEPTION { if(this->connected){ throw otl_exception(otl_error_msg_30,otl_error_code_30); } if(cmd_){ delete[] cmd_; cmd_=0; } connected=0; long_max_size=32760; retcode=connect_struct.ext_logon(alda,0); if(retcode) connected=1; else{ connected=0; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } } void rlogon(const char* connect_str, const int aauto_commit=0) OTL_THROWS_OTL_EXCEPTION { if(this->connected){ throw otl_exception(otl_error_msg_30,otl_error_code_30); } otl_ora7_connect::rlogon(connect_str,aauto_commit); } void logoff(void) { #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) if(connected) sc.init(sc.get_max_size()); #endif otl_ora7_connect::logoff(); } const char* getCmd(void) const { return cmd_; } otl_connect& operator<<(const char* cmd) { if(!connected){ this->rlogon(cmd); }else{ otl_cursor::direct_exec(*this,cmd); } return *this; } otl_connect& operator<<=(const char* cmd) { if(cmd_){ delete[] cmd_; cmd_=0; } size_t cmd_len=strlen(cmd); cmd_=new char[cmd_len+1]; OTL_STRCPY_S(cmd_,cmd_len+1,cmd); return *this; } private: char* cmd_; otl_connect& operator=(const otl_connect&) { return *this; } otl_connect(const otl_connect&) :otl_ora7_connect(),cmd_(0){} }; // ============ OTL Reference Cursor Streams for Oracle 7 ================= typedef otl_tmpl_variable otl_generic_variable; typedef otl_generic_variable* otl_p_generic_variable; class otl_ref_select_stream; class otl_ref_cursor: public otl_tmpl_cursor { private: friend class otl_ref_select_stream; int cur_row; int cur_size; int row_count; int array_size; otl_select_struct_override local_override; public: otl_ref_cursor (otl_connect& db, const char* cur_placeholder_name, void* master_stream_ptr, const otl_stream_buffer_size_type arr_size=1) :otl_tmpl_cursor (db), cur_row(-1), cur_size(0), row_count(0), array_size(arr_size), local_override(), sel_cur(), rvl_len(otl_var_list_size), rvl(new otl_p_generic_variable[rvl_len]), vl_cur_len(0), cur_placeholder(), master_stream_ptr_(master_stream_ptr) { local_override.reset(); for(int i=0;i(), cur_row(-1), cur_size(0), row_count(0), array_size(0), local_override(), sel_cur(), rvl_len(0), rvl(0), vl_cur_len(0), cur_placeholder(), master_stream_ptr_(0) { local_override.reset(); } virtual ~otl_ref_cursor() { this->in_destructor=1; delete[] rvl; rvl=0; } void open (otl_connect& db, const char* cur_placeholder_name, const otl_stream_buffer_size_type arr_size=1) { int i; local_override.reset(); cur_row=-1; row_count=0; cur_size=0; array_size=arr_size; rvl_len=otl_var_list_size; vl_cur_len=0; rvl=new otl_p_generic_variable[rvl_len]; for(i=0;i::open(db); } void close(void) { local_override.reset(); delete[] rvl; rvl=0; if(sel_cur.get_connected() && sel_cur.get_adb()==0) sel_cur.set_adb(adb); sel_cur.close(); otl_tmpl_cursor ::close(); } int first(void) {int i,rc; rc=obndrv (&this->cursor_struct.cda, OTL_RCAST(unsigned char*,cur_placeholder), -1, OTL_RCAST(ub1*,&sel_cur.get_cursor_struct_ref().cda), sizeof(sel_cur.get_cursor_struct_ref().cda), 102,-1,0,0,-1,-1); if(rc!=0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception(cursor_struct,stm_label?stm_label:stm_text); } if(cur_row==-2) ; // Special case -- calling describe_select() between parse() and first() else{ // Executing the PLSQL master block exec(1,0,otl_sql_exec_from_select_cursor_class); sel_cur.set_connected(1); } cur_row=-1; for(i=0;iadb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception(sel_cur.get_cursor_struct_ref(),stm_label?stm_label:stm_text); } row_count=sel_cur.get_cursor_struct_ref().cda.rpc; OTL_TRACE_FIRST_FETCH cur_size=row_count; if(cur_size!=0)cur_row=0; return cur_size!=0; } int next(void) {int rc; if(cur_row<0)return first(); if(cur_rowadb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception(sel_cur.get_cursor_struct_ref(), stm_label?stm_label:stm_text); } cur_size=sel_cur.get_cursor_struct_ref().cda.rpc-row_count; row_count=sel_cur.get_cursor_struct_ref().cda.rpc; OTL_TRACE_NEXT_FETCH2 if(cur_size!=0)cur_row=0; } return cur_size!=0; } void bind (const int column_num, otl_generic_variable& v) { if(!connected)return; ++vl_cur_len; if(vl_cur_len==rvl_len){ int temp_rvl_len=rvl_len*2; otl_p_generic_variable* temp_rvl= new otl_p_generic_variable[temp_rvl_len]; int i; for(i=0;i::bind(v); } void bind (const char* name, otl_generic_variable& v) { otl_tmpl_cursor ::bind(name,v); } int describe_select (otl_column_desc* desc, int& desc_len) {int i,rc; rc=obndrv (&cursor_struct.cda, OTL_RCAST(unsigned char*,cur_placeholder), -1, OTL_RCAST(ub1*,&sel_cur.get_cursor_struct_ref().cda), sizeof(sel_cur.get_cursor_struct_ref().cda), 102,-1,0,0,-1,-1); if(rc!=0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception(cursor_struct,stm_label?stm_label:stm_text); } // Executing the PLSQL master block exec(1,0,otl_sql_exec_from_select_cursor_class); sel_cur.set_connected(1); cur_row=-2; // Special case -- describe_select() before first() or next() desc_len=0; for(i=1;sel_cur.describe_column(desc[i-1],i);++i) ++desc_len; return 1; } protected: otl_cursor sel_cur; int rvl_len; otl_p_generic_variable* rvl; int vl_cur_len; char cur_placeholder[64]; void* master_stream_ptr_; private: otl_ref_cursor(const otl_ref_cursor&) : otl_tmpl_cursor (), cur_row(-1), cur_size(0), row_count(0), array_size(0), local_override(), sel_cur(), rvl_len(0), rvl(0), vl_cur_len(0), cur_placeholder(), master_stream_ptr_(0) { } otl_ref_cursor& operator=(const otl_ref_cursor&) { return *this; } }; class otl_stream; class otl_ref_select_stream: public otl_ref_cursor{ private: friend class otl_stream; otl_select_struct_override* override; long _rfc; public: int get_select_row_count() const { return this->cur_row==-1?0:this->cur_size-this->cur_row; } void cleanup(void) {int i; delete[] sl; for(i=0;iget_master_stream_ptr(), arr_size), override(0), _rfc(0), sl_desc(0), sl_len(0), sl(0), null_fetched(0), ret_code(0), cur_col(0), cur_in(0), executed(0), var_info() { if(sqlstm_label!=0){ if(stm_label!=0){ delete[] stm_label; stm_label=0; } size_t len=strlen(sqlstm_label)+1; stm_label=new char[len]; OTL_STRCPY_S(stm_label,len,sqlstm_label); } _rfc=0; init(); { size_t len=strlen(sqlstm)+1; stm_text=new char[len]; OTL_STRCPY_S(stm_text,len,sqlstm); otl_select_struct_override* temp_local_override=&this->local_override; otl_ext_hv_decl hvd (this->stm_text, 1, this->stm_label, &temp_local_override, adb ); hvd.alloc_host_var_list(vl,vl_len,*adb); } override=aoverride; try{ parse(); if(vl_len==0){ rewind(); null_fetched=0; } }catch(OTL_CONST_EXCEPTION otl_exception&){ cleanup(); if(this->adb)this->adb->increment_throw_count(); throw; } } virtual ~otl_ref_select_stream() { cleanup(); } void rewind(void) { OTL_TRACE_STREAM_EXECUTION _rfc=0; get_select_list(); ret_code=first(); null_fetched=0; cur_col=-1; cur_in=0; executed=1; } void clean(void) { _rfc=0; null_fetched=0; cur_col=-1; cur_in=0; executed=0; } int is_null(void) { return null_fetched; } int eof(void) { return !ret_code; } void skip_to_end_of_row() { check_if_executed(); if(eof())return; while(cur_colcur_row); } ret_code=this->next(); cur_col=0; if(!eof()) cur_col=-1; ++_rfc; } otl_ref_select_stream& operator>>(otl_time0& t) { check_if_executed(); if(eof())return *this; get_next(); if(check_type(otl_var_timestamp)&&!eof()){ otl_time0* tm=OTL_RCAST(otl_time0*,sl[cur_col].val(cur_row)); memcpy(OTL_RCAST(void*,&t),tm,otl_oracle_date_size); look_ahead(); } return *this; } otl_ref_select_stream& operator>>(char& c) { check_if_executed(); if(eof())return *this; get_next(); if(check_type(otl_var_char)&&!eof()){ c=*OTL_RCAST(char*,sl[cur_col].val(cur_row)); look_ahead(); } return *this; } otl_ref_select_stream& operator>>(unsigned char& c) { check_if_executed(); if(eof())return *this; get_next(); if(check_type(otl_var_char)&&!eof()){ c=*OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); look_ahead(); } return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) otl_ref_select_stream& operator>>(OTL_STRING_CONTAINER& s) { check_if_executed(); if(eof())return *this; get_next(); switch(sl[cur_col].get_ftype()){ case otl_var_char: if(!eof()){ #if defined(OTL_ACE) s.set(OTL_RCAST(char*,sl[cur_col].val(cur_row)),1); #else s=OTL_RCAST(char*,sl[cur_col].val(cur_row)); #endif look_ahead(); } break; #if defined(USER_DEFINED_STRING_CLASS) || \ defined(OTL_STL) || defined(OTL_ACE) case otl_var_varchar_long: case otl_var_raw_long: if(!eof()){ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); int len=sl[cur_col].get_len(cur_row); #if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE) s.assign(OTL_RCAST(char*,c),len); #elif defined(OTL_ACE) s.set(OTL_RCAST(char*,c),len,1); #endif look_ahead(); } break; #endif default: check_type(otl_var_char); } // switch return *this; } #endif otl_ref_select_stream& operator>>(char* s) { check_if_executed(); if(eof())return *this; get_next(); if(check_type(otl_var_char)&&!eof()){ otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,sl[cur_col].val(cur_row))); look_ahead(); } return *this; } otl_ref_select_stream& operator>>(unsigned char* s) { check_if_executed(); if(eof())return *this; get_next(); if(check_type(otl_var_char)&&!eof()){ otl_strcpy2(OTL_RCAST(unsigned char*,s), OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)), sl[cur_col].get_len(cur_row) ); look_ahead(); } return *this; } #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) #define OTL_D5(T,T_type) \ otl_ref_select_stream& operator>>(T& n) \ { \ check_if_executed(); \ if(eof())return *this; \ get_next(); \ if(!eof()){ \ int match_found=otl_numeric_convert_T \ (sl[cur_col].get_ftype(), \ sl[cur_col].val(cur_row), \ n); \ if(!match_found) \ strict_check_throw(T_type); \ look_ahead(); \ } \ return *this; \ } #else #define OTL_D5(T,T_type) \ otl_ref_select_stream& operator>>(T& n) \ { \ check_if_executed(); \ if(eof())return *this; \ get_next(); \ if(!eof()){ \ int match_found=otl_numeric_convert_T \ (sl[cur_col].get_ftype(), \ sl[cur_col].val(cur_row), \ n); \ if(!match_found){ \ if(check_type(otl_var_double,T_type)) \ n=OTL_PCONV(T,double,sl[cur_col].val(cur_row)); \ } \ look_ahead(); \ } \ return *this; \ } #endif #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) OTL_D5(int,otl_var_int) OTL_D5(unsigned,otl_var_unsigned_int) OTL_D5(long,otl_var_long_int) OTL_D5(short,otl_var_short) OTL_D5(float,otl_var_float) OTL_D5(double,otl_var_double) #else template OTL_D5(T,T_type) #endif otl_ref_select_stream& operator>>(otl_long_string& s) { check_if_executed(); if(eof())return *this; get_next(); switch(sl[cur_col].get_ftype()){ case otl_var_varchar_long: case otl_var_raw_long: { if(!eof()){ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); int len=sl[cur_col].get_len(cur_row); if(len>s.get_buf_size()) len=s.get_buf_size(); otl_memcpy(s.v,c,len,sl[cur_col].get_ftype()); if(sl[cur_col].get_ftype()==otl_var_varchar_long) s.null_terminate_string(len); s.set_len(len); look_ahead(); } } break; case otl_var_raw: { if(!eof()){ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); int len=OTL_SCAST(int,*OTL_RCAST(unsigned short*,c)); if(len>s.get_buf_size()) len=s.get_buf_size(); otl_memcpy(s.v,c+sizeof(short int),len,sl[cur_col].get_ftype()); s.set_len(len); look_ahead(); } } break; } return *this; } otl_ref_select_stream& operator<<(const otl_time0& t) { check_in_var(); if(check_in_type(otl_var_timestamp,otl_oracle_date_size)){ otl_time0* tm=OTL_RCAST(otl_time0*,vl[cur_in]->val()); memcpy(tm,OTL_RCAST(void*,OTL_CCAST(otl_time0*,&t)),otl_oracle_date_size); } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } otl_ref_select_stream& operator<<(const otl_null& /* n */) { check_in_var(); this->vl[cur_in]->set_null(0); get_in_next(); return *this; } otl_ref_select_stream& operator<<(const otl_long_string& s) { check_in_var(); if(check_in_type(otl_var_raw,1)){ unsigned char* c=OTL_RCAST(unsigned char*,vl[cur_in]->val()); int len=OTL_CCAST(otl_long_string*,&s)->len(); if(len>this->vl[cur_in]->actual_elem_size()){ otl_var_info_var (this->vl[cur_in]->get_name(), this->vl[cur_in]->get_ftype(), otl_var_raw, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_in]->set_not_null(0); otl_memcpy (c+sizeof(unsigned short), s.v, len, this->vl[cur_in]->get_ftype()); *OTL_RCAST(unsigned short*, this->vl[cur_in]->val(0))=OTL_SCAST(unsigned short,len); this->vl[cur_in]->set_len(len,0); } get_in_next(); return *this; } otl_ref_select_stream& operator<<(const char c) { check_in_var(); if(check_in_type(otl_var_char,1)){ char* tmp=OTL_RCAST(char*,vl[cur_in]->val()); tmp[0]=c; tmp[1]=0; } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } otl_ref_select_stream& operator<<(const unsigned char c) { check_in_var(); if(check_in_type(otl_var_char,1)){ unsigned char* tmp=OTL_RCAST(unsigned char*,vl[cur_in]->val()); tmp[0]=c; tmp[1]=0; } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) otl_ref_select_stream& operator<<(const OTL_STRING_CONTAINER& s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy (OTL_RCAST(unsigned char*,vl[cur_in]->val()), OTL_RCAST(unsigned char*,OTL_CCAST(char*,s.c_str())), overflow, vl[cur_in]->get_elem_size(), OTL_SCAST(int,s.length()) ); if(overflow){ char temp_var_info[256]; otl_var_info_var (vl[cur_in]->get_name(), vl[cur_in]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(this->adb)this->adb->increment_throw_count(); if(otl_uncaught_exception()) return *this; throw otl_exception (otl_error_msg_4, otl_error_code_4, stm_label?stm_label:stm_text, temp_var_info); } } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } #endif otl_ref_select_stream& operator<<(const char* s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy (OTL_RCAST(unsigned char*,vl[cur_in]->val()), OTL_RCAST(unsigned char*,OTL_CCAST(char*,s)), overflow, vl[cur_in]->get_elem_size() ); if(overflow){ char temp_var_info[256]; otl_var_info_var (vl[cur_in]->get_name(), vl[cur_in]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(this->adb)this->adb->increment_throw_count(); if(otl_uncaught_exception()) return *this; throw otl_exception (otl_error_msg_4, otl_error_code_4, stm_label?stm_label:stm_text, temp_var_info); } } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } otl_ref_select_stream& operator<<(const unsigned char* s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy4 (OTL_RCAST(unsigned char*,vl[cur_in]->val()), OTL_CCAST(unsigned char*,s), overflow, vl[cur_in]->get_elem_size() ); if(overflow){ char temp_var_info[256]; otl_var_info_var (vl[cur_in]->get_name(), vl[cur_in]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception (otl_error_msg_4, otl_error_code_4, stm_label?stm_label:stm_text, temp_var_info); } } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } #define OTL_D6(T,T_type) \ otl_ref_select_stream& operator<<(const T n) \ { \ check_in_var(); \ if(check_in_type(T_type,sizeof(T))){ \ *OTL_RCAST(T*,vl[cur_in]->val())=n; \ } \ this->vl[cur_in]->set_not_null(0); \ get_in_next(); \ return *this; \ } #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) OTL_D6(int,otl_var_int) OTL_D6(unsigned,otl_var_unsigned_int) OTL_D6(long,otl_var_long_int) OTL_D6(short,otl_var_short) OTL_D6(float,otl_var_float) OTL_D6(double,otl_var_double) #else template OTL_D6(T,T_type) #endif int select_list_len(void) { return sl_len; } int column_ftype(int ndx=0) { return sl[ndx].get_ftype(); } int column_size(int ndx=0) { return sl[ndx].get_elem_size(); } protected: otl_column_desc* sl_desc; int sl_len; otl_generic_variable* sl; int null_fetched; int ret_code; int cur_col; int cur_in; int executed; char var_info[256]; void init(void) { sl=0; sl_len=0; null_fetched=0; ret_code=0; sl_desc=0; executed=0; cur_in=0; stm_text=0; } void get_next(void) { if(cur_coladb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception (otl_error_msg_0, otl_error_code_0, this->stm_label? this->stm_label: this->stm_text, var_info); } #endif int check_type_throw(int type_code,int actual_data_type) { int out_type_code; if(actual_data_type!=0) out_type_code=actual_data_type; else out_type_code=type_code; otl_var_info_col (sl[cur_col].get_pos(), sl[cur_col].get_ftype(), out_type_code, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception (otl_error_msg_0, otl_error_code_0, stm_label?stm_label:stm_text, var_info); } int check_type(int type_code, int actual_data_type=0) { if(sl[cur_col].get_ftype()==type_code) return 1; else return check_type_throw(type_code,actual_data_type); } void look_ahead(void) { if(cur_col==sl_len-1){ ret_code=next(); cur_col=-1; ++_rfc; } } void get_select_list(void) {int i,j,rc; otl_auto_array_ptr loc_ptr(otl_var_list_size); otl_column_desc* sl_desc_tmp=loc_ptr.get_ptr(); int sld_tmp_len=0; int ftype,elem_size; rc=obndrv (&cursor_struct.cda, OTL_RCAST(unsigned char*,cur_placeholder), -1, OTL_RCAST(ub1*,&sel_cur.get_cursor_struct_ref().cda), sizeof(sel_cur.get_cursor_struct_ref().cda), 102,-1,0,0,-1,-1); if(rc!=0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(cursor_struct,stm_label?stm_label:stm_text); } for(i=0;i::bind(*vl[i]); // Executing the PLSQL master block otl_tmpl_cursor ::exec(1,0,otl_sql_exec_from_select_cursor_class); sel_cur.set_connected(1); cur_row=-2; sld_tmp_len=0; for(i=1;sel_cur.describe_column(sl_desc_tmp[i-1],i);++i){ ++sld_tmp_len; if(sld_tmp_len==loc_ptr.get_arr_size()){ loc_ptr.double_size(); sl_desc_tmp=loc_ptr.get_ptr(); } } sl_len=sld_tmp_len; if(sl){ delete[] sl; sl=0; } sl=new otl_generic_variable[sl_len==0?1:sl_len]; int max_long_size=this->adb->get_max_long_size(); for(j=0;jlocal_override.getLen()>0?this->local_override:*override, j+1, adb->get_connect_struct().get_connection_type()); sl[j].copy_pos(j+1); sl[j].init(true,ftype, elem_size, OTL_SCAST(otl_stream_buffer_size_type,array_size), &adb->get_connect_struct() ); } if(sl_desc){ delete[] sl_desc; sl_desc=0; } sl_desc=new otl_column_desc[sl_len==0?1:sl_len]; for(i=0;iget_name(), vl[cur_in]->get_ftype(), type_code, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception (otl_error_msg_0, otl_error_code_0, stm_label?stm_label:stm_text, var_info); } int check_in_type(int type_code,int tsize) { switch(vl[cur_in]->get_ftype()){ case otl_var_char: if(type_code==otl_var_char) return 1; case otl_var_raw: if(type_code==otl_var_raw) return 1; default: if(vl[cur_in]->get_ftype()==type_code && vl[cur_in]->get_elem_size()==tsize) return 1; } return check_in_type_throw(type_code); } void check_in_var_throw(void) { if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception (otl_error_msg_1, otl_error_code_1, stm_label?stm_label:stm_text, 0); } void check_in_var(void) { if(vl_len==0) check_in_var(); } void check_if_executed_throw(void) { if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception (otl_error_msg_2, otl_error_code_2, stm_label?stm_label:stm_text, 0); } void check_if_executed(void) { if(!executed) check_if_executed_throw(); } private: otl_ref_select_stream(const otl_ref_select_stream&): otl_ref_cursor(), override(0), _rfc(0), sl_desc(0), sl_len(0), sl(0), null_fetched(0), ret_code(0), cur_col(0), cur_in(0), executed(0), var_info() { } otl_ref_select_stream& operator=(const otl_ref_select_stream&) { return *this; } }; const int otl_ora7_no_stream=0; const int otl_ora7_io_stream=1; const int otl_ora7_select_stream=2; const int otl_ora7_refcur_select_stream=3; class otl_stream_shell: public otl_stream_shell_generic{ public: otl_ref_select_stream* ref_ss; otl_select_stream* ss; otl_inout_stream* io; otl_connect* adb; bool lob_stream_flag; int auto_commit_flag; otl_var_desc* iov; int iov_len; int next_iov_ndx; otl_var_desc* ov; int ov_len; int next_ov_ndx; bool flush_flag; int stream_type; otl_select_struct_override override; #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) OTL_STRING_CONTAINER orig_sql_stm; #endif otl_stream_shell(): otl_stream_shell_generic(), ref_ss(0), ss(0), io(0), adb(0), lob_stream_flag(false), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), flush_flag(false), stream_type(otl_ora7_no_stream), override() #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) ,orig_sql_stm() #endif { } otl_stream_shell(const int ashould_delete): otl_stream_shell_generic(), ref_ss(0), ss(0), io(0), adb(0), lob_stream_flag(false), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), flush_flag(true), stream_type(otl_ora7_no_stream), override() #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) ,orig_sql_stm() #endif { override.setLen(0); should_delete=ashould_delete; } virtual ~otl_stream_shell() { if(should_delete){ delete[] iov; delete[] ov; iov=0; iov_len=0; ov=0; ov_len=0; next_iov_ndx=0; next_ov_ndx=0; override.setLen(0); flush_flag=true; stream_type=otl_ora7_no_stream; delete ss; delete io; delete ref_ss; ss=0; io=0; ref_ss=0; adb=0; } } private: otl_stream_shell(const otl_stream_shell&): otl_stream_shell_generic(), ref_ss(0), ss(0), io(0), adb(0), lob_stream_flag(false), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), flush_flag(false), stream_type(otl_ora7_no_stream), override() #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) ,orig_sql_stm() #endif { } otl_stream_shell& operator=(const otl_stream_shell&) { return *this; } }; class otl_stream{ private: otl_stream_shell* shell; otl_ptr shell_pt; int connected; otl_ref_select_stream** ref_ss; otl_select_stream** ss; otl_inout_stream** io; otl_connect** adb; int* auto_commit_flag; otl_var_desc** iov; int* iov_len; int* next_iov_ndx; otl_var_desc** ov; int* ov_len; int* next_ov_ndx; otl_select_struct_override* override; int end_marker; int oper_int_called; int last_eof_rc; bool last_oper_was_read_op; protected: void reset_end_marker(void) { last_eof_rc=0; end_marker=-1; oper_int_called=0; } int buf_size_; void throw_end_of_row() #if defined(__GNUC__) && (__GNUC__>=4) __attribute__ ((noreturn)) #endif { throw otl_exception (otl_error_msg_34, otl_error_code_34, this->get_stm_text()); } public: void skip_to_end_of_row() { if(next_ov_ndx==0) return; if((*ov_len)==0)return; last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); (*io)->skip_to_end_of_row(); break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->skip_to_end_of_row(); break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->skip_to_end_of_row(); break; } while ((*next_ov_ndx)<(*ov_len)-1) ++(*next_ov_ndx); } void reset_to_last_valid_row() { if((*io)){ (*adb)->reset_throw_count(); (*io)->reset_to_last_valid_row(); } } bool get_lob_stream_flag() const { if(!shell) return false; else return shell->lob_stream_flag; } int get_adb_max_long_size() const { return this->shell->adb->get_max_long_size(); } void check_end_of_row() { if(next_ov_ndx==0||(*next_ov_ndx)!=0) throw_end_of_row(); if(next_iov_ndx==0||(*next_iov_ndx)!=0) throw_end_of_row(); } otl_stream_shell* get_shell(){return shell;} int get_connected() const {return connected;} int get_dirty_buf_len() const { switch(shell->stream_type){ case otl_ora7_no_stream: return 0; case otl_ora7_io_stream: return (*io)->get_dirty_buf_len(); case otl_ora7_select_stream: return (*ss)->get_select_row_count(); case otl_ora7_refcur_select_stream: return (*ref_ss)->get_select_row_count(); default: return 0; } } const char* get_stm_text(void) { const char* no_stm_text=OTL_NO_STM_TEXT; switch(shell->stream_type){ case otl_ora7_no_stream: return no_stm_text; case otl_ora7_io_stream: return (*io)->get_stm_label()?(*io)->get_stm_label():(*io)->get_stm_text(); case otl_ora7_select_stream: return (*ss)->get_stm_label()?(*ss)->get_stm_label():(*ss)->get_stm_text(); case otl_ora7_refcur_select_stream: return (*ref_ss)->get_stm_label()? (*ref_ss)->get_stm_label():(*ref_ss)->get_stm_text(); default: return no_stm_text; } } void setBufSize(int buf_size) { buf_size_=buf_size; } int getBufSize(void) const { return buf_size_; } long get_rpc() OTL_THROWS_OTL_EXCEPTION { switch(shell->stream_type){ case otl_ora7_no_stream: return 0; case otl_ora7_io_stream: (*adb)->reset_throw_count(); return (*io)->get_rpc(); case otl_ora7_select_stream: (*adb)->reset_throw_count(); return (*ss)->get_rfc(); case otl_ora7_refcur_select_stream: (*adb)->reset_throw_count(); return (*ref_ss)->_rfc; default: return 0; } } operator int(void) OTL_THROWS_OTL_EXCEPTION { if(!last_oper_was_read_op){ if(this->adb&&*this->adb)(*this->adb)->increment_throw_count(); if(this->adb&&*this->adb&&(*this->adb)->get_throw_count()>1)return 0; const char* stm_label=0; const char* stm_text=0; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: stm_label=(*io)->get_stm_label(); stm_text=(*io)->get_stm_text(); break; case otl_ora7_select_stream: stm_label=(*ss)->get_stm_label(); stm_text=(*ss)->get_stm_text(); break; case otl_ora7_refcur_select_stream: stm_label=(*ref_ss)->get_stm_label(); stm_text=(*ref_ss)->get_stm_text(); break; } throw otl_exception (otl_error_msg_18, otl_error_code_18, stm_label?stm_label:stm_text); } if(end_marker==1)return 0; int rc=0; int temp_eof=eof(); if(temp_eof && end_marker==-1 && oper_int_called==0){ end_marker=1; if(last_eof_rc==1) rc=0; else rc=1; }else if(!temp_eof && end_marker==-1) rc=1; else if(temp_eof && end_marker==-1){ end_marker=0; rc=1; }else if(temp_eof && end_marker==0){ end_marker=1; rc=0; } if(!oper_int_called)oper_int_called=1; return rc; } void create_var_desc(void) {int i; delete[] (*iov); delete[] (*ov); (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: if((*io)->get_vl_len()>0){ (*iov)=new otl_var_desc[(*io)->get_vl_len()]; (*iov_len)=(*io)->get_vl_len(); for(i=0;i<(*io)->get_vl_len();++i) (*io)->get_vl()[i]->copy_var_desc((*iov)[i]); } if((*io)->get_iv_len()>0){ (*ov)=new otl_var_desc[(*io)->get_iv_len()]; (*ov_len)=(*io)->get_iv_len(); for(i=0;i<(*io)->get_iv_len();++i) (*io)->get_in_vl()[i]->copy_var_desc((*ov)[i]); } break; case otl_ora7_select_stream: if((*ss)->get_vl_len()>0){ (*iov)=new otl_var_desc[(*ss)->get_vl_len()]; (*iov_len)=(*ss)->get_vl_len(); for(i=0;i<(*ss)->get_vl_len();++i) (*ss)->get_vl()[i]->copy_var_desc((*iov)[i]); } if((*ss)->get_sl_len()>0){ (*ov)=new otl_var_desc[(*ss)->get_sl_len()]; (*ov_len)=(*ss)->get_sl_len(); for(i=0;i<(*ss)->get_sl_len();++i){ (*ss)->get_sl()[i].copy_var_desc((*ov)[i]); (*ov)[i].copy_name((*ss)->get_sl_desc()[i].name); } } break; case otl_ora7_refcur_select_stream: if((*ref_ss)->vl_len>0){ (*iov)=new otl_var_desc[(*ref_ss)->vl_len]; (*iov_len)=(*ref_ss)->vl_len; for(i=0;i<(*ref_ss)->vl_len;++i) (*ref_ss)->vl[i]->copy_var_desc((*iov)[i]); } if((*ref_ss)->sl_len>0){ (*ov)=new otl_var_desc[(*ref_ss)->sl_len]; (*ov_len)=(*ref_ss)->sl_len; for(i=0;i<(*ref_ss)->sl_len;++i){ (*ref_ss)->sl[i].copy_var_desc((*ov)[i]); (*ov)[i].copy_name((*ref_ss)->sl_desc[i].name); } } break; } } void set_column_type(const int column_ndx, const int col_type, const int col_size=0) OTL_NO_THROW { if(shell==0){ init_stream(); shell->flush_flag=true; } override->add_override(column_ndx,col_type,col_size); } void set_all_column_types(const unsigned mask=0) OTL_NO_THROW { if(shell==0){ init_stream(); shell->flush_flag=true; } override->set_all_column_types(mask); } void set_flush(const bool flush_flag=true) OTL_NO_THROW { if(shell==0)init_stream(); if(shell==0)return; shell->flush_flag=flush_flag; } void inc_next_ov(void) { if((*ov_len)==0)return; if((*next_ov_ndx)<(*ov_len)-1) ++(*next_ov_ndx); else (*next_ov_ndx)=0; } void inc_next_iov(void) { if((*iov_len)==0)return; if((*next_iov_ndx)<(*iov_len)-1) ++(*next_iov_ndx); else (*next_iov_ndx)=0; } otl_var_desc* describe_in_vars(int& desc_len) OTL_NO_THROW { desc_len=0; if(shell==0)return 0; if(shell->iov==0)return 0; desc_len=shell->iov_len; return shell->iov; } otl_var_desc* describe_out_vars(int& desc_len) OTL_NO_THROW { desc_len=0; if(shell==0)return 0; if(shell->ov==0)return 0; desc_len=shell->ov_len; return shell->ov; } otl_var_desc* describe_next_in_var(void) OTL_NO_THROW { if(shell==0)return 0; if(shell->iov==0)return 0; return &(shell->iov[shell->next_iov_ndx]); } otl_var_desc* describe_next_out_var(void) OTL_NO_THROW { if(shell==0)return 0; if(shell->ov==0)return 0; return &(shell->ov[shell->next_ov_ndx]); } void init_stream(void) { buf_size_=1; last_oper_was_read_op=false; shell=0; shell=new otl_stream_shell(0); shell_pt.assign(&shell); connected=0; ref_ss=&(shell->ref_ss); ss=&(shell->ss); io=&(shell->io); adb=&(shell->adb); auto_commit_flag=&(shell->auto_commit_flag); iov=&(shell->iov); iov_len=&(shell->iov_len); next_iov_ndx=&(shell->next_iov_ndx); ov=&(shell->ov); ov_len=&(shell->ov_len); next_ov_ndx=&(shell->next_ov_ndx); override=&(shell->override); (*ref_ss)=0; (*io)=0; (*ss)=0; (*adb)=0; (*ov)=0; (*ov_len)=0; (*next_iov_ndx)=0; (*next_ov_ndx)=0; (*auto_commit_flag)=1; (*iov)=0; (*iov_len)=0; } otl_stream (const otl_stream_buffer_size_type arr_size, const char* sqlstm, otl_connect& db, const char* ref_cur_placeholder=0, const char* sqlstm_label=0) OTL_THROWS_OTL_EXCEPTION: shell(0), shell_pt(), connected(0), ref_ss(0), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), override(0), end_marker(0), oper_int_called(0), last_eof_rc(0), last_oper_was_read_op(0), buf_size_(0) { init_stream(); (*io)=0; (*ss)=0; (*ref_ss)=0; (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; (*auto_commit_flag)=1; (*next_iov_ndx)=0; (*next_ov_ndx)=0; (*adb)=&db; shell->flush_flag=true; open(arr_size,sqlstm,db,ref_cur_placeholder,sqlstm_label); } otl_stream() OTL_NO_THROW: shell(0), shell_pt(), connected(0), ref_ss(0), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), override(0), end_marker(0), oper_int_called(0), last_eof_rc(0), last_oper_was_read_op(0), buf_size_(0) { init_stream(); shell->flush_flag=true; } virtual ~otl_stream() #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) OTL_THROWS_OTL_EXCEPTION #endif { if(!connected)return; try{ if((*io)!=0&&shell->flush_flag==false) (*io)->set_flush_flag2(false); close(); if(shell!=0){ if((*io)!=0) (*io)->set_flush_flag2(true); } }catch(OTL_CONST_EXCEPTION otl_exception&){ if(shell!=0){ if((*io)!=0) (*io)->set_flush_flag2(true); } #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) clean(1); if(shell!=0) shell->set_should_delete(1); shell_pt.destroy(); #else shell_pt.destroy(); #endif #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) throw; #endif } #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) if(adb && (*adb) && (*adb)->get_throw_count()>0 #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) || otl_uncaught_exception() #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) || otl_uncaught_exception() #endif ){ // } #else shell_pt.destroy(); #endif } int eof(void) OTL_NO_THROW { switch(shell->stream_type){ case otl_ora7_no_stream: return 1; case otl_ora7_io_stream: (*adb)->reset_throw_count(); return (*io)->eof(); case otl_ora7_select_stream: (*adb)->reset_throw_count(); return (*ss)->eof(); case otl_ora7_refcur_select_stream: (*adb)->reset_throw_count(); return (*ref_ss)->eof(); default: return 0; } } void flush(void) OTL_THROWS_OTL_EXCEPTION { if((*io)){ (*adb)->reset_throw_count(); (*io)->flush(); } } void clean(const int clean_up_error_flag=0) OTL_THROWS_OTL_EXCEPTION { switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: (*adb)->reset_throw_count(); (*io)->clean(clean_up_error_flag); break; case otl_ora7_select_stream: (*adb)->reset_throw_count(); (*ss)->clean(); break; case otl_ora7_refcur_select_stream: (*adb)->reset_throw_count(); (*ref_ss)->clean(); break; } } void rewind(void) OTL_THROWS_OTL_EXCEPTION { switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: (*adb)->reset_throw_count(); (*io)->rewind(); break; case otl_ora7_select_stream: (*adb)->reset_throw_count(); (*ss)->rewind(); break; case otl_ora7_refcur_select_stream: (*adb)->reset_throw_count(); (*ref_ss)->rewind(); break; } } int is_null(void) OTL_NO_THROW { switch(shell->stream_type){ case otl_ora7_no_stream: return 0; case otl_ora7_io_stream: return (*io)->is_null(); case otl_ora7_select_stream: return (*ss)->is_null(); case otl_ora7_refcur_select_stream: return (*ref_ss)->is_null(); default: return 0; } } void set_commit(int auto_commit=0) OTL_NO_THROW { (*auto_commit_flag)=auto_commit; if((*io)){ (*adb)->reset_throw_count(); (*io)->set_commit(auto_commit); } } void intern_cleanup(void) { delete[] (*iov); delete[] (*ov); (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; (*next_iov_ndx)=0; (*next_ov_ndx)=0; override->setLen(0); switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: try{ (*io)->flush(); (*io)->close(); }catch(OTL_CONST_EXCEPTION otl_exception&){ clean(1); (*io)->close(); delete (*io); (*io)=0; shell->stream_type=otl_ora7_no_stream; throw; } delete (*io); (*io)=0; shell->stream_type=otl_ora7_no_stream; break; case otl_ora7_select_stream: try{ (*ss)->close(); }catch(OTL_CONST_EXCEPTION otl_exception&){ delete (*ss); (*ss)=0; shell->stream_type=otl_ora7_no_stream; throw; } delete (*ss); (*ss)=0; shell->stream_type=otl_ora7_no_stream; break; case otl_ora7_refcur_select_stream: try{ (*ref_ss)->close(); }catch(OTL_CONST_EXCEPTION otl_exception&){ delete (*ref_ss); (*ref_ss)=0; shell->stream_type=otl_ora7_no_stream; throw; } delete (*ref_ss); (*ref_ss)=0; shell->stream_type=otl_ora7_no_stream; break; } (*ss)=0; (*io)=0; (*ref_ss)=0; if(adb!=0)(*adb)=0; adb=0; } void open (const otl_stream_buffer_size_type arr_size, const char* sqlstm, otl_connect& db, const char* ref_cur_placeholder=0, const char* sqlstm_label=0) OTL_THROWS_OTL_EXCEPTION { reset_end_marker(); if(this->good()){ const char* temp_stm_text=0; switch(shell->stream_type){ case otl_ora7_no_stream: temp_stm_text=OTL_NO_STM_TEXT; break; case otl_ora7_io_stream: temp_stm_text=(*io)->get_stm_label()? (*io)->get_stm_label():(*io)->get_stm_text(); break; case otl_ora7_select_stream: temp_stm_text=(*ss)->get_stm_label()? (*ss)->get_stm_label():(*ss)->get_stm_text(); case otl_ora7_refcur_select_stream: temp_stm_text=(*ref_ss)->get_stm_label()? (*ref_ss)->get_stm_label():(*ref_ss)->get_stm_text(); break; default: temp_stm_text=OTL_NO_STM_TEXT; break; } throw otl_exception (otl_error_msg_29, otl_error_code_29, temp_stm_text); } if(shell==0) init_stream(); buf_size_=arr_size; OTL_TRACE_STREAM_OPEN2 #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) char temp_buf[128]; otl_itoa(arr_size,temp_buf); OTL_STRING_CONTAINER sql_stm=OTL_STRING_CONTAINER(temp_buf)+ OTL_STRING_CONTAINER("===>")+sqlstm; otl_stream_shell* temp_shell=OTL_RCAST(otl_stream_shell*, db.sc.find(sql_stm)); if(temp_shell){ if(shell!=0) shell_pt.destroy(); shell=temp_shell; ref_ss=&(shell->ref_ss); ss=&(shell->ss); io=&(shell->io); if((*io)!=0)(*io)->set_flush_flag2(true); adb=&(shell->adb); auto_commit_flag=&(shell->auto_commit_flag); iov=&(shell->iov); iov_len=&(shell->iov_len); next_iov_ndx=&(shell->next_iov_ndx); ov=&(shell->ov); ov_len=&(shell->ov_len); next_ov_ndx=&(shell->next_ov_ndx); override=&(shell->override); override->set_master_stream_ptr(OTL_RCAST(void*,this)); try{ if((*iov_len)==0)this->rewind(); }catch(OTL_CONST_EXCEPTION otl_exception&){ if((*adb)) (*adb)->sc.remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; throw; } connected=1; return; } shell->orig_sql_stm=sql_stm; #endif delete[] (*iov); delete[] (*ov); (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; (*next_iov_ndx)=0; (*next_ov_ndx)=0; char tmp[7]; char* c=OTL_CCAST(char*,sqlstm); while(otl_isspace(*c)||(*c)=='(')++c; OTL_STRNCPY_S(tmp,sizeof(tmp),c,6); tmp[6]=0; c=tmp; while(*c){ *c=OTL_SCAST(char,otl_to_upper(*c)); ++c; } if(adb==0)adb=&(shell->adb); (*adb)=&db; (*adb)->reset_throw_count(); try{ if((strncmp(tmp,"SELECT",6)==0|| strncmp(tmp,"WITH",4)==0)&& ref_cur_placeholder==0){ override->set_master_stream_ptr(OTL_RCAST(void*,this)); (*ss)=new otl_select_stream (override, arr_size, sqlstm, db, otl_explicit_select, sqlstm_label); shell->stream_type=otl_ora7_select_stream; }else if(ref_cur_placeholder!=0){ override->set_master_stream_ptr(OTL_RCAST(void*,this)); (*ref_ss)=new otl_ref_select_stream (override,arr_size,sqlstm, ref_cur_placeholder,db, sqlstm_label); shell->stream_type=otl_ora7_refcur_select_stream; }else{ (*io)=new otl_inout_stream (arr_size,sqlstm,db, OTL_RCAST(void*,this), false,sqlstm_label); (*io)->set_flush_flag(shell->flush_flag); shell->stream_type=otl_ora7_io_stream; } }catch(OTL_CONST_EXCEPTION otl_exception&){ shell_pt.destroy(); throw; } if((*io))(*io)->set_commit((*auto_commit_flag)); create_var_desc(); connected=1; } #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) void close(const bool save_in_stream_pool=true) OTL_THROWS_OTL_EXCEPTION #else void close(void) OTL_THROWS_OTL_EXCEPTION #endif { if(shell==0)return; OTL_TRACE_FUNC(0x4,"otl_stream","close","") #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) if(save_in_stream_pool&&(*adb)&& #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) !(otl_uncaught_exception())&& #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) !(otl_uncaught_exception())&& #endif (*adb)->get_throw_count()==0){ try{ this->flush(); this->clean(1); }catch(OTL_CONST_EXCEPTION otl_exception&){ this->clean(1); throw; } if((*adb) && (*adb)->get_throw_count()>0){ (*adb)->sc.remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; return; } #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) if(otl_uncaught_exception()){ if((*adb)) (*adb)->sc.remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; return; } #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) if(otl_uncaught_exception()){ if((*adb)) (*adb)->sc.remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; return; } #endif (*adb)->sc.add(shell,shell->orig_sql_stm.c_str()); shell_pt.disconnect(); connected=0; }else{ if((*adb)) (*adb)->sc.remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; } #else intern_cleanup(); connected=0; #endif } otl_column_desc* describe_select(int& desc_len) OTL_NO_THROW { desc_len=0; switch(shell->stream_type){ case otl_ora7_no_stream: return 0; case otl_ora7_io_stream: return 0; case otl_ora7_select_stream: (*adb)->reset_throw_count(); desc_len=(*ss)->get_sl_len(); return (*ss)->get_sl_desc(); case otl_ora7_refcur_select_stream: (*adb)->reset_throw_count(); desc_len=(*ref_ss)->sl_len; return (*ref_ss)->sl_desc; default: return 0; } } int good(void) OTL_NO_THROW { if(!connected)return 0; if((*io)||(*ss)||(*ref_ss)){ (*adb)->reset_throw_count(); return 1; }else return 0; } otl_stream& operator>>(otl_stream& (*pf) (otl_stream&)) { (*pf)(*this); return *this; } otl_stream& operator<<(otl_stream& (*pf) (otl_stream&)) { (*pf)(*this); return *this; } otl_stream& operator>>(otl_pl_tab_generic& tab) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; if((*io)){ last_eof_rc=(*io)->eof(); (*io)->operator>>(tab); OTL_TRACE_WRITE(", tab len="<>","PL/SQL Tab&") inc_next_ov(); } return *this; } otl_stream& operator<<(otl_pl_tab_generic& tab) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); if((*io)){ OTL_TRACE_READ(", tab len="<operator<<(tab); inc_next_iov(); } return *this; } #if defined(OTL_PL_TAB) && defined(OTL_STL) otl_stream& operator>>(otl_pl_vec_generic& vec) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; if((*io)){ last_eof_rc=(*io)->eof(); (*io)->operator>>(vec); OTL_TRACE_WRITE(", tab len="<>","PL/SQL Tab&") inc_next_ov(); } return *this; } otl_stream& operator<<(otl_pl_vec_generic& vec) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); if((*io)){ (*io)->operator<<(vec); OTL_TRACE_READ(", tab len="<>(otl_time0& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); break; } return *this; } otl_stream& operator<<(const otl_time0& n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: (*io)->operator<<(n); break; case otl_ora7_select_stream: (*ss)->operator<<(n); break; case otl_ora7_refcur_select_stream: (*ref_ss)->operator<<(n); if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } return *this; } otl_stream& operator>>(otl_datetime& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; #if defined(OTL_ORA7) && defined(OTL_ORA7_STRING_TO_TIMESTAMP) if(describe_next_out_var()->ftype==otl_var_char){ char tmp_str[100]; (*this)>>tmp_str; #if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_DATETIME_NULL_TO_VAL; else OTL_ORA7_STRING_TO_TIMESTAMP(tmp_str,s); #else OTL_ORA7_STRING_TO_TIMESTAMP(tmp_str,s); #endif OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&"); return *this; }else{ otl_time0 tmp; (*this)>>tmp; #if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_DATETIME_NULL_TO_VAL; else{ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100); s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour-1; s.minute=tmp.minute-1; s.second=tmp.second-1; } #else s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100); s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour-1; s.minute=tmp.minute-1; s.second=tmp.second-1; #endif OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&") inc_next_ov(); return *this; } #else otl_time0 tmp; (*this)>>tmp; #if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_DATETIME_NULL_TO_VAL; else{ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100); s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour-1; s.minute=tmp.minute-1; s.second=tmp.second-1; } #else s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100); s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour-1; s.minute=tmp.minute-1; s.second=tmp.second-1; #endif OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&") inc_next_ov(); return *this; #endif } otl_stream& operator<<(const otl_datetime& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); #if defined(OTL_ORA7) && defined(OTL_ORA7_TIMESTAMP_TO_STRING) if(describe_next_in_var()->ftype==otl_var_char){ char tmp_str[100]; OTL_ORA7_TIMESTAMP_TO_STRING(s,tmp_str); OTL_TRACE_READ (OTL_TRACE_FORMAT_DATETIME(s), "operator <<", "otl_datetime&"); (*this)<>(char& c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(c); break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(c); break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(c); break; } #if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL) if((*this).is_null()) c=OTL_DEFAULT_CHAR_NULL_TO_VAL; #endif OTL_TRACE_WRITE("'"<>","char&") inc_next_ov(); return *this; } otl_stream& operator>>(unsigned char& c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(c); break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(c); break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(c); break; } #if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL) if((*this).is_null()) c=OTL_DEFAULT_CHAR_NULL_TO_VAL; #endif OTL_TRACE_WRITE("'"<>","unsigned char&") inc_next_ov(); return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) otl_stream& operator>>(OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); break; } #if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL) if((*this).is_null()){ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s); } #elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_STRING_NULL_TO_VAL; #endif OTL_TRACE_WRITE("\""<>","OTL_STRING_CONTAINER&") inc_next_ov(); return *this; } #endif otl_stream& operator>>(char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); break; } #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL) ); #endif OTL_TRACE_WRITE("\""<>","char*") inc_next_ov(); return *this; } otl_stream& operator>>(unsigned char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); break; } #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL) ); #endif #if defined(OTL_UNICODE) OTL_TRACE_WRITE ("\""<>", OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*") #else OTL_TRACE_WRITE("\""<>","unsigned char*") #endif inc_next_ov(); return *this; } otl_stream& operator>>(int& n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(n); #else (*io)->operator>>(n); #endif break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(n); #else (*ss)->operator>>(n); #endif break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(n); #else (*ref_ss)->operator>>(n); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) n=OTL_SCAST(int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(n,"operator >>","int&") inc_next_ov(); return *this; } otl_stream& operator>>(unsigned& u) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(u); #else (*io)->operator>>(u); #endif break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(u); #else (*ss)->operator>>(u); #endif break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(u); #else (*ref_ss)->operator>>(u); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) u=OTL_SCAST(unsigned int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(u,"operator >>","unsigned&") inc_next_ov(); return *this; } otl_stream& operator>>(short& sh) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(sh); #else (*io)->operator>>(sh); #endif break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(sh); #else (*ss)->operator>>(sh); #endif break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(sh); #else (*ref_ss)->operator>>(sh); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) sh=OTL_SCAST(short int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(sh,"operator >>","short int&") inc_next_ov(); return *this; } otl_stream& operator>>(long int& l) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(l); #else (*io)->operator>>(l); #endif break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(l); #else (*ss)->operator>>(l); #endif break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(l); #else (*ref_ss)->operator>>(l); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) l=OTL_SCAST(long int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(l,"operator >>","long int&") inc_next_ov(); return *this; } otl_stream& operator>>(float& f) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(f); #else (*io)->operator>>(f); #endif break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(f); #else (*ss)->operator>>(f); #endif break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(f); #else (*ref_ss)->operator>>(f); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) f=OTL_SCAST(float,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(f,"operator >>","float&") inc_next_ov(); return *this; } otl_stream& operator>>(double& d) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator>>(d); #else (*io)->operator>>(d); #endif break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(d); #else (*ss)->operator>>(d); #endif break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(d); #else (*ref_ss)->operator>>(d); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) d=OTL_SCAST(double,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(d,"operator >>","double&") inc_next_ov(); return *this; } otl_stream& operator>>(otl_long_string& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_ora7_select_stream: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; case otl_ora7_refcur_select_stream: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); break; } OTL_TRACE_WRITE(" len="<>","otl_long_string&") inc_next_ov(); return *this; } otl_stream& operator<<(const char c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("'"<stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: (*io)->operator<<(c); break; case otl_ora7_select_stream: (*ss)->operator<<(c); break; case otl_ora7_refcur_select_stream: (*ref_ss)->operator<<(c); if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const unsigned char c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("'"<stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: (*io)->operator<<(c); break; case otl_ora7_select_stream: (*ss)->operator<<(c); break; case otl_ora7_refcur_select_stream: (*ref_ss)->operator<<(c); if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) otl_stream& operator<<(const OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("\""<stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: (*io)->operator<<(s); break; case otl_ora7_select_stream: (*ss)->operator<<(s); break; case otl_ora7_refcur_select_stream: (*ref_ss)->operator<<(s); if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } #endif otl_stream& operator<<(const char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("\""<stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: (*io)->operator<<(s); break; case otl_ora7_select_stream: (*ss)->operator<<(s); break; case otl_ora7_refcur_select_stream: (*ref_ss)->operator<<(s); if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const unsigned char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); #if defined(OTL_UNICODE) OTL_TRACE_READ ("\""<stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: (*io)->operator<<(s); break; case otl_ora7_select_stream: (*ss)->operator<<(s); break; case otl_ora7_refcur_select_stream: (*ref_ss)->operator<<(s); if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const int n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(n,"operator <<","int") switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(n); #else (*io)->operator<<(n); #endif break; case otl_ora7_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(n); #else (*ss)->operator<<(n); #endif break; case otl_ora7_refcur_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(n); #else (*ref_ss)->operator<<(n); #endif if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const unsigned u) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(u,"operator <<","unsigned") switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(u); #else (*io)->operator<<(u); #endif break; case otl_ora7_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(u); #else (*ss)->operator<<(u); #endif break; case otl_ora7_refcur_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(u); #else (*ref_ss)->operator<<(u); #endif if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const short sh) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(sh,"operator <<","short int") switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(sh); #else (*io)->operator<<(sh); #endif break; case otl_ora7_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(sh); #else (*ss)->operator<<(sh); #endif break; case otl_ora7_refcur_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(sh); #else (*ref_ss)->operator<<(sh); #endif if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const long int l) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(l,"operator <<","long int") switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(l); #else (*io)->operator<<(l); #endif break; case otl_ora7_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(l); #else (*ss)->operator<<(l); #endif break; case otl_ora7_refcur_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(l); #else (*ref_ss)->operator<<(l); #endif if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const float f) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(f,"operator <<","float") switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(f); #else (*io)->operator<<(f); #endif break; case otl_ora7_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(f); #else (*ss)->operator<<(f); #endif break; case otl_ora7_refcur_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(f); #else (*ref_ss)->operator<<(f); #endif if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const double d) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(d,"operator <<","double") switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*io)->operator<<(d); #else (*io)->operator<<(d); #endif break; case otl_ora7_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(d); #else (*ss)->operator<<(d); #endif break; case otl_ora7_refcur_select_stream: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(d); #else (*ref_ss)->operator<<(d); #endif if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const otl_null& n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("NULL","operator <<","otl_null&") switch(shell->stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: (*io)->operator<<(n); break; case otl_ora7_select_stream: (*ss)->operator<<(n); break; case otl_ora7_refcur_select_stream: (*ref_ss)->operator<<(n); if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const otl_long_string& d) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(" len="<stream_type){ case otl_ora7_no_stream: break; case otl_ora7_io_stream: (*io)->operator<<(d); break; case otl_ora7_select_stream: (*ss)->operator<<(d); break; case otl_ora7_refcur_select_stream: (*ref_ss)->operator<<(d); if(!(*ov)&&(*ref_ss)->sl) create_var_desc(); break; } inc_next_iov(); return *this; } private: otl_stream& operator=(const otl_stream&) { return *this; } otl_stream(const otl_stream&): shell(0), shell_pt(), connected(0), ref_ss(0), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), override(0), end_marker(0), oper_int_called(0), last_eof_rc(0), last_oper_was_read_op(0), buf_size_(0) { } #if !defined(OTL_STREAM_NO_PRIVATE_BOOL_OPERATORS) otl_stream& operator>>(bool&) OTL_NO_THROW { return *this; } otl_stream& operator<<(const bool) OTL_NO_THROW { return *this; } #endif #if !defined(OTL_STREAM_NO_PRIVATE_UNSIGNED_LONG_OPERATORS) otl_stream& operator>>(unsigned long int&) OTL_NO_THROW { return *this; } otl_stream& operator<<(const unsigned long int) OTL_NO_THROW { return *this; } #endif }; inline otl_connect& operator>>(otl_connect& connect, otl_stream& s) { const char* cmd=connect.getCmd(); const char* invalid_cmd="*** INVALID COMMAND ***"; if(!cmd) cmd=invalid_cmd; s.open(s.getBufSize(),cmd,connect); return connect; } #if (defined(OTL_STL)||defined(OTL_VALUE_TEMPLATE_ON)) && defined(OTL_VALUE_TEMPLATE) template otl_stream& operator<<(otl_stream& s, const otl_value& var) OTL_THROWS_OTL_EXCEPTION { if(var.ind) s< otl_stream& operator>>(otl_stream& s, otl_value& var) OTL_THROWS_OTL_EXCEPTION { s>>var.v; if(s.is_null()) var.ind=true; else var.ind=false; return s; } #endif typedef otl_tmpl_nocommit_stream otl_nocommit_stream; #if defined(OTL_BIGINT) && defined(OTL_STR_TO_BIGINT) && \ defined(OTL_BIGINT_TO_STR) inline otl_stream& operator>>(otl_stream& s, OTL_BIGINT& n) OTL_THROWS_OTL_EXCEPTION { char temp_val[otl_bigint_str_size]; s>>temp_val; if(s.is_null()){ #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if(s.is_null()) n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif return s; } OTL_STR_TO_BIGINT(temp_val,n) return s; } inline otl_stream& operator<<(otl_stream& s, const OTL_BIGINT n) OTL_THROWS_OTL_EXCEPTION { char temp_val[otl_bigint_str_size]; OTL_BIGINT_TO_STR(n,temp_val); s<>(otl_stream& s, OTL_BIGINT& n) OTL_THROWS_OTL_EXCEPTION { long temp_val; s>>temp_val; if(s.is_null()){ #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if(s.is_null()) n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif return s; } n=OTL_SCAST(OTL_BIGINT,temp_val); return s; } inline otl_stream& operator<<(otl_stream& s, const OTL_BIGINT n) OTL_THROWS_OTL_EXCEPTION { long temp_val=OTL_SCAST(long,n); s< #if !defined(OTL_ORA_DOES_NOT_UNDEF_MIN_MAX) #if defined(min) #undef min #endif #if defined(max) #undef max #endif #endif #define OTL_UTF8_BYTES_PER_CHAR (4) #if defined(OTL_ORA8_PROC) extern "C" { #include } #endif OTL_ORA8_NAMESPACE_BEGIN const int inVarChar2=1; const int inNumber=2; const int inLong=8; const int inRowId=104; const int inDate=12; const int inRaw=23; const int inLongRaw=24; const int inChar=96; #if defined(OTL_ORA10G)||defined(OTL_ORA10G_R2) const int inBFloat=SQLT_IBFLOAT; const int inBDouble=SQLT_IBDOUBLE; #endif const int inMslabel=105; const int inUserDefinedType=108; const int inRef=111; const int inCLOB=112; const int inBLOB=113; #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) const int inTimestamp=SQLT_TIMESTAMP; const int inTimestamp_TZ=SQLT_TIMESTAMP_TZ; const int inTimestamp_LTZ=SQLT_TIMESTAMP_LTZ; const int inIntervalYM=SQLT_INTERVAL_YM; const int inIntervalDS=SQLT_INTERVAL_DS; #endif const int extVarChar2=1; const int extNumber=2; const int extInt=3; const int extFloat=4; #if defined(OTL_ORA_MAP_STRINGS_TO_CHARZ) const int extCChar=97; #else const int extCChar=5; #endif const int extVarNum=6; const int extLong=8; const int extVarChar=9; const int extRowId=11; const int extDate=12; const int extVarRaw=15; const int extRaw=extVarRaw; const int extLongRaw=24; const int extUInt=68; const int extLongVarChar=94; const int extLongVarRaw=95; const int extChar=96; const int extCharZ=97; const int extMslabel=105; const int extCLOB=inCLOB; const int extBLOB=inBLOB; #if (defined(OTL_ORA10G)||defined(OTL_ORA10G_R2))&&!defined(OTL_ORA_LEGACY_NUMERIC_TYPES) const int extBFloat=SQLT_BFLOAT; const int extBDouble=SQLT_BDOUBLE; #endif #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) const int extTimestamp=SQLT_TIMESTAMP; const int extTimestamp_TZ=SQLT_TIMESTAMP_TZ; const int extTimestamp_LTZ=SQLT_TIMESTAMP_LTZ; #endif #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) typedef otl_datetime otl_time0; #else typedef otl_oracle_date otl_time0; #endif class otl_exc{ public: unsigned char msg[1000]; int code; char sqlstate[32]; #if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET) int error_offset; #endif #if defined(OTL_EXTENDED_EXCEPTION) char** msg_arr; char** sqlstate_arr; int* code_arr; int arr_len; #endif enum{disabled=0,enabled=1}; otl_exc(): msg(), code(0), sqlstate() #if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET) ,error_offset(-1) #endif #if defined(OTL_EXTENDED_EXCEPTION) ,msg_arr(0), sqlstate_arr(0), code_arr(0), arr_len(0) #endif { sqlstate[0]=0; msg[0]=0; } virtual ~otl_exc(){} void init(const char* amsg, const int acode) { OTL_STRCPY_S(OTL_RCAST(char*,msg),sizeof(msg),amsg); code=acode; #if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET) error_offset=-1; #endif #if defined(OTL_EXTENDED_EXCEPTION) msg_arr=0; sqlstate_arr=0; code_arr=0; arr_len=0; #endif } }; class otl_cur; class otl_var; class otl_conn{ private: friend class otl_cur; friend class otl_var; OCIEnv *envhp; // OCI environment handle OCIServer *srvhp; // OCI Server handle OCIError *errhp; // OCI Error handle OCISvcCtx *svchp; // OCI Service context handle OCISession *authp; // OCI Session handle int auto_commit; int extern_lda; int attached; int in_session; int char_set_; int session_begin_count; int session_mode_; int ext_cred; int last_status; char* xa_server_external_name; char* xa_server_internal_name; #if defined(OTL_ORA_OCI_ENV_CREATE) bool threaded_mode; #endif public: #if defined(OTL_ORA_OCI_ENV_CREATE) void set_threaded_mode(const bool athreaded_mode) { threaded_mode=athreaded_mode; } #endif void cleanup(void) { session_end(); server_detach(); } int get_session_begin_count() const { return session_begin_count; } int get_extern_lda() const { return extern_lda; } int get_last_status() const { return last_status; } int get_auto_commit() const { return auto_commit; } OCIEnv* get_envhp() { return envhp; } OCIError* get_errhp() { return errhp; } OCISvcCtx* get_svchp() { return svchp; } OCIServer* get_srvhp() { return srvhp; } OCISession* get_authp() { return authp; } int get_char_set() const { return char_set_; } int get_connection_type(void) { return 0; } #if !defined(OTL_ORA_OCI_ENV_CREATE) static int initialize(const int threaded_mode=0) { int status; int mode; if(threaded_mode) mode=OCI_THREADED; else mode=OCI_DEFAULT; status=OCIInitialize (OTL_SCAST(ub4,mode), OTL_RCAST(dvoid *,0), 0, 0, 0); if(status!=OCI_SUCCESS) return 0; else return 1; #else static int initialize(const int /*threaded_mode*/) { return 1; #endif } otl_conn(): envhp(0), srvhp(0), errhp(0), svchp(0), authp(0), auto_commit(0), extern_lda(0), attached(0), in_session(0), char_set_(SQLCS_IMPLICIT), session_begin_count(0), session_mode_(OCI_DEFAULT), ext_cred(0), last_status(OCI_SUCCESS), xa_server_external_name(0), xa_server_internal_name(0) #if defined(OTL_ORA_OCI_ENV_CREATE) ,threaded_mode(false) #endif { } #if defined(OTL_ORA_OCI_ENV_CREATE) void set_connect_mode(bool mode) { threaded_mode=mode; } #endif void set_char_set(const int char_set) { char_set_=char_set; } void set_xa_server_external_name(const char* name) { if(xa_server_external_name){ delete[] xa_server_external_name; xa_server_external_name=0; } size_t len=strlen(name)+1; xa_server_external_name=new char[len]; OTL_STRCPY_S(xa_server_external_name,len,name); } void set_xa_server_internal_name(const char* name) { if(xa_server_internal_name){ delete[] xa_server_internal_name; xa_server_internal_name=0; } size_t len=strlen(name)+1; xa_server_internal_name=new char[len]; OTL_STRCPY_S(xa_server_internal_name,len,name); } void delete_xa_strings(void ) { if(xa_server_external_name){ delete[] xa_server_external_name; xa_server_external_name=0; } if(xa_server_internal_name){ delete[] xa_server_internal_name; xa_server_internal_name=0; } } virtual ~otl_conn() { delete_xa_strings(); } void set_timeout(const int /*atimeout*/=0){} void set_cursor_type(const int /*acursor_type*/=0){} int cancel(void) {int status; status=OCIBreak(srvhp,errhp); if(status) return 0; else return 1; } int server_attach(const char* tnsname) {int& status=last_status; envhp=0; srvhp=0; errhp=0; svchp=0; authp=0; extern_lda=0; attached=0; in_session=0; session_begin_count=0; #if !defined(OTL_ORA_OCI_ENV_CREATE) status=OCIEnvInit (OTL_RCAST(OCIEnv**,&envhp), OCI_DEFAULT, 0, 0); #else status=OCIEnvCreate (OTL_RCAST(OCIEnv**,&envhp), #if defined(OTL_ORA_OCI_ENV_CREATE_MODE) OTL_ORA_OCI_ENV_CREATE_MODE, #else threaded_mode?OCI_THREADED:OCI_DEFAULT, #endif 0, 0, 0, 0, 0, 0); #endif if(status)return 0; #if defined(__GNUC__) && (__GNUC__>=4) void* temp_errhp=&errhp; #endif status=OCIHandleAlloc (OTL_RCAST(dvoid*,envhp), #if defined(__GNUC__) && (__GNUC__>=4) OTL_RCAST(dvoid**,temp_errhp), #else OTL_RCAST(dvoid**,&errhp), #endif OCI_HTYPE_ERROR, 0, 0); if(status)return 0; #if defined(__GNUC__) && (__GNUC__>=4) void* temp_srvhp=&srvhp; #endif status=OCIHandleAlloc (OTL_RCAST(dvoid*,envhp), #if defined(__GNUC__) && (__GNUC__>=4) OTL_RCAST(dvoid**,temp_srvhp), #else OTL_RCAST(dvoid**,&srvhp), #endif OCI_HTYPE_SERVER, 0, 0); if(status)return 0; #if defined(__GNUC__) && (__GNUC__>=4) void * temp_svchp=&svchp; #endif status=OCIHandleAlloc (OTL_RCAST(dvoid*,envhp), #if defined(__GNUC__) && (__GNUC__>=4) OTL_RCAST(dvoid**,temp_svchp), #else OTL_RCAST(dvoid**,&svchp), #endif OCI_HTYPE_SVCCTX, 0, 0); if(status)return 0; status=OCIServerAttach (srvhp, errhp, tnsname==0?OTL_RCAST(text*,OTL_CCAST(char*,"")): OTL_RCAST(text*,OTL_CCAST(char*,tnsname)), tnsname==0?0:OTL_SCAST(sb4,strlen(OTL_CCAST(char*,tnsname))), 0); if(status)return 0; status=OCIAttrSet (OTL_RCAST(dvoid*,svchp), OCI_HTYPE_SVCCTX, OTL_RCAST(dvoid*,srvhp), 0, OCI_ATTR_SERVER, OTL_RCAST(OCIError*,errhp)); if(status)return 0; if(xa_server_external_name!=0 && xa_server_internal_name!=0){ status=OCIAttrSet (OTL_RCAST(dvoid*,srvhp), OCI_HTYPE_SERVER, OTL_RCAST(dvoid*,xa_server_external_name), 0, OCI_ATTR_EXTERNAL_NAME, errhp); if(status)return 0; status=OCIAttrSet (OTL_RCAST(dvoid*,srvhp), OCI_HTYPE_SERVER, OTL_RCAST(dvoid*,xa_server_internal_name), 0, OCI_ATTR_INTERNAL_NAME, errhp); if(status)return 0; } #if defined(__GNUC__) && (__GNUC__>=4) void* temp_authp=&authp; #endif status=OCIHandleAlloc (OTL_RCAST(dvoid*,envhp), #if defined(__GNUC__) && (__GNUC__>=4) OTL_RCAST(dvoid **,temp_authp), #else OTL_RCAST(dvoid **,&authp), #endif OTL_SCAST(ub4,OCI_HTYPE_SESSION), 0, 0); if(status)return 0; attached=1; return 1; } int session_begin(const int aauto_commit) {int& status=last_status; int cred_type; if(!attached)return 0; if(session_begin_count==0)return 0; if(ext_cred) cred_type=OCI_CRED_EXT; else cred_type=OCI_CRED_RDBMS; status=OCISessionBegin (svchp, errhp, authp, cred_type, OTL_SCAST(ub4,session_mode_)); if(status!=OCI_SUCCESS && status!=OCI_SUCCESS_WITH_INFO) return 0; in_session=1; auto_commit=aauto_commit; ++session_begin_count; return 1; } int session_begin (const char* userid, const char* password, const int aauto_commit, const int session_mode=OCI_DEFAULT) {int& status=last_status; int cred_type; if(!attached)return 0; status=OCIAttrSet (OTL_RCAST(dvoid*,authp), OTL_SCAST(ub4,OCI_HTYPE_SESSION), OTL_RCAST(dvoid*,OTL_CCAST(char*,userid)), OTL_SCAST(ub4,strlen(OTL_CCAST(char*,userid))), OTL_SCAST(ub4,OCI_ATTR_USERNAME), errhp); if(status)return 0; status=OCIAttrSet (OTL_RCAST(dvoid*,authp), OTL_SCAST(ub4,OCI_HTYPE_SESSION), OTL_RCAST(dvoid*,OTL_CCAST(char*,password)), OTL_SCAST(ub4,strlen(OTL_CCAST(char*,password))), OTL_SCAST(ub4,OCI_ATTR_PASSWORD), errhp); if(status)return 0; cred_type=OCI_CRED_RDBMS; if(userid[0]==0&&password[0]==0){ ext_cred=1; cred_type=OCI_CRED_EXT; }else{ ext_cred=0; cred_type=OCI_CRED_RDBMS; } session_mode_=session_mode; status=OCISessionBegin (svchp, errhp, authp, cred_type, OTL_SCAST(ub4,session_mode_)); if(status!=OCI_SUCCESS && status!=OCI_SUCCESS_WITH_INFO) return 0; status=OCIAttrSet (OTL_RCAST(dvoid*,svchp), OTL_SCAST(ub4,OCI_HTYPE_SVCCTX), OTL_RCAST(dvoid *,authp), 0, OTL_SCAST(ub4,OCI_ATTR_SESSION), errhp); if(status)return 0; in_session=1; auto_commit=aauto_commit; ++session_begin_count; return 1; } #if defined(OTL_ORA8I) || defined(OTL_ORA9I) int change_password (const char* user_name, const char* password, const char* new_password) {int& status=last_status; OCIAttrSet (OTL_RCAST(dvoid*,svchp), OTL_SCAST(ub4,OCI_HTYPE_SVCCTX), OTL_RCAST(dvoid *,authp), 0, OTL_SCAST(ub4,OCI_ATTR_SESSION), errhp); status=OCIPasswordChange (svchp, errhp, OTL_RCAST(text*,OTL_CCAST(char*,user_name)), OTL_SCAST(ub4,strlen(user_name)), OTL_RCAST(text*,OTL_CCAST(char*,password)), OTL_SCAST(ub4,strlen(password)), OTL_RCAST(text*,OTL_CCAST(char*,new_password)), OTL_SCAST(ub4,strlen(new_password)), OCI_AUTH); if(status) return 0; else return 1; } #endif int server_detach(void) {int rc=0; if(attached){ OCIServerDetach(srvhp,errhp,OTL_SCAST(ub4,OCI_DEFAULT)); rc=1; } if(authp!=0)OCIHandleFree(OTL_RCAST(dvoid*,authp), OTL_SCAST(ub4,OCI_HTYPE_SESSION)); if(errhp!=0)OCIHandleFree(OTL_RCAST(dvoid*,errhp), OTL_SCAST(ub4,OCI_HTYPE_ERROR)); if(svchp!=0)OCIHandleFree(OTL_RCAST(dvoid*,svchp), OTL_SCAST(ub4,OCI_HTYPE_SVCCTX)); if(srvhp!=0)OCIHandleFree(OTL_RCAST(dvoid*,srvhp), OTL_SCAST(ub4,OCI_HTYPE_SERVER)); if(envhp!=0)OCIHandleFree(OTL_RCAST(dvoid*,envhp), OTL_SCAST(ub4,OCI_HTYPE_ENV)); auto_commit=0; attached=0; in_session=0; envhp=0; srvhp=0; errhp=0; svchp=0; authp=0; delete_xa_strings(); return rc; } int session_end(void) {int& status=last_status; if(!in_session)return 0; status=OCISessionEnd(svchp,errhp,authp,0); if(status)return 0; in_session=0; auto_commit=0; return 1; } int auto_commit_on(void) { auto_commit=1; return 1; } int auto_commit_off(void) { auto_commit=0; return 1; } int rlogon(const char* connect_str,const int aauto_commit) { int status; char username[256]; char passwd[256]; char tnsname[1024]; char* tnsname_ptr=0; char* username_ptr=username; char* c=OTL_CCAST(char*,connect_str); char* passwd_ptr=passwd; char prev_c=' '; auto_commit=aauto_commit; username[0]=0; passwd[0]=0; tnsname[0]=0; while(*c&&*c!='/'&&(OTL_SCAST(unsigned,username_ptr-username)< sizeof(username)-1)){ *username_ptr=*c; ++c; ++username_ptr; } *username_ptr=0; if(*c=='/')++c; prev_c=' '; while(*c && !(*c=='@' && prev_c!='\\') && (OTL_SCAST(unsigned,passwd_ptr-passwd)=4) void* temp_errhp=&errhp; #endif status=OCIHandleAlloc (OTL_RCAST(dvoid*,envhp), #if defined(__GNUC__) && (__GNUC__>=4) OTL_RCAST(dvoid**,temp_errhp), #else OTL_RCAST(dvoid**,&errhp), #endif OCI_HTYPE_ERROR, 0, 0); if(status)return 0; return 1; } int logoff(void) { int rc; if(extern_lda){ OCIHandleFree(OTL_RCAST(dvoid*,errhp), OTL_SCAST(ub4,OCI_HTYPE_ERROR)); envhp=0; svchp=0; errhp=0; extern_lda=0; }else{ rc=session_end(); if(!rc)return 0; rc=server_detach(); if(!rc)return 0; } auto_commit=0; return 1; } void error(otl_exc& exception_struct) {sb4 errcode; size_t len; OCIErrorGet (OTL_RCAST(dvoid*,errhp), OTL_SCAST(ub4,1), 0, &errcode, OTL_RCAST(text*,exception_struct.msg), OTL_SCAST(ub4,sizeof(exception_struct.msg)), OCI_HTYPE_ERROR); exception_struct.code=errcode; len=strlen(OTL_RCAST(char*,exception_struct.msg)); exception_struct.msg[len]=0; } int commit(void) { last_status=OCITransCommit(svchp,errhp,OTL_SCAST(ub4,OCI_DEFAULT)); return !last_status; } #if defined(OTL_ORA10G_R2) int commit_nowait(void) { #if defined(OCI_TRANS_WRITENOWAIT) last_status=OCITransCommit (svchp, errhp, OTL_SCAST(ub4,OCI_TRANS_WRITENOWAIT)); #else last_status=OCITransCommit (svchp, errhp, OTL_SCAST(ub4,0x00000008)); #endif return !last_status; } #endif int rollback(void) { last_status=OCITransRollback(svchp,errhp,OTL_SCAST(ub4,OCI_DEFAULT)); return !last_status; } private: otl_conn(const otl_conn&): envhp(0), srvhp(0), errhp(0), svchp(0), authp(0), auto_commit(0), extern_lda(0), attached(0), in_session(0), char_set_(SQLCS_IMPLICIT), session_begin_count(0), session_mode_(OCI_DEFAULT), ext_cred(0), last_status(OCI_SUCCESS), xa_server_external_name(0), xa_server_internal_name(0) #if defined(OTL_ORA_OCI_ENV_CREATE) ,threaded_mode(false) #endif { } otl_conn& operator=(const otl_conn&) { return *this; } }; class otl_cur0{ public: virtual ~otl_cur0(){} }; class otl_cur; class otl_inout_stream; class otl_refcur_stream; class otl_ref_select_stream; class otl_var{ private: friend class otl_cur; friend class otl_inout_stream; friend class otl_refcur_stream; friend class otl_ref_select_stream; ub1* p_v; sb2* p_ind; ub2* p_rlen; ub2* p_rcode; int ftype; int array_size; int elem_size; bool nls_flag; OCILobLocator** lob; #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) OCIDateTime** timestamp; #endif OCIStmt* cda; otl_conn* connect; ub1* buf; int buf_len; int ext_buf_flag; int act_elem_size; ub4 max_tab_len; ub4 cur_tab_len; int pl_tab_flag; int lob_stream_flag; int vparam_type; int lob_len; int lob_pos; int lob_ftype; int otl_adapter; bool lob_stream_mode; sb4 unicode_var_len; ub2 csid; ub1 csfrm; ub4 read_blob_amt; ub4 total_read_blob_amt; bool charz_flag; bool select_stm_flag; public: int get_otl_adapter() const {return otl_adapter;} OCIStmt* get_cda(){return cda;} OCIStmt** get_cda_ptr(){return &cda;} void set_nls_flag(const bool anls_flag) { nls_flag=anls_flag; } void set_lob_stream_mode(const bool alob_stream_mode) { lob_stream_mode=alob_stream_mode; } void set_vparam_type(const int avparam_type) { vparam_type=avparam_type; } void set_charz_flag(const bool acharz_flag) { charz_flag=acharz_flag; } otl_var(): p_v(0), p_ind(0), p_rlen(0), p_rcode(0), ftype(0), array_size(0), elem_size(0), nls_flag(false), lob(0), #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) timestamp(0), #endif cda(0), connect(0), buf(0), buf_len(0), ext_buf_flag(0), act_elem_size(0), max_tab_len(0), cur_tab_len(0), pl_tab_flag(0), lob_stream_flag(0), vparam_type(-1), lob_len(0), lob_pos(0), lob_ftype(0), otl_adapter(otl_ora8_adapter), lob_stream_mode(false), unicode_var_len(0), csid(0), csfrm(SQLCS_IMPLICIT), read_blob_amt(0), total_read_blob_amt(0), charz_flag(false), select_stm_flag(false) { } virtual ~otl_var() {int i; if(ftype==otl_var_refcur&&cda!=0){ OCIHandleFree(OTL_RCAST(dvoid*,cda),OCI_HTYPE_STMT); cda=0; } if(ftype==otl_var_blob||(ftype==otl_var_clob&&lob!=0)){ for(i=0;ienvhp, connect->errhp, trg_ptr, OTL_SCAST(sb2,src_ptr->year), OTL_SCAST(ub1,src_ptr->month), OTL_SCAST(ub1,src_ptr->day), OTL_SCAST(ub1,src_ptr->hour), OTL_SCAST(ub1,src_ptr->minute), OTL_SCAST(ub1,src_ptr->second), OTL_SCAST (ub4,otl_to_fraction(src_ptr->fraction, src_ptr->frac_precision)), 0, 0); }else{ int tz_hour=src_ptr->tz_hour; int tz_minute=src_ptr->tz_minute; char tz_str[60]; char* tzc=otl_itoa(tz_hour,tz_str); *tzc=':'; ++tzc; tzc=otl_itoa(tz_minute,tzc); size_t tz_len=tzc-tz_str; rc=OCIDateTimeConstruct (connect->envhp, connect->errhp, trg_ptr, OTL_SCAST(sb2,src_ptr->year), OTL_SCAST(ub1,src_ptr->month), OTL_SCAST(ub1,src_ptr->day), OTL_SCAST(ub1,src_ptr->hour), OTL_SCAST(ub1,src_ptr->minute), OTL_SCAST(ub1,src_ptr->second), OTL_SCAST (ub4,otl_to_fraction(src_ptr->fraction, src_ptr->frac_precision)), OTL_RCAST(text*,tz_str), tz_len); } if(rc!=0)return 0; return 1; #else memcpy(trg,src,sz); return 1; #endif } int read_dt(void* trg, const void* src, const int #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) #else sz #endif ) { #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) OCIDateTime* src_ptr=OTL_RCAST(OCIDateTime*,OTL_CCAST(void*,src)); otl_datetime* trg_ptr=OTL_RCAST(otl_datetime*,OTL_CCAST(void*,trg)); sb2 year; ub1 month, day, hour, minute, sec; ub4 fsec; sb1 tz_hour; sb1 tz_minute; int rc=OCIDateTimeGetDate (connect->envhp, connect->errhp, src_ptr, &year, &month, &day); if(rc!=0)return 0; rc=OCIDateTimeGetTime (connect->envhp, connect->errhp, src_ptr, &hour, &minute, &sec, &fsec); if(rc!=0)return 0; trg_ptr->year=year; trg_ptr->month=month; trg_ptr->day=day; trg_ptr->hour=hour; trg_ptr->minute=minute; trg_ptr->second=sec; trg_ptr->fraction=otl_from_fraction(fsec,trg_ptr->frac_precision); trg_ptr->tz_hour=0; trg_ptr->tz_minute=0; if(ftype==otl_var_tz_timestamp || ftype==otl_var_ltz_timestamp){ rc=OCIDateTimeGetTimeZoneOffset (connect->envhp, connect->errhp, src_ptr, &tz_hour, &tz_minute); if(rc!=0)return 0; trg_ptr->tz_hour=tz_hour; trg_ptr->tz_minute=tz_minute; } return 1; #else memcpy(trg,src,sz); return 1; #endif } int actual_elem_size(void) { return act_elem_size; } void init (const bool aselect_stm_flag, const int aftype, int& aelem_size, const otl_stream_buffer_size_type aarray_size, const void* connect_struct=0, const int apl_tab_flag=0) { int i; ub4 lobEmpty=0; select_stm_flag=aselect_stm_flag; connect=OTL_RCAST(otl_conn*,OTL_CCAST(void*,connect_struct)); ftype=aftype; #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) if(ftype==otl_var_nchar){ ftype=otl_var_char; nls_flag=true; }else if(ftype==otl_var_nclob){ ftype=otl_var_clob; nls_flag=true; } #endif pl_tab_flag=apl_tab_flag; act_elem_size=aelem_size; #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) if((ftype==otl_var_timestamp || ftype==otl_var_tz_timestamp || ftype==otl_var_ltz_timestamp) && apl_tab_flag) act_elem_size=sizeof(otl_oracle_date); #endif if(ftype==otl_var_refcur){ array_size=aarray_size; elem_size=1; #if defined(__GNUC__) && (__GNUC__>=4) void* temp_cda=&cda; #endif OCIHandleAlloc (OTL_RCAST(dvoid*,connect->get_envhp()), #if defined(__GNUC__) && (__GNUC__>=4) OTL_RCAST(dvoid**,temp_cda), #else OTL_RCAST(dvoid**,&cda), #endif OCI_HTYPE_STMT, 0, 0); #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) }else if((ftype==otl_var_timestamp || ftype==otl_var_tz_timestamp || ftype==otl_var_ltz_timestamp) && !apl_tab_flag){ array_size=aarray_size; elem_size=sizeof(OCIDateTime*); act_elem_size=elem_size; timestamp=new OCIDateTime*[array_size]; p_v=OTL_RCAST(ub1*,timestamp); p_ind=new sb2[array_size]; p_rlen=new ub2[array_size]; p_rcode=new ub2[array_size]; for(i=0;ienvhp), OTL_RCAST(dvoid**,×tamp[i]), dtype, 0, 0); write_dt(timestamp[i],&dt,1); } }else timestamp=0; #endif }else if(ftype==otl_var_blob||ftype==otl_var_clob){ array_size=aarray_size; elem_size=aelem_size; lob=new OCILobLocator*[array_size]; p_v=OTL_RCAST(ub1*,lob); p_ind=new sb2[array_size]; p_rlen=0; p_rcode=0; if(connect!=0){ for(i=0;iget_envhp()), OTL_RCAST(dvoid**,&lob[i]), OTL_SCAST(ub4,OCI_DTYPE_LOB), 0, 0); lobEmpty=0; OCIAttrSet (OTL_RCAST(dvoid*,lob[i]), OCI_DTYPE_LOB, OTL_RCAST(dvoid*,&lobEmpty), 0, OCI_ATTR_LOBEMPTY, OTL_RCAST(OCIError*,connect->get_errhp())); } }else lob=0; }else{ if(ftype==otl_var_varchar_long||ftype==otl_var_raw_long){ elem_size=aelem_size+sizeof(sb4); array_size=1; }else if(ftype==otl_var_raw){ elem_size=aelem_size+sizeof(short int); array_size=aarray_size; }else{ elem_size=aelem_size; array_size=aarray_size; #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) if((ftype==otl_var_timestamp || ftype==otl_var_tz_timestamp || ftype==otl_var_ltz_timestamp) && apl_tab_flag){ elem_size=sizeof(otl_oracle_date); aelem_size=elem_size; // sending feedback back to the template class } #endif } #if defined(OTL_UNICODE) if(ftype==otl_var_char){ unsigned unicode_buffer_size= elem_size*OTL_SCAST(unsigned,array_size)*sizeof(OTL_WCHAR); p_v=new ub1[unicode_buffer_size]; memset(p_v,0,unicode_buffer_size); } else if(ftype==otl_var_varchar_long){ unsigned unicode_buffer_size=elem_size; p_v=new ub1[unicode_buffer_size]; memset(p_v,0,unicode_buffer_size); }else{ p_v=new ub1[elem_size*OTL_SCAST(unsigned,array_size)]; memset(p_v,0,elem_size*OTL_SCAST(unsigned,array_size)); } #elif defined(OTL_ORA_UTF8) if(ftype==otl_var_char){ unsigned buffer_size=elem_size*OTL_SCAST(unsigned,array_size); if(select_stm_flag) buffer_size*=OTL_UTF8_BYTES_PER_CHAR; // 3 bytes per UTF8 char on SELECT by default p_v=new ub1[buffer_size]; memset(p_v,0,buffer_size); } else if(ftype==otl_var_varchar_long){ p_v=new ub1[elem_size]; memset(p_v,0,elem_size); }else{ p_v=new ub1[elem_size*OTL_SCAST(unsigned,array_size)]; memset(p_v,0,elem_size*OTL_SCAST(unsigned,array_size)); } #else p_v=new ub1[elem_size*OTL_SCAST(unsigned,array_size)]; memset(p_v,0,elem_size*OTL_SCAST(unsigned,array_size)); #endif p_ind=new sb2[array_size]; p_rlen=new ub2[array_size]; p_rcode=new ub2[array_size]; if(ftype==otl_var_varchar_long||ftype==otl_var_raw_long){ if(aelem_size>32767) p_ind[0]=0; else p_ind[0]=OTL_SCAST(short,aelem_size); p_rcode[0]=0; }else{ for(i=0;iget_svchp(), connect->get_errhp(), lob[ndx], &blen); alen=OTL_SCAST(int,blen); if(rc!=OCI_SUCCESS)return 0; return 1; } int is_blob_initialized(const int ndx,int& is_init) { int rc; is_init=0; rc=OCILobLocatorIsInit (connect->get_envhp(), connect->get_errhp(), lob[ndx], &is_init); if(rc!=OCI_SUCCESS) return 0; else return 1; } int get_blob (const int ndx, unsigned char* abuf, const int buf_size, int& len) { int byte_buf_size=buf_size; #if defined(OTL_UNICODE) if(ftype==otl_var_clob) byte_buf_size=buf_size*sizeof(OTL_CHAR); #endif ub4 amt=byte_buf_size; ub4 offset=1; int rc; #if defined(OTL_UNICODE) if(ftype==otl_var_clob||ftype==otl_var_nclob) memset(OTL_RCAST(void*,abuf),0,OTL_SCAST(size_t,buf_size)); #endif int is_init=0; rc=OCILobLocatorIsInit (connect->get_envhp(), connect->get_errhp(), lob[ndx], &is_init); if (rc!=0) return 0; if (!is_init){ len=0; return 1; } #if defined(OTL_UNICODE) if(ftype==otl_var_clob) csid=OTL_UNICODE_ID; else csid=0; #else csid=0; #endif do{ rc=OCILobRead (connect->get_svchp(), connect->get_errhp(), lob[ndx], &amt, offset, OTL_RCAST(dvoid*,abuf+offset-1), OTL_SCAST(ub4,byte_buf_size-offset+1), 0, 0, csid, OTL_SCAST(ub1,nls_flag?SQLCS_NCHAR:connect->get_char_set())); offset+=amt; }while(rc==OCI_NEED_DATA); len=offset-1; if(rc!=OCI_SUCCESS){ len=0; return 0; } return 1; } void set_lob_stream_flag(const int flg=1) { lob_stream_flag=flg; } int close_lob(void) { #if defined(OTL_ORA8I)||defined(OTL_ORA9I) int rc; boolean flag=0; rc=OCILobIsOpen (connect->get_svchp(), connect->get_errhp(), lob[0], &flag); if(rc!=OCI_SUCCESS)return 0; if(flag!=TRUE)return 1; rc=OCILobClose (connect->get_svchp(), connect->get_errhp(), lob[0]); if(rc!=OCI_SUCCESS)return 0; #endif return 1; } int put_blob(void) { if((ftype!=otl_var_clob&&ftype!=otl_var_blob)|| lob_stream_flag||buf==0||buf_len==0)return 1; int rc; int byte_buf_len=buf_len; #if defined(OTL_UNICODE) if(ftype==otl_var_clob) byte_buf_len=buf_len*sizeof(OTL_CHAR); #endif ub4 amt=OTL_SCAST(ub4,buf_len); ub4 offset=1; #if defined(OTL_UNICODE) if(ftype==otl_var_clob) csid=OTL_UNICODE_ID; else csid=0; #else csid=0; #endif rc=OCILobWrite (connect->get_svchp(), connect->get_errhp(), lob[0], &amt, offset, OTL_RCAST(dvoid*,buf), OTL_SCAST(ub4,byte_buf_len), OCI_ONE_PIECE, 0, 0, csid, OTL_SCAST(ub1,nls_flag?SQLCS_NCHAR:connect->get_char_set())); if(rc!=0)return 0; return 1; } int read_blob (otl_long_string& s, const int andx, int& aoffset, int alob_len) { ub4 byte_buf_size=s.get_buf_size(); #if defined(OTL_UNICODE) if(ftype==otl_var_clob) byte_buf_size=byte_buf_size*sizeof(OTL_CHAR); #endif ub4& amt=read_blob_amt; amt=0; if(aoffset==1)total_read_blob_amt=0; ub4& offset=total_read_blob_amt; if(offset==0)offset=1; int rc; int is_init=0; rc=OCILobLocatorIsInit (connect->get_envhp(), connect->get_errhp(), lob[0], &is_init); if(rc!=OCI_SUCCESS)return 0; if(!is_init){ s.set_len(0); return 1; } #if defined(OTL_UNICODE) if(ftype==otl_var_clob) csid=OTL_UNICODE_ID; else csid=0; #else csid=0; #endif rc=OCILobRead (connect->get_svchp(), connect->get_errhp(), lob[andx], &amt, offset, OTL_RCAST(dvoid*,s.v), OTL_SCAST(ub4,byte_buf_size), 0, 0, csid, OTL_SCAST(ub1,nls_flag?SQLCS_NCHAR:connect->get_char_set())); #if defined(OTL_UNICODE) if(ftype==otl_var_clob && aoffset>1 && amt==byte_buf_size) amt/=sizeof(OTL_CHAR); #endif #if defined(OTL_ORA_UTF8) switch(rc){ case OCI_SUCCESS: s.set_len(amt); offset+=amt; if(ftype==otl_var_blob) aoffset+=s.len(); else aoffset=alob_len+1; return 1; case OCI_NEED_DATA: s.set_len(amt); offset+=amt; if(ftype==otl_var_blob) aoffset+=s.len(); else aoffset=2; return 1; case OCI_ERROR: default: s.set_len(0); return 0; } #else switch(rc){ case OCI_SUCCESS: if(aoffset==1) s.set_len(alob_len); else s.set_len(alob_len-aoffset+1); break; case OCI_NEED_DATA: s.set_len(amt); break; case OCI_ERROR: s.set_len(0); break; } if(rc==OCI_NEED_DATA||rc==OCI_SUCCESS){ aoffset+=s.len(); return 1; }else return 0; #endif } int write_blob (const otl_long_string& s, const int alob_len, int& aoffset, otl_cur0& /* cur */) { if(!lob_stream_flag)return 1; int rc; int byte_s_length=s.len(); #if defined(OTL_UNICODE) int byte_lob_len; if(ftype==otl_var_clob){ byte_lob_len=alob_len*sizeof(OTL_CHAR); byte_s_length=s.len()*sizeof(OTL_CHAR); } #endif ub4 offset=aoffset; ub4 amt=0; ub1 mode; if(aoffset==1 && alob_len>s.len()) mode=OCI_FIRST_PIECE; else if(aoffset==1 && alob_len<=s.len()){ mode=OCI_ONE_PIECE; amt=s.len(); }else if((aoffset-1)+s.len()get_svchp(), connect->get_errhp(), lob[0], 0); if(rc!=OCI_SUCCESS) return 0; } if(alob_len==0)return 1; rc=OCILobWrite (connect->get_svchp(), connect->get_errhp(), lob[0], OTL_RCAST(ub4*,&amt), offset, OTL_RCAST(dvoid*,s.v), OTL_SCAST(ub4,byte_s_length), mode, 0, 0, csid, OTL_SCAST(ub1,nls_flag?SQLCS_NCHAR:connect->get_char_set())); if(rc==OCI_NEED_DATA|| rc==OCI_SUCCESS|| rc==OCI_SUCCESS_WITH_INFO){ aoffset+=s.len(); return 1; } return 0; } int save_blob (const unsigned char* abuf, const int len, const int extern_buffer_flag) { if(extern_buffer_flag){ ext_buf_flag=1; buf_len=len; buf=OTL_CCAST(unsigned char*,abuf); }else{ if(buf!=0&&!ext_buf_flag){ delete[] buf; buf=0; } ext_buf_flag=0; buf_len=len; #if defined(OTL_UNICODE) buf=new ub1[buf_len*sizeof(OTL_CHAR)]; memcpy(buf,abuf,buf_len*sizeof(OTL_CHAR)); #else buf=new ub1[buf_len]; memcpy(buf,abuf,buf_len); #endif } return 1; } void set_null(int ndx) { p_ind[ndx]=-1; } void set_not_null(int ndx, int pelem_size) { switch(ftype){ case otl_var_varchar_long: case otl_var_raw_long: p_ind[0]=0; break; case otl_var_raw: p_ind[ndx]=OTL_SCAST(short,pelem_size); break; case otl_var_clob: case otl_var_blob: if(lob_stream_flag==0){ ub4 lobEmpty=0; OCIAttrSet (OTL_RCAST(dvoid*,lob[ndx]), OCI_DTYPE_LOB, OTL_RCAST(dvoid*,&lobEmpty), 0, OCI_ATTR_LOBEMPTY, OTL_RCAST(OCIError*,connect->get_errhp())); } break; default: p_ind[ndx]=OTL_SCAST(short,pelem_size); break; } } void set_len(int len, int ndx) { if(ftype==otl_var_varchar_long||ftype==otl_var_raw_long){ #if defined(OTL_UNICODE) if(ftype==otl_var_varchar_long) *OTL_RCAST(sb4*,p_v)=len*sizeof(OTL_CHAR); else *OTL_RCAST(sb4*,p_v)=len; #else *OTL_RCAST(sb4*,p_v)=len; #endif }else p_rlen[ndx]=OTL_SCAST(short,len); } int get_len(int ndx) { if(ftype==otl_var_varchar_long||ftype==otl_var_raw_long){ if(p_ind[0]==-1) return 0; else{ #if defined(OTL_UNICODE) if(ftype==otl_var_varchar_long) return (*OTL_RCAST(sb4*,p_v))/sizeof(OTL_CHAR); else return *OTL_RCAST(sb4*,p_v); #else return *OTL_RCAST(sb4*,p_v); #endif } }else return p_rlen[ndx]; } int is_null(int ndx) { return p_ind[ndx]==-1; } void* val(int ndx,int pelem_size) { switch(ftype){ #if defined(OTL_UNICODE) case otl_var_char: return OTL_RCAST(void*,&p_v[OTL_SCAST(unsigned,ndx)* pelem_size*sizeof(OTL_WCHAR)]); #endif #if defined(OTL_ORA_UTF8) case otl_var_char: if(select_stm_flag) return OTL_RCAST(void*,&p_v[OTL_SCAST(unsigned,ndx)* pelem_size*OTL_UTF8_BYTES_PER_CHAR]); else return OTL_RCAST(void*,&p_v[OTL_SCAST(unsigned,ndx)*pelem_size]); #endif case otl_var_raw: return OTL_RCAST(void*,&p_v[(OTL_SCAST(unsigned,ndx))* (pelem_size+sizeof(short int))]); case otl_var_varchar_long: case otl_var_raw_long: return OTL_RCAST(void*,p_v+sizeof(sb4)); #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) case otl_var_timestamp: case otl_var_tz_timestamp: case otl_var_ltz_timestamp: if(!pl_tab_flag) return OTL_RCAST(void*,timestamp[ndx]); #endif default: return OTL_RCAST(void*,&p_v[OTL_SCAST(unsigned,ndx)*pelem_size]); } } static int int2ext(int int_type) { switch(int_type){ case inVarChar2: return extCChar; case inNumber: return extFloat; case inLong: return extLongVarChar; case inRowId: return extCChar; #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) case inDate: return extTimestamp; case inTimestamp:return extTimestamp; case inTimestamp_TZ:return extTimestamp_TZ; case inTimestamp_LTZ:return extTimestamp_LTZ; case inIntervalYM:return extCChar; case inIntervalDS:return extCChar; #else case inDate: return extDate; #endif case inRaw: return extRaw; case inLongRaw: return extLongVarRaw; case inChar: return extCChar; #if defined(OTL_ORA10G)||defined(OTL_ORA10G_R2) #if defined(OTL_ORA_NATIVE_TYPES) && !defined(OTL_ORA_LEGACY_NUMERIC_TYPES) case inBFloat: return extBFloat; case inBDouble: return extBDouble; #else case inBFloat: return extFloat; case inBDouble: return extFloat; #endif #endif case inCLOB: return extCLOB; case inBLOB: return extBLOB; default: return otl_unsupported_type; } } static int datatype_size(int aftype,int maxsz,int int_type,int max_long_size) { switch(aftype){ case extCChar: switch(int_type){ #if defined(OTL_ORA_TIMESTAMP) case inIntervalYM: return 30; case inIntervalDS: return 30; #endif case inRowId: return 30; case inDate: return otl_oracle_date_size; case inRaw: return max_long_size; default: return maxsz+1; } #if (defined(OTL_ORA10G)||defined(OTL_ORA10G_R2)) && defined(OTL_ORA_NATIVE_TYPES) \ && !defined(OTL_ORA_LEGACY_NUMERIC_TYPES) case extBFloat: case extBDouble: return sizeof(double); #endif case extLongVarChar: return max_long_size; case extLongVarRaw: return max_long_size; case extRaw: return maxsz; case extCLOB: return max_long_size; case extBLOB: return max_long_size; case extFloat: return sizeof(double); #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) case extDate: return sizeof(OCIDateTime*); case extTimestamp: case extTimestamp_TZ: case extTimestamp_LTZ: return sizeof(OCIDateTime*); #else case extDate: return otl_oracle_date_size; #endif default: return 0; } } static void map_ftype (otl_column_desc& desc, const int max_long_size, int& aftype, int& aelem_size, otl_select_struct_override& override, const int column_ndx, const int /*connection_type*/) {int ndx=override.find(column_ndx); if(ndx==-1){ aftype=int2ext(desc.dbtype); aelem_size=datatype_size (aftype, OTL_SCAST(int,desc.dbsize), desc.dbtype, max_long_size); switch(aftype){ #if (defined(OTL_ORA10G)||defined(OTL_ORA10G_R2))&&defined(OTL_ORA_NATIVE_TYPES)\ &&!defined(OTL_ORA_LEGACY_NUMERIC_TYPES) case extBFloat: case extBDouble: if(override.get_all_mask() & otl_all_num2str){ aftype=otl_var_char; aelem_size=otl_num_str_size; }else aftype=otl_var_double; break; #endif case extCChar: aftype=otl_var_char; break; case extRaw: aftype=otl_var_raw; break; case extFloat: if(override.get_all_mask() & otl_all_num2str){ aftype=otl_var_char; aelem_size=otl_num_str_size; }else aftype=otl_var_double; break; case extLongVarChar: aftype=otl_var_varchar_long; break; case extLongVarRaw: aftype=otl_var_raw_long; break; case extCLOB: aftype=otl_var_clob; break; case extBLOB: aftype=otl_var_blob; break; #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) case extDate: case extTimestamp: if(override.get_all_mask() & otl_all_date2str){ aftype=otl_var_char; aelem_size=otl_date_str_size; }else aftype=otl_var_timestamp; break; case extTimestamp_TZ: if(override.get_all_mask() & otl_all_date2str){ aftype=otl_var_char; aelem_size=otl_date_str_size; }else aftype=otl_var_tz_timestamp; break; case extTimestamp_LTZ: if(override.get_all_mask() & otl_all_date2str){ aftype=otl_var_char; aelem_size=otl_date_str_size; }else aftype=otl_var_ltz_timestamp; break; #else case extDate: if(override.get_all_mask() & otl_all_date2str){ aftype=otl_var_char; aelem_size=otl_date_str_size; }else aftype=otl_var_timestamp; break; #endif } }else{ aftype=override.get_col_type(ndx); switch(aftype){ #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) case otl_var_nchar: #endif case otl_var_char: aelem_size=override.get_col_size(ndx); break; case otl_var_raw: aelem_size=override.get_col_size(ndx); break; case otl_var_double: aelem_size=sizeof(double); break; case otl_var_float: aelem_size=sizeof(float); break; case otl_var_int: aelem_size=sizeof(int); break; #if defined(OTL_BIGINT) && defined(OTL_ORA11G_R2) case otl_var_bigint: aelem_size=sizeof(OTL_BIGINT); break; #endif case otl_var_unsigned_int: aelem_size=sizeof(unsigned); break; case otl_var_short: aelem_size=sizeof(short); break; case otl_var_long_int: aelem_size=sizeof(long); break; default: aelem_size=override.get_col_size(ndx); break; } } desc.otl_var_dbtype=aftype; } private: otl_var(const otl_var&): p_v(0), p_ind(0), p_rlen(0), p_rcode(0), ftype(0), array_size(0), elem_size(0), nls_flag(false), lob(0), #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) timestamp(0), #endif cda(0), connect(0), buf(0), buf_len(0), ext_buf_flag(0), act_elem_size(0), max_tab_len(0), cur_tab_len(0), pl_tab_flag(0), lob_stream_flag(0), vparam_type(-1), lob_len(0), lob_pos(0), lob_ftype(0), otl_adapter(otl_ora8_adapter), lob_stream_mode(false), unicode_var_len(0), csid(0), csfrm(SQLCS_IMPLICIT), read_blob_amt(0), total_read_blob_amt(0), charz_flag(false), select_stm_flag(false) { } otl_var& operator=(const otl_var&) { return *this; } }; class otl_sel; class otl_refcur_base_cursor; class otl_refcur_stream; class otl_ref_cursor; class otl_ref_select_stream; #if defined(OTL_ORA_SUBSCRIBE) class otl_subscriber; #endif class otl_cur: public otl_cur0{ private: #if defined(OTL_ORA_SUBSCRIBE) friend class otl_subscriber; #endif friend class otl_sel; friend class otl_refcur_base_cursor; friend class otl_refcur_stream; friend class otl_ref_cursor; friend class otl_ref_select_stream; OCIStmt* cda; // Statement handle OCIError* errhp; // Error handle bool extern_cda; int status; int eof_status; otl_conn* db; int straight_select; int pos_nbr; int commit_on_success; int last_param_data_token; int last_sql_param_data_status; int sql_param_data_count; bool canceled; int direct_exec_flag; int parse_only_flag; int stm_executed; public: void set_canceled(const bool acanceld) { canceled=acanceld; } void reset_last_param_data_token() { last_param_data_token=0; } void reset_last_sql_param_data_status() { last_sql_param_data_status=0; } void reset_sql_param_data_count() { sql_param_data_count=0; } otl_cur(): cda(0), errhp(0), extern_cda(false), status(0), eof_status(0), db(0), straight_select(1), pos_nbr(0), commit_on_success(0), last_param_data_token(0), last_sql_param_data_status(0), sql_param_data_count(0), canceled(false), direct_exec_flag(0), parse_only_flag(0), stm_executed(0) { } virtual ~otl_cur(){} void set_direct_exec(const int flag) { direct_exec_flag=flag; } void set_parse_only(const int flag) { parse_only_flag=flag; } ub4 rpc(void) { sb4 arpc; status=OCIAttrGet (OTL_RCAST(dvoid *,cda), OTL_SCAST(ub4,OCI_HTYPE_STMT), OTL_RCAST(dvoid *,&arpc), 0, OTL_SCAST(ub4,OCI_ATTR_ROW_COUNT), errhp); if(status)return 0; return arpc; } int open(otl_conn& connect,otl_var* var=0) { db=&connect; commit_on_success=db->get_auto_commit(); if(var!=0){ extern_cda=true; cda=var->get_cda(); status=OCI_SUCCESS; }else{ #if defined(__GNUC__) && (__GNUC__>=4) void* temp_cda=&cda; #endif status=OCIHandleAlloc (OTL_RCAST(dvoid *,db->get_envhp()), #if defined(__GNUC__) && (__GNUC__>=4) OTL_RCAST(dvoid **,temp_cda), #else OTL_RCAST(dvoid **,&cda), #endif OCI_HTYPE_STMT, 0, 0); if(status)return 0; } #if defined(__GNUC__) && (__GNUC__>=4) void* temp_errhp=&errhp; #endif status=OCIHandleAlloc (OTL_RCAST(dvoid *,db->get_envhp()), #if defined(__GNUC__) && (__GNUC__>=4) OTL_RCAST(dvoid **,temp_errhp), #else OTL_RCAST(dvoid **,&errhp), #endif OCI_HTYPE_ERROR, 0, 0); if(status)return 0; straight_select=1; pos_nbr=0; return 1; } int close(void) { if(!extern_cda) status=OCIHandleFree(OTL_RCAST(dvoid*,cda),OCI_HTYPE_STMT); status=OCIHandleFree(OTL_RCAST(dvoid*,errhp),OCI_HTYPE_ERROR); cda=0; errhp=0; commit_on_success=0; return 1; } int parse(const char* stm_text) { status=OCIStmtPrepare (cda, errhp, OTL_RCAST(text*,OTL_CCAST(char*,stm_text)), OTL_SCAST(ub4,strlen(stm_text)), OTL_SCAST(ub4,OCI_NTV_SYNTAX), OTL_SCAST(ub4,OCI_DEFAULT)); if(status)return 0; if(direct_exec_flag && parse_only_flag){ #if !defined(OCI_PARSE_ONLY) status=OCIStmtExecute (db->svchp, cda, errhp, OTL_SCAST(ub4,1), OTL_SCAST(ub4,0), 0, 0, 0x100); #else status=OCIStmtExecute (db->get_svchp(), cda, errhp, OTL_SCAST(ub4,0), OTL_SCAST(ub4,0), 0, 0, OCI_PARSE_ONLY); #endif if(status) return 0; else return 1; }else if(direct_exec_flag && !parse_only_flag){ ub4 mode; if(commit_on_success) mode=OCI_COMMIT_ON_SUCCESS; else mode=OCI_DEFAULT; status=OCIStmtExecute (db->get_svchp(), cda, errhp, OTL_SCAST(ub4,1), OTL_SCAST(ub4,0), 0, 0, mode); stm_executed=1; if(status) return 0; else return 1; } return 1; } int exec(const int iters, const int rowoff, const int /*otl_sql_exec_from_class*/) { if(parse_only_flag){ parse_only_flag=0; return 1; }else if(!stm_executed){ ub4 mode; if(commit_on_success) mode=OCI_COMMIT_ON_SUCCESS; else mode=OCI_DEFAULT; status=OCIStmtExecute (db->get_svchp(), cda, errhp, OTL_SCAST(ub4,iters), OTL_SCAST(ub4,rowoff), 0, 0, mode); stm_executed=0; if(status!=OCI_SUCCESS) return 0; return 1; } return 1; } long get_rpc() { return rpc(); } int fetch(const otl_stream_buffer_size_type iters,int& eof_data) { eof_data=0; status=OCIStmtFetch (cda, errhp, OTL_SCAST(ub4,iters), OTL_SCAST(ub4,OCI_FETCH_NEXT), OTL_SCAST(ub4,OCI_DEFAULT)); eof_status=status; if(status!=OCI_SUCCESS&& status!=OCI_SUCCESS_WITH_INFO&& status!=OCI_NO_DATA) return 0; if(status==OCI_NO_DATA){ eof_data=1; return 1; } return 1; } int tmpl_ftype2ora_ftype(const int ftype) { switch(ftype){ case otl_var_char: return extCChar; #if (defined(OTL_ORA10G)||defined(OTL_ORA10G_R2))&&defined(OTL_ORA_NATIVE_TYPES)\ &&!defined(OTL_ORA_LEGACY_NUMERIC_TYPES) case otl_var_double: return extBDouble; case otl_var_float: return extBFloat; #else case otl_var_double: return extFloat; case otl_var_float: return extFloat; #endif case otl_var_int: return extInt; case otl_var_unsigned_int: return extUInt; case otl_var_short: return extInt; case otl_var_long_int: return extInt; #if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\ !defined(OTL_BIGINT_TO_STR)) case otl_var_bigint: return extInt; #endif #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) case otl_var_timestamp: return extTimestamp; case otl_var_tz_timestamp: return extTimestamp_TZ; case otl_var_ltz_timestamp: return extTimestamp_LTZ; #else case otl_var_timestamp: return extDate; #endif case otl_var_varchar_long: return extLongVarChar; case otl_var_raw_long: return extLongVarRaw; case otl_var_raw: return extRaw; case otl_var_clob: return SQLT_CLOB; case otl_var_blob: return SQLT_BLOB; default: return 0; } } int bind (const char* name, otl_var& v, const int elem_size, const int ftype, const int /*param_type*/, const int /*name_pos*/, const int /*connection_type*/, const int apl_tab_flag) {OCIBind* bindpp; int db_ftype=0; if(ftype==otl_var_refcur){ status=OCIBindByName (cda, &bindpp, errhp, OTL_RCAST(text*,OTL_CCAST(char*,name)), OTL_SCAST(sb4,strlen(name)), OTL_RCAST(dvoid*,v.get_cda_ptr()), 0, SQLT_RSET, 0, 0, 0, 0, 0, OTL_SCAST(ub4,OCI_DEFAULT)); }else if(ftype!=otl_var_clob&&ftype!=otl_var_blob){ int var_elem_size; #if defined(OTL_UNICODE) if(ftype==otl_var_char){ var_elem_size=elem_size*sizeof(OTL_WCHAR); // ### } else if(ftype==otl_var_varchar_long) var_elem_size=elem_size; else var_elem_size=elem_size; #else if(ftype==otl_var_varchar_long) var_elem_size=elem_size+sizeof(sb4); else var_elem_size=elem_size; #endif db_ftype=tmpl_ftype2ora_ftype(ftype); #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) if(ftype==otl_var_timestamp || ftype==otl_var_tz_timestamp || ftype==otl_var_ltz_timestamp){ if(!apl_tab_flag) var_elem_size=sizeof(OCIDateTime*); else if(db_ftype==extTimestamp) db_ftype=extDate; } #endif #if defined(OTL_UNICODE) if(ftype==otl_var_char) db_ftype=SQLT_VCS; #endif if(apl_tab_flag){ if(ftype==otl_var_float||ftype==otl_var_double) db_ftype=extFloat; status=OCIBindByName (cda, &bindpp, errhp, OTL_RCAST(text*,OTL_CCAST(char*,name)), OTL_SCAST(sb4,strlen(name)), OTL_RCAST(dvoid*,v.p_v), ftype==otl_var_raw?var_elem_size+sizeof(short):var_elem_size, OTL_SCAST(ub2,v.charz_flag?extCharZ:db_ftype), OTL_RCAST(dvoid*,v.p_ind), 0, 0, OTL_SCAST(ub4,v.max_tab_len), OTL_RCAST(ub4*,&v.cur_tab_len), OTL_SCAST(ub4,OCI_DEFAULT)); }else{ status=OCIBindByName (cda, &bindpp, errhp, OTL_RCAST(text*,OTL_CCAST(char*,name)), OTL_SCAST(sb4,strlen(name)), OTL_RCAST(dvoid*,v.p_v), ftype==otl_var_raw?var_elem_size+sizeof(short):var_elem_size, OTL_SCAST(ub2,db_ftype), OTL_RCAST(dvoid*,v.p_ind), 0, 0, 0, 0, OTL_SCAST(ub4,OCI_DEFAULT)); } if(status)return 0; #if defined(OTL_UNICODE) if(ftype==otl_var_char||ftype==otl_var_varchar_long){ if(ftype!=otl_var_varchar_long){ if(v.nls_flag) v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR); else v.csfrm=OTL_SCAST(ub1,db->char_set_); status=OCIAttrSet (bindpp, OCI_HTYPE_BIND, &v.csfrm, 0, OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM), errhp); if(status)return 0; } v.csid=OTL_UNICODE_ID; status=OCIAttrSet (bindpp, OCI_HTYPE_BIND, &v.csid, 0, OCI_ATTR_CHARSET_ID, errhp); if(status)return 0; if(ftype==otl_var_varchar_long) v.unicode_var_len=elem_size-sizeof(sb4); else{ #if defined(OTL_ORA_MAX_UNICODE_VARCHAR_SIZE) if(var_elem_size>OTL_ORA_MAX_UNICODE_VARCHAR_SIZE) v.unicode_var_len=OTL_ORA_MAX_UNICODE_VARCHAR_SIZE; else v.unicode_var_len=var_elem_size; #else v.unicode_var_len=var_elem_size; #endif } status=OCIAttrSet (bindpp, OCI_HTYPE_BIND, &v.unicode_var_len, 0, OCI_ATTR_MAXDATA_SIZE, errhp); if(status)return 0; } #endif #if defined(OTL_ORA_UTF8) if(ftype==otl_var_char){ if(v.nls_flag) v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR); else v.csfrm=OTL_SCAST(ub1,db->char_set_); status=OCIAttrSet (bindpp, OCI_HTYPE_BIND, &v.csfrm, 0, OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM), errhp); if(status)return 0; } #endif return 1; }else{ status=OCIBindByName (cda, &bindpp, errhp, OTL_RCAST(text*,OTL_CCAST(char*,name)), OTL_SCAST(sb4,strlen(name)), OTL_RCAST(dvoid*,v.p_v), OTL_SCAST(sb4,-1), OTL_SCAST(ub2,tmpl_ftype2ora_ftype(ftype)), OTL_RCAST(dvoid*,v.p_ind), 0, 0, 0, 0, OTL_SCAST(ub4,OCI_DEFAULT)); if(status)return 0; #if defined(OTL_UNICODE) if(ftype==otl_var_clob){ v.csid=OTL_UNICODE_ID; status=OCIAttrSet (bindpp, OCI_HTYPE_BIND, &v.csid, 0, OCI_ATTR_CHARSET_ID, errhp); if(status)return 0; if(v.nls_flag) v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR); else v.csfrm=OTL_SCAST(ub1,db->char_set_); status=OCIAttrSet (bindpp, OCI_HTYPE_BIND, &v.csfrm, 0, OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM), errhp); if(status)return 0; } #endif #if defined(OTL_ORA_UTF8) if(ftype==otl_var_clob){ if(v.nls_flag) v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR); else v.csfrm=OTL_SCAST(ub1,db->char_set_); status=OCIAttrSet (bindpp, OCI_HTYPE_BIND, &v.csfrm, 0, OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM), errhp); if(status)return 0; } #endif return 1; } if(status)return 0; return 1; } int bind (const int column_num, otl_var& v, const int elem_size, const int ftype, const int /*param_type*/) {OCIDefine *defnp; int db_ftype=0; if(ftype!=otl_var_clob&&ftype!=otl_var_blob){ int var_elem_size; #if defined(OTL_UNICODE) if(ftype==otl_var_char) var_elem_size=elem_size*sizeof(OTL_WCHAR); else if(ftype==otl_var_varchar_long) var_elem_size=elem_size+sizeof(sb4); else var_elem_size=elem_size; #elif defined(OTL_ORA_UTF8) if(ftype==otl_var_char && v.select_stm_flag) var_elem_size=elem_size*OTL_UTF8_BYTES_PER_CHAR; // 3 bytes per UTF8 char else if(ftype==otl_var_varchar_long) var_elem_size=elem_size+sizeof(sb4); else var_elem_size=elem_size; #else if(ftype==otl_var_varchar_long) var_elem_size=elem_size+sizeof(sb4); else var_elem_size=elem_size; #endif db_ftype=tmpl_ftype2ora_ftype(ftype); #if defined(OTL_UNICODE) if(ftype==otl_var_char) db_ftype=SQLT_VCS; #endif status=OCIDefineByPos (cda, &defnp, errhp, OTL_SCAST(ub4,column_num), OTL_RCAST(dvoid*,v.p_v), OTL_SCAST(sb4,ftype==otl_var_raw?var_elem_size+sizeof(short):var_elem_size), OTL_SCAST(ub2,db_ftype), OTL_RCAST(dvoid*,v.p_ind), OTL_RCAST(ub2*,v.p_rlen), OTL_RCAST(ub2*,v.p_rcode), OCI_DEFAULT); if(status)return 0; #if defined(OTL_ORA_UTF8) if(ftype==otl_var_char||ftype==otl_var_varchar_long){ if(v.nls_flag) v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR); else v.csfrm=OTL_SCAST(ub1,db->char_set_); status=OCIAttrSet (defnp, OCI_HTYPE_DEFINE, OTL_RCAST(void*,&v.csfrm), OTL_SCAST(ub4,0), OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM), errhp); if(status)return 0; } #endif #if defined(OTL_UNICODE) if(ftype==otl_var_char||ftype==otl_var_varchar_long){ if(v.nls_flag) v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR); else v.csfrm=OTL_SCAST(ub1,db->char_set_); status=OCIAttrSet (defnp, OCI_HTYPE_DEFINE, OTL_RCAST(void*,&v.csfrm), OTL_SCAST(ub4,0), OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM), errhp); if(status)return 0; v.csid=OTL_UNICODE_ID; status=OCIAttrSet (defnp, OCI_HTYPE_DEFINE, &v.csid, 0, OCI_ATTR_CHARSET_ID, errhp); if(status)return 0; } #endif return 1; }else{ status=OCIDefineByPos (cda, &defnp, errhp, OTL_SCAST(ub4,column_num), OTL_RCAST(dvoid*,v.p_v), OTL_SCAST(sb4,-1), OTL_SCAST(ub2,tmpl_ftype2ora_ftype(ftype)), OTL_RCAST(dvoid*,v.p_ind), OTL_RCAST(ub2*,v.p_rlen), OTL_RCAST(ub2*,v.p_rcode), OCI_DEFAULT); if(status)return 0; #if defined(OTL_UNICODE) if(ftype==otl_var_char||ftype==otl_var_varchar_long){ v.csid=OTL_UNICODE_ID; status=OCIAttrSet (defnp, OCI_HTYPE_DEFINE, &v.csid, 0, OCI_ATTR_CHARSET_ID, errhp); if(status)return 0; } #endif #if defined(OTL_ORA_UTF8) if(ftype==otl_var_clob){ if(v.nls_flag) v.csfrm=OTL_SCAST(ub1,SQLCS_NCHAR); else v.csfrm=OTL_SCAST(ub1,db->char_set_); status=OCIAttrSet (defnp, OCI_HTYPE_DEFINE, OTL_RCAST(void*,&v.csfrm), OTL_SCAST(ub4,0), OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM), errhp); if(status)return 0; } #endif return 1; } } void set_select_type(const int select_type) { straight_select=select_type; } int describe_column (otl_column_desc& col, const int column_num, int& eof_desc) { OCIParam* pard; ub2 dtype; ub2 dbsize; sb2 prec; #if defined(OTL_ORA8_8I_DESC_COLUMN_SCALE) ub1 scale; #else sb2 scale; #endif ub1 nullok; text* col_name; ub4 col_name_len; ub4 pos_num; eof_desc=0; if(straight_select&&pos_nbr==0){ status=OCIStmtExecute (db->get_svchp(), cda, errhp, 0, 0, 0, 0, OCI_DESCRIBE_ONLY); if(status!=OCI_SUCCESS)return 0; status=OCIAttrGet (cda, OCI_HTYPE_STMT, OTL_RCAST(ub4*,&pos_num), 0, OTL_SCAST(ub4,OCI_ATTR_PARAM_COUNT), errhp); if(status!=OCI_SUCCESS)return 0; pos_nbr=OTL_SCAST(int,pos_num); } if(!straight_select&&pos_nbr==0){ status=OCIAttrGet (cda, OCI_HTYPE_STMT, OTL_RCAST(ub4*,&pos_num), 0, OTL_SCAST(ub4,OCI_ATTR_PARAM_COUNT), errhp); if(status!=OCI_SUCCESS)return 0; pos_nbr=OTL_SCAST(int,pos_num); } if(column_num<1||column_num>pos_nbr){ eof_desc=1; return 0; } #if defined(__GNUC__) && (__GNUC__>=4) void* temp_pard=&pard; #endif status=OCIParamGet (cda, OCI_HTYPE_STMT, errhp, #if defined(__GNUC__) && (__GNUC__>=4) OTL_RCAST(void**,temp_pard), #else OTL_RCAST(void**,&pard), #endif OTL_SCAST(ub4,column_num)); if(status!=OCI_SUCCESS&&status!=OCI_NO_DATA) return 0; if(status==OCI_NO_DATA){ eof_desc=1; return 1; } status=OCIAttrGet (OTL_RCAST(dvoid*,pard), OTL_SCAST(ub4,OCI_DTYPE_PARAM), OTL_RCAST(dvoid*,&dtype), 0, OTL_SCAST(ub4,OCI_ATTR_DATA_TYPE), OTL_RCAST(OCIError*,errhp)); if(status!=OCI_SUCCESS)return 0; #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) #if !defined(OTL_ORA8I) ub1 charset_form; status=OCIAttrGet (OTL_RCAST(dvoid*,pard), OTL_SCAST(ub4,OCI_DTYPE_PARAM), OTL_RCAST(dvoid*,&charset_form), 0, OTL_SCAST(ub4,OCI_ATTR_CHARSET_FORM), OTL_RCAST(OCIError*,errhp)); if(status!=OCI_SUCCESS)return 0; col.charset_form=OTL_SCAST(int,charset_form); ub2 char_size; status=OCIAttrGet (OTL_RCAST(dvoid*,pard), OTL_SCAST(ub4,OCI_DTYPE_PARAM), OTL_RCAST(dvoid*,&char_size), 0, OTL_SCAST(ub4,OCI_ATTR_CHAR_SIZE), OTL_RCAST(OCIError*,errhp)); if(status!=OCI_SUCCESS)return 0; col.char_size=OTL_SCAST(int,char_size); #else col.char_size=0; #endif #endif col.dbtype=dtype; #if defined(__GNUC__) && (__GNUC__>=4) void* temp_col_name=&col_name; #endif status=OCIAttrGet (OTL_RCAST(dvoid*,pard), OTL_SCAST(ub4,OCI_DTYPE_PARAM), #if defined(__GNUC__) && (__GNUC__>=4) OTL_RCAST(dvoid**,temp_col_name), #else OTL_RCAST(dvoid**,&col_name), #endif OTL_RCAST(ub4*,&col_name_len), OTL_SCAST(ub4,OCI_ATTR_NAME), OTL_RCAST(OCIError*,errhp)); if(status!=OCI_SUCCESS)return 0; col.set_name(OTL_RCAST(char*,col_name),col_name_len); status=OCIAttrGet (OTL_RCAST(dvoid*,pard), OTL_SCAST(ub4,OCI_DTYPE_PARAM), OTL_RCAST(dvoid*,&dbsize), OTL_RCAST(ub4*,0), OTL_SCAST(ub4,OCI_ATTR_DATA_SIZE), OTL_RCAST(OCIError*,errhp)); if(status!=OCI_SUCCESS)return 0; col.dbsize=dbsize; status=OCIAttrGet (OTL_RCAST(dvoid*,pard), OTL_SCAST(ub4,OCI_DTYPE_PARAM), OTL_RCAST(dvoid*,&prec), 0, OTL_SCAST(ub4,OCI_ATTR_PRECISION), OTL_RCAST(OCIError*,errhp)); if(status!=OCI_SUCCESS)return 0; col.prec=prec; status=OCIAttrGet (OTL_RCAST(dvoid*,pard), OTL_SCAST(ub4,OCI_DTYPE_PARAM), OTL_RCAST(dvoid*,&scale), 0, OTL_SCAST(ub4,OCI_ATTR_SCALE), OTL_RCAST(OCIError*,errhp)); if(status!=OCI_SUCCESS)return 0; col.scale=scale; status=OCIAttrGet (OTL_RCAST(dvoid*,pard), OTL_SCAST(ub4,OCI_DTYPE_PARAM), OTL_RCAST(dvoid*,&nullok), 0, OTL_SCAST(ub4,OCI_ATTR_IS_NULL), OTL_RCAST(OCIError*,errhp)); if(status!=OCI_SUCCESS)return 0; col.nullok=nullok; return 1; } void error(otl_exc& exception_struct) {sb4 errcode; size_t len; OTL_STRCPY_S(OTL_RCAST(char*,exception_struct.msg), sizeof(exception_struct.msg), "123456789"); OCIErrorGet (OTL_RCAST(dvoid*,errhp), OTL_SCAST(ub4,1), 0, &errcode, OTL_RCAST(text*,exception_struct.msg), OTL_SCAST(ub4,sizeof(exception_struct.msg)), OCI_HTYPE_ERROR); exception_struct.code=errcode; len=strlen(OTL_RCAST(char*,exception_struct.msg)); exception_struct.msg[len]=0; #if defined(OTL_EXCEPTION_ENABLE_ERROR_OFFSET) ub2 error_offset; if(OCIAttrGet (cda, OCI_HTYPE_STMT, OTL_RCAST(ub2*,&error_offset), 0, OTL_SCAST(ub4,OCI_ATTR_PARSE_ERROR_OFFSET), errhp)==OCI_SUCCESS) exception_struct.error_offset=OTL_SCAST(int,error_offset); #endif } private: otl_cur(const otl_cur&): otl_cur0(), cda(0), errhp(0), extern_cda(false), status(0), eof_status(0), db(0), straight_select(1), pos_nbr(0), commit_on_success(0), last_param_data_token(0), last_sql_param_data_status(0), sql_param_data_count(0), canceled(false), direct_exec_flag(0), parse_only_flag(0), stm_executed(0) { } otl_cur& operator=(const otl_cur&) { return *this; } }; class otl_ref_cursor; class otl_sel{ private: friend class otl_ref_cursor; int implicit_cursor; public: int get_implicit_cursor() const {return implicit_cursor;} void set_arr_size (const int input_arr_size, int& out_array_size, int& out_prefetch_array_size) { out_array_size=input_arr_size; out_prefetch_array_size=0; } void set_prefetch_size(const int /*aprefetch_array_size*/) { } int close_select(otl_cur& /*cur*/) { int i=1; return i; } otl_sel(): implicit_cursor(0) { } virtual ~otl_sel(){} void set_select_type(const int /*atype*/) { implicit_cursor=0; } void init(const int /*array_size*/){} int first (otl_cur& cur, int& cur_row, int& cur_size, int& row_count, int& eof_data, const int array_size) {int rc; eof_data=0; cur_row=-1; cur.commit_on_success=0; rc=cur.exec(0,0,otl_sql_exec_from_select_cursor_class); if(rc==0)return 0; rc=cur.fetch(OTL_SCAST(otl_stream_buffer_size_type,array_size),eof_data); if(rc==0)return 0; row_count=cur.rpc(); cur_size=row_count; if(cur_size!=0)cur_row=0; return 1; } int next (otl_cur& cur, int& cur_row, int& cur_size, int& row_count, int& eof_data, const int array_size) {int rc; if(cur_row otl_ora8_connect; typedef otl_tmpl_cursor otl_cursor; template class otl_tmpl_lob_stream: public otl_lob_stream_generic{ public: typedef otl_tmpl_exception otl_exception; typedef otl_tmpl_variable* p_bind_var; typedef otl_tmpl_connect * p_connect; typedef otl_tmpl_cursor * p_cursor; private: p_bind_var bind_var; p_connect connect; p_cursor cursor; otl_long_string* temp_buf; char* temp_char_buf; public: void init (void* avar,void* aconnect,void* acursor, int andx, int amode, const int alob_is_null=0) OTL_NO_THROW { connect=OTL_RCAST(p_connect,aconnect); bind_var=OTL_RCAST(p_bind_var,avar); cursor=OTL_RCAST(p_cursor,acursor); mode=amode; retcode=0; lob_is_null=alob_is_null; ndx=andx; offset=0; if(amode==otl_lob_stream_write_mode) lob_len=2147483647; else lob_len=0; eof_flag=0; in_destructor=0; if(bind_var) bind_var->get_var_struct().set_lob_stream_flag(); } void set_len(const int new_len=0) OTL_NO_THROW { lob_len=new_len; } otl_tmpl_lob_stream() OTL_NO_THROW: otl_lob_stream_generic(true), bind_var(0), connect(0), cursor(0), temp_buf(0), temp_char_buf(0) { init(0,0,0,0,otl_lob_stream_zero_mode); } virtual ~otl_tmpl_lob_stream() #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) OTL_THROWS_OTL_EXCEPTION #endif { in_destructor=1; if(temp_buf){ delete temp_buf; temp_buf=0; } if(temp_char_buf){ delete[] temp_char_buf; temp_char_buf=0; } #if defined(OTL_DESTRUCTORS_DO_NOT_THROW) try{ close(); }catch(OTL_CONST_EXCEPTION otl_exception&){ } #else close(); #endif } #if (defined(OTL_STL) || defined(OTL_ACE) || \ defined(OTL_USER_DEFINED_STRING_CLASS_ON)) && !defined(OTL_UNICODE) otl_lob_stream_generic& operator<<(const OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION { otl_long_string temp_s(s.c_str(), OTL_SCAST(int,s.length()), OTL_SCAST(int,s.length())); (*this)<>(OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION { const int TEMP_BUF_SIZE=4096; if(!temp_char_buf)temp_char_buf=new char[TEMP_BUF_SIZE]; if(!temp_buf)temp_buf=new otl_long_string(temp_char_buf,TEMP_BUF_SIZE-1); int iters=0; while(!this->eof()){ ++iters; (*this)>>(*temp_buf); temp_char_buf[temp_buf->len()]=0; if(iters>1) s+=temp_char_buf; else s=temp_char_buf; } return *this; } #endif otl_lob_stream_generic& operator<<(const otl_long_string& s) OTL_THROWS_OTL_EXCEPTION { if(mode!=otl_lob_stream_write_mode){ const char* stm=0; char var_info[256]; var_info[0]=0; if(cursor!=0){ if(cursor->get_stm_label()) stm=cursor->get_stm_label(); else stm=cursor->get_stm_text(); } if(bind_var!=0){ otl_var_info_var (bind_var->get_name(), bind_var->get_ftype(), otl_var_long_string, var_info, sizeof(var_info)); } char* vinfo=0; if(var_info[0]!=0) vinfo=&var_info[0]; if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_tmpl_exception (otl_error_msg_9, otl_error_code_9, stm, vinfo); } if(offset==0)offset=1; if((offset-1)+s.len()>lob_len){ char var_info[256]; otl_var_info_var (bind_var->get_name(), bind_var->get_ftype(), otl_var_long_string, var_info, sizeof(var_info)); if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; char err_msg[1024]; char temp_num[64]; OTL_STRCPY_S(err_msg,sizeof(err_msg),otl_error_msg_7); OTL_STRCAT_S(err_msg,sizeof(err_msg),", trying to store "); otl_itoa(s.len(),temp_num); OTL_STRCAT_S(err_msg,sizeof(err_msg),temp_num); #if defined(OTL_UNICODE) OTL_STRCAT_S(err_msg,sizeof(err_msg)," Unicode characters at offset "); #else OTL_STRCAT_S(err_msg,sizeof(err_msg)," bytes at offset "); #endif otl_itoa(offset,temp_num); OTL_STRCAT_S(err_msg,sizeof(err_msg),temp_num); OTL_STRCAT_S(err_msg,sizeof(err_msg),". New length: "); otl_itoa((offset-1)+s.len(),temp_num); OTL_STRCAT_S(err_msg,sizeof(err_msg),temp_num); OTL_STRCAT_S(err_msg,sizeof(err_msg)," would be bigger than length of lob: "); otl_itoa(lob_len,temp_num); OTL_STRCAT_S(err_msg,sizeof(err_msg),temp_num); throw otl_tmpl_exception (err_msg, otl_error_code_7, cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text(), var_info); } if(s.is_last_piece()) lob_len=(offset+s.len()-1); retcode=bind_var->get_var_struct().write_blob (s,lob_len,offset,cursor->get_cursor_struct()); if(retcode){ if((offset-1)==lob_len) close(); return *this; } if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_tmpl_exception (connect->get_connect_struct(), cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text()); } otl_lob_stream_generic& operator>>(otl_long_string& s) OTL_THROWS_OTL_EXCEPTION { if(mode!=otl_lob_stream_read_mode){ const char* stm=0; char var_info[256]; var_info[0]=0; if(cursor!=0){ if(cursor->get_stm_label()) stm=cursor->get_stm_label(); else stm=cursor->get_stm_text(); } if(bind_var!=0){ otl_var_info_var (bind_var->get_name(), bind_var->get_ftype(), otl_var_long_string, var_info, sizeof(var_info)); } char* vinfo=0; if(var_info[0]!=0) vinfo=&var_info[0]; if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_tmpl_exception (otl_error_msg_10, otl_error_code_10, stm, vinfo); } if(offset==0&&lob_len==0) lob_len=len(); if(lob_len==0||(offset-1)==lob_len){ s.set_len(0); eof_flag=1; return *this; } if(offset==0)offset=1; retcode=bind_var->get_var_struct().read_blob(s,ndx,offset,lob_len); if((offset-1)==lob_len)eof_flag=1; if(retcode){ if(eof()){ close(); eof_flag=1; } return *this; } if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_tmpl_exception (connect->get_connect_struct(), cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text()); } int eof(void) OTL_NO_THROW { if(lob_is_null)return 1; return eof_flag; } bool is_initialized(void) OTL_THROWS_OTL_EXCEPTION { if(cursor==0||connect==0||bind_var==0||lob_is_null)return false; int is_init=0; retcode=bind_var->get_var_struct().is_blob_initialized(ndx,is_init); if(retcode) return is_init!=0; if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return false; if(otl_uncaught_exception()) return false; throw OTL_TMPL_EXCEPTION (connect->get_connect_struct(), cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text()); } int len(void) OTL_THROWS_OTL_EXCEPTION { if(cursor==0||connect==0||bind_var==0||lob_is_null)return 0; int alen; retcode=bind_var->get_var_struct().get_blob_len(ndx,alen); if(retcode)return alen; if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_tmpl_exception (connect->get_connect_struct(), cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text()); } void close(void) OTL_THROWS_OTL_EXCEPTION { if(in_destructor){ if(mode==otl_lob_stream_read_mode){ bind_var->get_var_struct().set_lob_stream_flag(0); bind_var->set_not_null(0); } return; } if(mode==otl_lob_stream_zero_mode)return; if(mode==otl_lob_stream_read_mode){ if(offsetget_var_struct().close_lob(); bind_var->get_var_struct().set_lob_stream_flag(0); bind_var->set_not_null(0); init(0,0,0,0,otl_lob_stream_zero_mode); }else{ // write mode if(!(offset==0&&lob_len==0)&&(offset-1)!=lob_len){ bind_var->get_var_struct().close_lob(); char var_info[256]; char msg_buf[1024]; OTL_STRCPY_S(msg_buf,sizeof(msg_buf),otl_error_msg_8); otl_var_info_var (bind_var->get_name(), bind_var->get_ftype(), otl_var_long_string, var_info, sizeof(var_info)); if(this->connect)this->connect->increment_throw_count(); if(this->connect&&this->connect->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_tmpl_exception (msg_buf, otl_error_code_8, cursor->get_stm_label()?cursor->get_stm_label(): cursor->get_stm_text(), var_info); } bind_var->get_var_struct().set_lob_stream_flag(0); bind_var->set_not_null(0); } } private: otl_tmpl_lob_stream(const otl_tmpl_lob_stream&) OTL_NO_THROW: otl_lob_stream_generic(true), bind_var(0), connect(0), cursor(0), temp_buf(0), temp_char_buf(0) { } otl_tmpl_lob_stream& operator=(const otl_tmpl_lob_stream&) { return *this; } }; typedef otl_tmpl_lob_stream otl_lob_stream; typedef otl_tmpl_exception otl_exception; typedef otl_tmpl_inout_stream otl_ora8_inout_stream; typedef otl_tmpl_select_stream otl_select_stream; typedef otl_tmpl_ext_hv_decl otl_ext_hv_decl; const int otl_no_stream_type=0; const int otl_inout_stream_type=1; const int otl_refcur_stream_type=2; const int otl_select_stream_type=3; const int otl_constant_sql_type=4; const int otl_mixed_refcur_stream_type=5; class otl_connect: public otl_ora8_connect{ protected: #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) otl_stream_pool sc; #endif public: #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) otl_stream_pool& get_sc(){return sc;} void set_stream_pool_size(const int max_size=otl_max_default_pool_size) { sc.init(max_size); } #endif public: long direct_exec (const char* sqlstm, const int exception_enabled=1) OTL_THROWS_OTL_EXCEPTION { return otl_cursor::direct_exec(*this,sqlstm,exception_enabled); } void syntax_check(const char* sqlstm) OTL_THROWS_OTL_EXCEPTION { otl_cursor::syntax_check(*this,sqlstm); } otl_connect() OTL_NO_THROW: otl_ora8_connect(), #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) sc(), #endif cmd_(0) { } #if defined(OTL_ORA_OCI_ENV_CREATE) void set_connect_mode(bool threaded_mode=false) { connect_struct.set_threaded_mode(threaded_mode); } #endif #if defined(OTL_UNICODE) || defined(OTL_ORA_UTF8) void set_character_set(const int char_set=SQLCS_IMPLICIT) OTL_THROWS_OTL_EXCEPTION { connect_struct.set_char_set(char_set); } #endif otl_connect(const char* connect_str, const int aauto_commit=0 #if defined(OTL_ORA_OCI_ENV_CREATE) ,bool threaded_mode=false #endif ) OTL_THROWS_OTL_EXCEPTION : otl_ora8_connect(), #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) sc(), #endif cmd_(0) { #if defined(OTL_ORA_OCI_ENV_CREATE) set_connect_mode(threaded_mode); #endif rlogon(connect_str,aauto_commit); } virtual ~otl_connect() #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) OTL_THROWS_OTL_EXCEPTION #endif { if(cmd_){ delete[] cmd_; cmd_=0; } #if defined(OTL_DESTRUCTORS_DO_NOT_THROW) try{ logoff(); }catch(OTL_CONST_EXCEPTION otl_exception&){ } #else logoff(); #endif } const char* getCmd(void) const { return cmd_; } otl_connect& operator<<(const char* cmd) { if(!connected){ this->rlogon(cmd); }else{ otl_cursor::direct_exec(*this,cmd); } return *this; } otl_connect& operator<<=(const char* cmd) { if(cmd_){ delete[] cmd_; cmd_=0; } size_t cmd_len=strlen(cmd); cmd_=new char[cmd_len+1]; OTL_STRCPY_S(cmd_,cmd_len+1,cmd); return *this; } static int otl_terminate(void) OTL_THROWS_OTL_EXCEPTION { #if defined(OTL_ORA8)&&!defined(OTL_ORA8I)&&!defined(OTL_ORA9I) return 1; #else return OCITerminate(OCI_DEFAULT)==OCI_SUCCESS; #endif } void cancel(void) OTL_THROWS_OTL_EXCEPTION { if(!connected)return; retcode=connect_struct.cancel(); if(!retcode){ increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } } #if defined(OTL_ORA10G_R2) void commit_nowait(void) OTL_THROWS_OTL_EXCEPTION { if(!connected)return; retcode=connect_struct.commit_nowait(); if(!retcode){ increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } } #endif #if defined(OTL_ORA8I) || defined(OTL_ORA9I) void change_password (const char* user_name, const char* old_password, const char* new_password) OTL_THROWS_OTL_EXCEPTION { throw_count=0; retcode=connect_struct.change_password (user_name, old_password, new_password); if(!retcode){ increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } } #endif void auto_commit_off(void) OTL_THROWS_OTL_EXCEPTION { otl_ora8_connect::auto_commit_off(); } void auto_commit_on(void) OTL_THROWS_OTL_EXCEPTION { otl_ora8_connect::auto_commit_on(); } void rlogon(OCIEnv *envhp,OCISvcCtx *svchp) OTL_THROWS_OTL_EXCEPTION { if(this->connected){ throw otl_exception(otl_error_msg_30,otl_error_code_30); } if(cmd_){ delete[] cmd_; cmd_=0; } connected=0; long_max_size=32760; retcode=connect_struct.ext_logon(envhp,svchp,0); if(retcode) connected=1; else{ connected=0; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } } void rlogon(const char* connect_str, const int aauto_commit=0, const char* xa_server_external_name=0, const char* xa_server_internal_name=0 #if defined(OTL_ORA_OCI_ENV_CREATE) ,bool threaded_mode=false #endif ) OTL_THROWS_OTL_EXCEPTION { if(this->connected){ throw otl_exception(otl_error_msg_30,otl_error_code_30); } if(cmd_){ delete[] cmd_; cmd_=0; } if(xa_server_external_name!=0 && xa_server_internal_name!=0){ connect_struct.set_xa_server_external_name (xa_server_external_name); connect_struct.set_xa_server_internal_name (xa_server_internal_name); } #if defined(OTL_ORA_OCI_ENV_CREATE) set_connect_mode(threaded_mode); #endif otl_ora8_connect::rlogon(connect_str,aauto_commit); if(connect_struct.get_last_status()==OCI_SUCCESS_WITH_INFO){ otl_exception ex(connect_struct); if(ex.code!=0){ increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw ex; } } } void logoff(void) OTL_THROWS_OTL_EXCEPTION { #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) if(connected) sc.init(sc.get_max_size()); #endif if(!connected){ connect_struct.session_end(); connect_struct.server_detach(); }else{ OTL_TRACE_FUNC(0x1,"otl_connect","logoff","") if(connect_struct.get_extern_lda()) connect_struct.logoff(); else{ session_end(); server_detach(); } connected=0; } } void server_attach(const char* tnsname=0, const char* xa_server_external_name=0, const char* xa_server_internal_name=0 #if defined(OTL_ORA_OCI_ENV_CREATE) ,bool threaded_mode=false #endif ) OTL_THROWS_OTL_EXCEPTION { if(cmd_){ delete[] cmd_; cmd_=0; } if(xa_server_external_name!=0 && xa_server_internal_name!=0){ connect_struct.set_xa_server_external_name (xa_server_external_name); connect_struct.set_xa_server_internal_name (xa_server_internal_name); } connected=0; long_max_size=32760; throw_count=0; #if defined(OTL_ORA_OCI_ENV_CREATE) set_connect_mode(threaded_mode); #endif retcode=connect_struct.server_attach(tnsname); if(!retcode){ increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } } void server_detach(void) OTL_THROWS_OTL_EXCEPTION { retcode=connect_struct.server_detach(); if(!retcode){ increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } } void session_begin (const char* username, const char* password, const int auto_commit=0, const int session_mode=OCI_DEFAULT // OCI_SYSDBA -- in this mode, the user is authenticated for SYSDBA // access. // OCI_SYSOPER -- in this mode, the user is authenticated // for SYSOPER access. ) OTL_THROWS_OTL_EXCEPTION { if(cmd_){ delete[] cmd_; cmd_=0; } throw_count=0; retcode=connect_struct.session_begin (username,password,auto_commit,session_mode); if(retcode) connected=1; else{ connected=0; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } if(connect_struct.get_last_status()==OCI_SUCCESS_WITH_INFO){ otl_exception ex(connect_struct); if(ex.code!=0){ increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw ex; } } } void session_reopen(const int auto_commit=0) OTL_THROWS_OTL_EXCEPTION { throw_count=0; if(connect_struct.get_session_begin_count()==0){ connected=0; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(otl_error_msg_11,otl_error_code_11); } retcode=connect_struct.session_begin(auto_commit); if(retcode) connected=1; else{ connected=0; increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } if(connect_struct.get_last_status()==OCI_SUCCESS_WITH_INFO){ otl_exception ex(connect_struct); if(ex.code!=0){ increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw ex; } } } void session_end(void) OTL_THROWS_OTL_EXCEPTION { #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) if(connected) sc.init(sc.get_max_size()); #endif connected=0; retcode=connect_struct.session_end(); if(!retcode){ increment_throw_count(); if(get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(connect_struct); } } private: char* cmd_; otl_connect& operator=(const otl_connect&) { return *this; } otl_connect(const otl_connect&) : otl_ora8_connect(), #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) sc(), #endif cmd_(0) { } }; typedef otl_tmpl_variable otl_generic_variable; typedef otl_generic_variable* otl_p_generic_variable; class otl_refcur_base_cursor: public otl_tmpl_cursor { protected: int cur_row; int cur_size; int row_count; int array_size; public: otl_refcur_base_cursor (otl_connect& db, otl_var* var, const char* master_plsql_block, const otl_stream_buffer_size_type arr_size=1) :otl_tmpl_cursor (db,var), cur_row(-1), cur_size(0), row_count(0), array_size(arr_size) { size_t len=strlen(master_plsql_block)+1; stm_text=new char[len]; OTL_STRCPY_S(stm_text,len,master_plsql_block); } otl_refcur_base_cursor(): otl_tmpl_cursor (), cur_row(-1), cur_size(0), row_count(0), array_size(0) { } virtual ~otl_refcur_base_cursor() { delete[] stm_text; stm_text=0; } void open (otl_connect& db, otl_var* var, const char* master_plsql_block, const otl_stream_buffer_size_type arr_size=1) { cur_row=-1; row_count=0; cur_size=0; array_size=arr_size; otl_tmpl_cursor ::open(db,var); size_t len=strlen(master_plsql_block)+1; stm_text=new char[len]; OTL_STRCPY_S(stm_text,len,master_plsql_block); } void close(void) { delete[] stm_text; stm_text=0; otl_tmpl_cursor ::close(); } int first(void) {int rc; cur_row=-1; rc=cursor_struct.fetch(OTL_SCAST (otl_stream_buffer_size_type, array_size), eof_data); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception(cursor_struct,stm_label?stm_label:stm_text); } row_count=cursor_struct.rpc(); cur_size=row_count; if(cur_size!=0)cur_row=0; return cur_size!=0; } int next(void) {int rc; if(cur_row<0)return first(); if(cur_row::eof()){ cur_row=-1; return 0; } rc=cursor_struct.fetch(OTL_SCAST(otl_stream_buffer_size_type, array_size),eof_data); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception(cursor_struct,stm_label?stm_label:stm_text); } cur_size=cursor_struct.rpc()-row_count; row_count=cursor_struct.rpc(); if(cur_size!=0)cur_row=0; } return cur_size!=0; } void bind_col (const int column_num, otl_generic_variable& v) { if(!connected)return; v.set_pos(column_num); otl_refcur_base_cursor::bind(column_num,v); } int describe_select (otl_column_desc* desc, int& desc_len) {int i; desc_len=0; cursor_struct.straight_select=0; for(i=1;describe_column(desc[i-1],i);++i) ++desc_len; return 1; } private: otl_refcur_base_cursor(const otl_refcur_base_cursor&): otl_tmpl_cursor (), cur_row(-1), cur_size(0), row_count(0), array_size(0) { } otl_refcur_base_cursor& operator=(const otl_refcur_base_cursor&) { return *this; } }; #if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE) #define OTL_ORA_COMMON_READ_STREAM otl_read_stream_interface #define OTL_ORA_REFCUR_COMMON_READ_STREAM otl_read_stream_interface class otl_read_stream_interface{ public: virtual ~otl_read_stream_interface(){} virtual int is_null(void) OTL_NO_THROW = 0; virtual void rewind(void) OTL_THROWS_OTL_EXCEPTION = 0; virtual int eof(void) OTL_NO_THROW = 0; virtual void skip_to_end_of_row(void) OTL_NO_THROW = 0; virtual otl_var_desc* describe_out_vars(int& desc_len) OTL_NO_THROW = 0; virtual otl_var_desc* describe_next_out_var(void) OTL_NO_THROW = 0; virtual otl_read_stream_interface& operator>>(otl_datetime& s) OTL_THROWS_OTL_EXCEPTION = 0; #if !defined(OTL_UNICODE) virtual otl_read_stream_interface& operator>>(char& c) OTL_THROWS_OTL_EXCEPTION = 0; #endif virtual otl_read_stream_interface& operator>>(unsigned char& c) OTL_THROWS_OTL_EXCEPTION = 0; #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) virtual otl_read_stream_interface& operator>>(OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION = 0; #endif #if defined(OTL_UNICODE_STRING_TYPE) virtual otl_read_stream_interface& operator>>(OTL_UNICODE_STRING_TYPE& s) OTL_THROWS_OTL_EXCEPTION = 0; #endif #if !defined(OTL_UNICODE) virtual otl_read_stream_interface& operator>>(char* s) OTL_THROWS_OTL_EXCEPTION = 0; #endif #if defined(OTL_UNICODE) virtual otl_read_stream_interface& operator>>(OTL_UNICODE_CHAR_TYPE* s) OTL_THROWS_OTL_EXCEPTION = 0; #endif virtual otl_read_stream_interface& operator>>(unsigned char* s) OTL_THROWS_OTL_EXCEPTION = 0; #if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\ !defined(OTL_BIGINT_TO_STR)) virtual otl_read_stream_interface& operator>>(OTLBIGINT& f) OTL_THROWS_OTL_EXCEPTION = 0; #endif virtual otl_read_stream_interface& operator>>(int& n) OTL_THROWS_OTL_EXCEPTION = 0; virtual otl_read_stream_interface& operator>>(unsigned& u) OTL_THROWS_OTL_EXCEPTION = 0; virtual otl_read_stream_interface& operator>>(short& sh) OTL_THROWS_OTL_EXCEPTION = 0; virtual otl_read_stream_interface& operator>>(long int& l) OTL_THROWS_OTL_EXCEPTION = 0; virtual otl_read_stream_interface& operator>>(float& f) OTL_THROWS_OTL_EXCEPTION = 0; virtual otl_read_stream_interface& operator>>(double& d) OTL_THROWS_OTL_EXCEPTION = 0; virtual otl_read_stream_interface& operator>>(otl_long_string& s) OTL_THROWS_OTL_EXCEPTION = 0; virtual otl_read_stream_interface& operator>>(otl_lob_stream& s) OTL_THROWS_OTL_EXCEPTION = 0; virtual otl_column_desc* describe_select(int& desc_len) OTL_NO_THROW = 0; }; #else #define OTL_ORA_COMMON_READ_STREAM otl_stream #define OTL_ORA_REFCUR_COMMON_READ_STREAM otl_refcur_stream #endif class otl_refcur_stream: #if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE) public otl_read_stream_interface, #endif public otl_refcur_base_cursor{ protected: int delay_next; int same_sl_flag; otl_select_struct_override override; otl_var_desc* ov; int ov_len; int next_ov_ndx; public: void skip_to_end_of_row() { check_if_executed(); if(eof())return; while(cur_colcur_row); } ret_code=this->next(); cur_col=0; if(!eof()) cur_col=-1; } bool good() const { return get_connected()==1; } bool get_lob_stream_flag() const { return true; } int get_adb_max_long_size() const { return this->adb->get_max_long_size(); } void inc_next_ov(void) { if(ov_len==0)return; if(next_ov_ndxadb)this->adb->increment_throw_count(); throw; } } virtual ~otl_refcur_stream() OTL_THROWS_OTL_EXCEPTION { cleanup(); close(); } int is_null(void) OTL_NO_THROW { return null_fetched; } int eof(void) OTL_NO_THROW { if(delay_next){ look_ahead(); delay_next=0; } return !ret_code; } int eof_intern(void) { return !ret_code; } void check_if_executed(void){} void open (otl_connect& db, otl_var* var, const char* master_plsql_block, const otl_stream_buffer_size_type arr_size=1) OTL_THROWS_OTL_EXCEPTION { otl_refcur_base_cursor::open(db,var,master_plsql_block,arr_size); get_select_list(); rewind(); delete[] ov; ov=new otl_var_desc[sl_len]; ov_len=sl_len; for(int i=0;i>(otl_time0& t) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_timestamp)&&!eof_intern()){ #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) void* tm=OTL_RCAST(void*,sl[cur_col].val(this->cur_row)); int rc=sl[cur_col].get_var_struct().read_dt(&t,tm,sizeof(otl_time0)); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception(adb->get_connect_struct(),stm_label?stm_label:stm_text); } #else otl_time0* tm=OTL_RCAST(otl_time0*,sl[cur_col].val(cur_row)); memcpy(OTL_RCAST(void*,&t),tm,otl_oracle_date_size); #endif look_ahead(); } inc_next_ov(); return *this; } #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) // already declared #else OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(otl_datetime& s) OTL_THROWS_OTL_EXCEPTION {otl_time0 tmp; (*this)>>tmp; #if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_DATETIME_NULL_TO_VAL; else{ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100); s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour-1; s.minute=tmp.minute-1; s.second=tmp.second-1; } #else s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100); s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour-1; s.minute=tmp.minute-1; s.second=tmp.second-1; #endif inc_next_ov(); return *this; } #endif OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(char& c) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ c=*OTL_RCAST(char*,sl[cur_col].val(cur_row)); #if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL) if((*this).is_null()) c=OTL_DEFAULT_CHAR_NULL_TO_VAL; #endif look_ahead(); } inc_next_ov(); return *this; } OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(unsigned char& c) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ c=*OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); #if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL) if((*this).is_null()) c=OTL_DEFAULT_CHAR_NULL_TO_VAL; #endif look_ahead(); } inc_next_ov(); return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); switch(sl[cur_col].get_ftype()){ case otl_var_char: if(!eof_intern()){ #if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL) if((*this).is_null()){ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s); }else #elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_STRING_NULL_TO_VAL; else #endif #if defined(OTL_ACE) s.set(OTL_RCAST(char*,sl[cur_col].val(cur_row)),1); #else s=OTL_RCAST(char*,sl[cur_col].val(cur_row)); #endif look_ahead(); } break; #if defined(USER_DEFINED_STRING_CLASS) || \ defined(OTL_STL) || defined(OTL_ACE) case otl_var_varchar_long: case otl_var_raw_long: if(!eof_intern()){ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); int len=sl[cur_col].get_len(cur_row); #if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE) s.assign(OTL_RCAST(char*,c),len); #elif defined(OTL_ACE) s.set(OTL_RCAST(char*,c),len,1); #endif look_ahead(); } break; case otl_var_blob: case otl_var_clob: if(!eof_intern()){ int len=0; int max_long_sz=this->adb->get_max_long_size(); otl_auto_array_ptr loc_ptr(max_long_sz); unsigned char* temp_buf=loc_ptr.get_ptr(); int rc=sl[cur_col].get_var_struct().get_blob (cur_row, temp_buf, max_long_sz, len); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception(adb->get_connect_struct(), stm_label?stm_label:stm_text); } #if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE) s.assign(OTL_RCAST(char*,temp_buf),len); #elif defined(OTL_ACE) s.set(OTL_RCAST(char*,temp_buf),len,1); #endif look_ahead(); } break; #endif default: check_type(otl_var_char); } // switch inc_next_ov(); return *this; } #endif OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(char* s) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,sl[cur_col].val(cur_row))); #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL) ); #endif look_ahead(); } inc_next_ov(); return *this; } #if defined(OTL_UNICODE_STRING_TYPE) OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(OTL_UNICODE_STRING_TYPE& s) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ #if defined(OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR) OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(cur_row)); OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR(s,temp_s+1,*temp_s); #else OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(cur_row)); s.assign(temp_s+1,*temp_s); #endif #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,OTL_DEFAULT_STRING_NULL_TO_VAL); #endif look_ahead(); } inc_next_ov(); return *this; } #endif #if defined(OTL_UNICODE) OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(OTL_UNICODE_CHAR_TYPE* s) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ otl_strcpy2(OTL_RCAST(unsigned char*,s), OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)), sl[cur_col].get_len(cur_row) ); #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL) ); #endif look_ahead(); } inc_next_ov(); return *this; } #endif OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(unsigned char* s) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ otl_strcpy2(OTL_RCAST(unsigned char*,s), OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)), sl[cur_col].get_len(cur_row) ); #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL) ); #endif look_ahead(); } inc_next_ov(); return *this; } OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(int& n) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(!eof_intern()){ #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T2 (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), n); #else int match_found=otl_numeric_convert_T (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), n); #endif if(!match_found){ if(check_type(otl_var_double,otl_var_int)) n=OTL_PCONV(int,double,sl[cur_col].val(cur_row)); } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) n=OTL_SCAST(int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif look_ahead(); } inc_next_ov(); return *this; } #if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\ !defined(OTL_BIGINT_TO_STR)) OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(OTL_BIGINT& n) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(!eof_intern()){ #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T2 (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), n); #else int match_found=otl_numeric_convert_T (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), n); #endif if(!match_found){ if(check_type(otl_var_double,otl_var_int)) n=OTL_PCONV(OTL_BIGINT,double,sl[cur_col].val(cur_row)); } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif look_ahead(); } inc_next_ov(); return *this; } #endif OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(unsigned& u) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(!eof_intern()){ #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T2 (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), u); #else int match_found=otl_numeric_convert_T (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), u); #endif if(!match_found){ if(check_type(otl_var_double,otl_var_unsigned_int)) u=OTL_PCONV(unsigned,double,sl[cur_col].val(cur_row)); } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) u=OTL_SCAST(unsigned int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif look_ahead(); } inc_next_ov(); return *this; } OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(short& sh) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(!eof_intern()){ #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T2 (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), sh); #else int match_found=otl_numeric_convert_T (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), sh); #endif if(!match_found){ if(check_type(otl_var_double,otl_var_short)) sh=OTL_PCONV(short,double,sl[cur_col].val(cur_row)); } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) sh=OTL_SCAST(short int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif look_ahead(); } inc_next_ov(); return *this; } OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(long int& l) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(!eof_intern()){ #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T2 (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), l); #else int match_found=otl_numeric_convert_T (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), l); #endif if(!match_found){ if(check_type(otl_var_double,otl_var_long_int)) l=OTL_PCONV(long int,double,sl[cur_col].val(cur_row)); } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) l=OTL_SCAST(long int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif look_ahead(); } inc_next_ov(); return *this; } OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(float& f) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(!eof_intern()){ #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T2 (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), f); #else int match_found=otl_numeric_convert_T (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), f); #endif if(!match_found){ if(check_type(otl_var_double,otl_var_float)) f=OTL_PCONV(float,double,sl[cur_col].val(cur_row)); } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) f=OTL_SCAST(float,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif look_ahead(); } inc_next_ov(); return *this; } OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(double& d) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(!eof_intern()){ #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T2 (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), d); #else int match_found=otl_numeric_convert_T (sl[cur_col].get_ftype(), sl[cur_col].val(cur_row), d); #endif if(!match_found){ if(check_type(otl_var_double,otl_var_double)) d=*OTL_RCAST(double*,sl[cur_col].val(cur_row)); } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) d=OTL_SCAST(double,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif look_ahead(); } inc_next_ov(); return *this; } OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(otl_long_string& s) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if(!eof_intern()){ switch(sl[cur_col].get_ftype()){ case otl_var_raw_long: case otl_var_varchar_long: { unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); int len=sl[cur_col].get_len(cur_row); if(len>s.get_buf_size()) len=s.get_buf_size(); otl_memcpy(s.v,c,len,sl[cur_col].get_ftype()); if(sl[cur_col].get_ftype()==otl_var_varchar_long) s.null_terminate_string(len); s.set_len(len); look_ahead(); } break; case otl_var_blob: case otl_var_clob: { int len; int rc=sl[cur_col].get_var_struct().get_blob(cur_row,s.v,s.get_buf_size(),len); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception(adb->get_connect_struct(), stm_label?stm_label:stm_text); } s.set_len(len); if(sl[cur_col].get_ftype()==otl_var_clob) s.null_terminate_string(len); look_ahead(); } break; case otl_var_raw: { unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(this->cur_row)); int len2=OTL_SCAST(int,*OTL_RCAST(unsigned short*,c)); otl_memcpy(s.v,c+sizeof(short int),len2,sl[cur_col].get_ftype()); s.set_len(len2); look_ahead(); } break; } } inc_next_ov(); return *this; } OTL_ORA_REFCUR_COMMON_READ_STREAM& operator>>(otl_lob_stream& s) OTL_THROWS_OTL_EXCEPTION { check_if_executed(); if(eof_intern())return *this; get_next(); if((sl[cur_col].get_ftype()==otl_var_blob|| sl[cur_col].get_ftype()==otl_var_clob)&& !eof_intern()){ s.init (&sl[cur_col], adb, OTL_RCAST(otl_refcur_base_cursor*,this), cur_row, otl_lob_stream_read_mode, this->is_null()); delay_next=1; } inc_next_ov(); return *this; } otl_var_desc* describe_out_vars(int& desc_len) OTL_NO_THROW { desc_len=0; if(ov==0)return 0; desc_len=ov_len; return ov; } otl_var_desc* describe_next_out_var(void) OTL_NO_THROW { if(ov==0)return 0; return &ov[next_ov_ndx]; } int select_list_len(void) OTL_NO_THROW { return sl_len; } int column_ftype(int ndx=0) OTL_NO_THROW { return sl[ndx].get_ftype(); } int column_size(int ndx=0) OTL_NO_THROW { return sl[ndx].get_elem_size(); } otl_column_desc* describe_select(int& desc_len) OTL_NO_THROW { desc_len=0; desc_len=sl_len; return sl_desc; } protected: otl_column_desc* sl_desc; int sl_len; otl_generic_variable* sl; int null_fetched; int ret_code; int cur_col; int cur_in; int executed; char var_info[256]; void init(void) { ov=0; ov_len=0; next_ov_ndx=0; same_sl_flag=0; sl=0; sl_len=0; null_fetched=0; ret_code=0; sl_desc=0; executed=0; cur_in=0; cur_col=-1; executed=1; stm_text=0; delay_next=0; } void get_next(void) { if(cur_coladb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception (otl_error_msg_0, otl_error_code_0, stm_label?stm_label:stm_text, var_info); } int check_type(int type_code, int actual_data_type=0) { switch(sl[cur_col].get_ftype()){ case otl_var_timestamp: case otl_var_tz_timestamp: case otl_var_ltz_timestamp: if(type_code==otl_var_timestamp) return 1; default: if(sl[cur_col].get_ftype()==type_code) return 1; } return check_type_throw(type_code,actual_data_type); } void look_ahead(void) { if(cur_col==sl_len-1){ ret_code=next(); cur_col=-1; } } void get_select_list(void) { int i,j; otl_auto_array_ptr loc_ptr(otl_var_list_size); otl_column_desc* sl_desc_tmp=loc_ptr.get_ptr(); int sld_tmp_len=0; int ftype,elem_size; sld_tmp_len=0; cursor_struct.straight_select=0; for(i=1;describe_column(sl_desc_tmp[i-1],i);++i){ ++sld_tmp_len; if(sld_tmp_len==loc_ptr.get_arr_size()){ loc_ptr.double_size(); sl_desc_tmp=loc_ptr.get_ptr(); } } sl_len=sld_tmp_len; if(sl){ delete[] sl; sl=0; } sl=new otl_generic_variable[sl_len==0?1:sl_len]; int max_long_size=this->adb->get_max_long_size(); for(j=0;jadb->get_connect_struct().get_connection_type()); sl[j].copy_pos(j+1); #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) if(sl_desc_tmp[j].charset_form==2) sl[j].get_var_struct().nls_flag=true; #endif sl[j].init(true, ftype, elem_size, OTL_SCAST(otl_stream_buffer_size_type,array_size), &adb->get_connect_struct() ); } if(sl_desc){ delete[] sl_desc; sl_desc=0; } sl_desc=new otl_column_desc[sl_len==0?1:sl_len]; for(i=0;i>(otl_refcur_stream& str) { if(eof())return *this; if(check_in_type(otl_var_refcur,1)){ if(str.get_connected())str.close(); str.open(*adb2, &(in_vl[cur_in_x]->get_var_struct()), stm_text, OTL_SCAST (const otl_stream_buffer_size_type, in_vl[cur_in_x]->get_var_struct().array_size) ); null_fetched=0; } get_in_next(); return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) otl_inout_stream& operator>>(OTL_STRING_CONTAINER& s) { otl_ora8_inout_stream::operator>>(s); return *this; } otl_inout_stream& operator<<(const OTL_STRING_CONTAINER& s) { otl_ora8_inout_stream::operator<<(s); return *this; } #endif otl_inout_stream& operator<<(const otl_null& n) { otl_ora8_inout_stream::operator<<(n); return *this; } #if defined(OTL_PL_TAB) && defined(OTL_STL) otl_inout_stream& operator>>(otl_pl_vec_generic& tab) { otl_ora8_inout_stream::operator>>(tab); return *this; } otl_inout_stream& operator<<(otl_pl_vec_generic& tab) { otl_ora8_inout_stream::operator<<(tab); return *this; } #endif otl_inout_stream& operator>>(otl_pl_tab_generic& tab) { otl_ora8_inout_stream::operator>>(tab); return *this; } otl_inout_stream& operator<<(otl_pl_tab_generic& tab) { otl_ora8_inout_stream::operator<<(tab); return *this; } otl_inout_stream& operator>>(otl_time0& s) { otl_ora8_inout_stream::operator>>(s); return *this; } otl_inout_stream& operator<<(const otl_time0& s) { otl_ora8_inout_stream::operator<<(s); return *this; } otl_inout_stream& operator>>(char& c) { otl_ora8_inout_stream::operator>>(c); return *this; } otl_inout_stream& operator<<(const char c) { otl_ora8_inout_stream::operator<<(c); return *this; } otl_inout_stream& operator>>(unsigned char& c) { otl_ora8_inout_stream::operator>>(c); return *this; } #if defined(OTL_UNICODE_STRING_TYPE) otl_inout_stream& operator>>(OTL_UNICODE_STRING_TYPE& s) { otl_ora8_inout_stream::operator>>(s); return *this; } otl_inout_stream& operator<<(const OTL_UNICODE_STRING_TYPE& s) { otl_ora8_inout_stream::operator<<(s); return *this; } #endif otl_inout_stream& operator<<(const unsigned char c) { otl_ora8_inout_stream::operator<<(c); return *this; } otl_inout_stream& operator>>(char* s) { otl_ora8_inout_stream::operator>>(s); return *this; } otl_inout_stream& operator<<(const char* s) { otl_ora8_inout_stream::operator<<(s); return *this; } otl_inout_stream& operator>>(unsigned char* s) { otl_ora8_inout_stream::operator>>(s); return *this; } otl_inout_stream& operator<<(const unsigned char* s) { otl_ora8_inout_stream::operator<<(s); return *this; } #if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\ !defined(OTL_BIGINT_TO_STR)) otl_inout_stream& operator>>(OTL_BIGINT& n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator>>(n); #else otl_ora8_inout_stream::operator>>(n); #endif return *this; } #endif otl_inout_stream& operator>>(int& n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator>>(n); #else otl_ora8_inout_stream::operator>>(n); #endif return *this; } #if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\ !defined(OTL_BIGINT_TO_STR)) otl_inout_stream& operator<<(const OTL_BIGINT n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator<<(n); #else otl_ora8_inout_stream::operator<<(n); #endif return *this; } #endif otl_inout_stream& operator<<(const int n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator<<(n); #else otl_ora8_inout_stream::operator<<(n); #endif return *this; } otl_inout_stream& operator>>(float& n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator>>(n); #else otl_ora8_inout_stream::operator>>(n); #endif return *this; } otl_inout_stream& operator<<(const float n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator<<(n); #else otl_ora8_inout_stream::operator<<(n); #endif return *this; } otl_inout_stream& operator>>(double& n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator>>(n); #else otl_ora8_inout_stream::operator>>(n); #endif return *this; } otl_inout_stream& operator<<(const double n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator<<(n); #else otl_ora8_inout_stream::operator<<(n); #endif return *this; } otl_inout_stream& operator>>(short int& n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator>>(n); #else otl_ora8_inout_stream::operator>>(n); #endif return *this; } otl_inout_stream& operator<<(const short int n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator<<(n); #else otl_ora8_inout_stream::operator<<(n); #endif return *this; } otl_inout_stream& operator>>(unsigned int& n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator>>(n); #else otl_ora8_inout_stream::operator>>(n); #endif return *this; } otl_inout_stream& operator<<(const unsigned int n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator<<(n); #else otl_ora8_inout_stream::operator<<(n); #endif return *this; } otl_inout_stream& operator>>(long int& n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator>>(n); #else otl_ora8_inout_stream::operator>>(n); #endif return *this; } otl_inout_stream& operator<<(const long int n) { #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) otl_ora8_inout_stream::operator<<(n); #else otl_ora8_inout_stream::operator<<(n); #endif return *this; } otl_inout_stream& operator>>(otl_long_string& n) { otl_ora8_inout_stream::operator>>(n); return *this; } otl_inout_stream& operator<<(const otl_long_string& n) { otl_ora8_inout_stream::operator<<(n); return *this; } otl_inout_stream& operator>>(otl_lob_stream& n) { otl_ora8_inout_stream::operator>>(n); return *this; } otl_inout_stream& operator<<(otl_lob_stream& s) { otl_ora8_inout_stream::operator<<(s); return *this; } protected: otl_connect* adb2; private: otl_inout_stream(const otl_inout_stream&): otl_ora8_inout_stream(), adb2(0) { } otl_inout_stream& operator=(const otl_inout_stream&) { return *this; } }; // ============ OTL Reference Cursor Streams for Oracle 8 ================= class otl_cur; class otl_ref_cursor: public otl_tmpl_cursor { protected: friend class otl_cur; int cur_row; int cur_size; int row_count; int array_size; otl_select_struct_override local_override; public: otl_ref_cursor (otl_connect& db, const char* cur_placeholder_name, void* master_stream_ptr, const otl_stream_buffer_size_type arr_size=1) :otl_tmpl_cursor (db), cur_row(-1), cur_size(0), row_count(0), array_size(arr_size), local_override(), sel_cur(), rvl_len(otl_var_list_size), rvl(new otl_p_generic_variable[rvl_len]), vl_cur_len(0), cur_placeholder(), master_stream_ptr_(master_stream_ptr) {int i; local_override.reset(); for(i=0;i(), cur_row(-1), cur_size(0), row_count(0), array_size(0), local_override(), sel_cur(), rvl_len(0), rvl(), vl_cur_len(0), cur_placeholder(), master_stream_ptr_(0) { local_override.reset(); } virtual ~otl_ref_cursor() { delete[] rvl; rvl=0; } void open (otl_connect& db, const char* cur_placeholder_name, const otl_stream_buffer_size_type arr_size=1) {int i; local_override.reset(); cur_row=-1; row_count=0; cur_size=0; array_size=arr_size; rvl_len=otl_var_list_size; vl_cur_len=0; rvl=new otl_p_generic_variable[rvl_len]; for(i=0;i::open(db); } void release_sel_cur(void) { #if defined(OTL_ORA8_8I_REFCUR) return; #else char tmp_buf[256]; OCIBind* bindpp; int rc; if(!sel_cur.get_connected())return; OTL_STRCPY_S(tmp_buf,sizeof(tmp_buf),"begin close "); OTL_STRCAT_S(tmp_buf,sizeof(tmp_buf),cur_placeholder); OTL_STRCAT_S(tmp_buf,sizeof(tmp_buf),"; end;"); otl_tmpl_cursor ::parse(tmp_buf); rc=OCIBindByName (cursor_struct.cda, &bindpp, cursor_struct.errhp, OTL_RCAST(text*,cur_placeholder), OTL_SCAST(sb4,strlen(cur_placeholder)), OTL_RCAST(dvoid*,&sel_cur.get_cursor_struct().cda), 0, SQLT_RSET, 0, 0, 0, 0, 0, OTL_SCAST(ub4,OCI_DEFAULT)); if(rc!=0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(cursor_struct, stm_label?stm_label:stm_text); } otl_tmpl_cursor ::exec(1,0,otl_sql_exec_from_select_cursor_class); #endif } void close(void) { local_override.reset(); delete[] rvl; rvl=0; release_sel_cur(); sel_cur.close(); otl_tmpl_cursor ::close(); } int first(void) {int i,rc; OCIBind* bindpp; if(!sel_cur.get_connected()){ sel_cur.open(*adb); rc=OCIBindByName (cursor_struct.cda, &bindpp, cursor_struct.errhp, OTL_RCAST(text*,cur_placeholder), OTL_SCAST(sb4,strlen(cur_placeholder)), OTL_RCAST(dvoid*,&sel_cur.get_cursor_struct().cda), 0, SQLT_RSET, 0, 0, 0, 0, 0, OTL_SCAST(ub4,OCI_DEFAULT)); if(rc!=0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception(cursor_struct, stm_label?stm_label:stm_text); } } if(cur_row==-2) ; // Special case -- calling describe_select() between parse() and first() else{ // Executing the PLSQL master block exec(1,0,otl_sql_exec_from_select_cursor_class); sel_cur.set_connected(1); } cur_row=-1; for(i=0;iadb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception(sel_cur.get_cursor_struct(), stm_label?stm_label:stm_text); } row_count=sel_cur.get_cursor_struct().rpc(); OTL_TRACE_FIRST_FETCH cur_size=row_count; if(cur_size!=0)cur_row=0; return cur_size!=0; } int next(void) {int rc; if(cur_row<0)return first(); if(cur_rowadb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception(sel_cur.get_cursor_struct(), stm_label?stm_label:stm_text); } cur_size=sel_cur.get_cursor_struct().rpc()-row_count; row_count=sel_cur.get_cursor_struct().rpc(); OTL_TRACE_NEXT_FETCH2 if(cur_size!=0)cur_row=0; } return cur_size!=0; } void bind (const int column_num, otl_generic_variable& v) { if(!connected)return; ++vl_cur_len; if(vl_cur_len==rvl_len){ int temp_rvl_len=rvl_len*2; otl_p_generic_variable* temp_rvl= new otl_p_generic_variable[temp_rvl_len]; int i; for(i=0;i::bind(v); } void bind (const char* name, otl_generic_variable& v) { otl_tmpl_cursor ::bind(name,v); } int describe_select (otl_column_desc* desc, int& desc_len) {int i,rc; OCIBind* bindpp; if(!sel_cur.get_connected()){ sel_cur.open(*adb); rc=OCIBindByName (cursor_struct.cda, &bindpp, cursor_struct.errhp, OTL_RCAST(text*,cur_placeholder), OTL_SCAST(sb4,strlen(cur_placeholder)), OTL_RCAST(dvoid*,&sel_cur.get_cursor_struct().cda), 0, SQLT_RSET, 0, 0, 0, 0, 0, OTL_SCAST(ub4,OCI_DEFAULT)); if(rc!=0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception(cursor_struct, stm_label?stm_label:stm_text); } } // Executing the PLSQL master block exec(1,0,otl_sql_exec_from_select_cursor_class); sel_cur.set_connected(1); cur_row=-2; // Special case -- describe_select() before first() or next() desc_len=0; sel_cur.get_cursor_struct().straight_select=0; for(i=1;sel_cur.describe_column(desc[i-1],i);++i) ++desc_len; return 1; } public: otl_cursor sel_cur; protected: int rvl_len; otl_p_generic_variable* rvl; int vl_cur_len; char cur_placeholder[64]; void* master_stream_ptr_; private: otl_ref_cursor(const otl_ref_cursor&) :otl_tmpl_cursor (), cur_row(-1), cur_size(0), row_count(0), array_size(0), local_override(), sel_cur(), rvl_len(0), rvl(0), vl_cur_len(0), cur_placeholder(), master_stream_ptr_(0) { } otl_ref_cursor& operator=(const otl_ref_cursor&) { return *this; } }; class otl_ref_select_stream: public otl_ref_cursor{ protected: otl_select_struct_override *override; int delay_next; int same_sl_flag; long _rfc; public: void skip_to_end_of_row() { check_if_executed(); if(eof())return; while(cur_colcur_row); } ret_code=this->next(); cur_col=0; if(!eof()) cur_col=-1; ++_rfc; } int get_select_row_count() const { return this->cur_row==-1?0:this->cur_size-this->cur_row; } long get_rfc() const {return _rfc;} void cleanup(void) {int i; delete[] sl; for(i=0;iget_master_stream_ptr(), arr_size), override(0), delay_next(0), same_sl_flag(0), _rfc(0), sl_desc(0), sl_len(0), sl(0), null_fetched(0), ret_code(0), cur_col(0), cur_in(0), executed(0), var_info() { if(sqlstm_label!=0){ if(stm_label!=0){ delete[] stm_label; stm_label=0; } size_t len=strlen(sqlstm_label)+1; stm_label=new char[len]; OTL_STRCPY_S(stm_label,len,sqlstm_label); } init(); override=aoverride; { size_t len=strlen(sqlstm)+1; stm_text=new char[len]; OTL_STRCPY_S(stm_text,len,sqlstm); otl_select_struct_override* temp_local_override=&this->local_override; otl_ext_hv_decl hvd (this->stm_text, 1, this->stm_label, &temp_local_override, adb ); hvd.alloc_host_var_list(vl,vl_len,*adb); } try{ parse(); if(vl_len==0){ rewind(); null_fetched=0; } }catch(OTL_CONST_EXCEPTION otl_exception&){ cleanup(); if(this->adb)this->adb->increment_throw_count(); throw; } } virtual ~otl_ref_select_stream() { cleanup(); close(); } void rewind(void) { OTL_TRACE_STREAM_EXECUTION _rfc=0; get_select_list(); ret_code=first(); null_fetched=0; cur_col=-1; cur_in=0; executed=1; delay_next=0; } void clean(void) { _rfc=0; null_fetched=0; cur_col=-1; cur_in=0; executed=0; delay_next=0; } int is_null(void) { return null_fetched; } int eof(void) { if(delay_next){ look_ahead(); delay_next=0; } return !ret_code; } int eof_intern(void) { return !ret_code; } otl_ref_select_stream& operator>>(otl_time0& t) { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_timestamp)&&!eof_intern()){ #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) void* tm=OTL_RCAST(void*,sl[cur_col].val(this->cur_row)); int rc=sl[cur_col].get_var_struct().read_dt(&t,tm,sizeof(otl_time0)); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception(adb->get_connect_struct(), stm_label?stm_label:stm_text); } #else otl_time0* tm=OTL_RCAST(otl_time0*,sl[cur_col].val(cur_row)); memcpy(OTL_RCAST(void*,&t),tm,otl_oracle_date_size); #endif look_ahead(); } return *this; } otl_ref_select_stream& operator<<(const otl_time0& t) { check_in_var(); if(check_in_type(otl_var_timestamp,otl_oracle_date_size)){ #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) void* tm=OTL_RCAST(void*,vl[cur_in]->val()); int rc=vl[cur_in]->get_var_struct().write_dt(tm,&t,sizeof(otl_time0)); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception(adb->get_connect_struct(), stm_label?stm_label:stm_text); } #else otl_time0* tm=OTL_RCAST(otl_time0*,vl[cur_in]->val()); memcpy(tm,OTL_RCAST(void*,OTL_CCAST(otl_time0*,&t)),otl_oracle_date_size); #endif } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } otl_ref_select_stream& operator<<(const otl_long_string& s) { check_in_var(); if(check_in_type(otl_var_raw,1)){ unsigned char* c=OTL_RCAST(unsigned char*,vl[cur_in]->val()); int len=OTL_CCAST(otl_long_string*,&s)->len(); if(len>this->vl[cur_in]->actual_elem_size()){ otl_var_info_var (this->vl[cur_in]->get_name(), this->vl[cur_in]->get_ftype(), otl_var_raw, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception (otl_error_msg_5, otl_error_code_5, this->stm_label?this->stm_label: this->stm_text, var_info); } this->vl[cur_in]->set_not_null(0); otl_memcpy (c+sizeof(unsigned short), s.v, len, this->vl[cur_in]->get_ftype()); *OTL_RCAST(unsigned short*, this->vl[cur_in]->val(0))=OTL_SCAST(unsigned short,len); this->vl[cur_in]->set_len(len,0); } get_in_next(); return *this; } otl_ref_select_stream& operator>>(char& c) { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ c=*OTL_RCAST(char*,sl[cur_col].val(cur_row)); look_ahead(); } return *this; } otl_ref_select_stream& operator>>(unsigned char& c) { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ c=*OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); look_ahead(); } return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) otl_ref_select_stream& operator>>(OTL_STRING_CONTAINER& s) { check_if_executed(); if(eof_intern())return *this; get_next(); switch(sl[cur_col].get_ftype()){ case otl_var_char: if(!eof_intern()){ #if defined(OTL_ACE) s.set(OTL_RCAST(char*,sl[cur_col].val(cur_row)),1); #else s=OTL_RCAST(char*,sl[cur_col].val(cur_row)); #endif look_ahead(); } break; #if defined(USER_DEFINED_STRING_CLASS) || \ defined(OTL_STL) || defined(OTL_ACE) case otl_var_varchar_long: case otl_var_raw_long: if(!eof_intern()){ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); int len=sl[cur_col].get_len(cur_row); #if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE) s.assign(OTL_RCAST(char*,c),len); #elif defined(OTL_ACE) s.set(OTL_RCAST(char*,c),len,1); #endif look_ahead(); } break; case otl_var_blob: case otl_var_clob: if(!eof_intern()){ int len=0; int max_long_sz=this->adb->get_max_long_size(); otl_auto_array_ptr loc_ptr(max_long_sz); unsigned char* temp_buf=loc_ptr.get_ptr(); int rc=sl[cur_col].get_var_struct().get_blob (cur_row, temp_buf, max_long_sz, len); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception(adb->get_connect_struct(), stm_label?stm_label:stm_text); } #if (defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS)) && !defined(OTL_ACE) s.assign(OTL_RCAST(char*,temp_buf),len); #elif defined(OTL_ACE) s.set(OTL_RCAST(char*,temp_buf),len,1); #endif look_ahead(); } break; #endif default: check_type(otl_var_char); } // switch return *this; } #endif otl_ref_select_stream& operator>>(char* s) { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,sl[cur_col].val(cur_row))); look_ahead(); } return *this; } #if defined(OTL_UNICODE_STRING_TYPE) otl_ref_select_stream& operator>>(OTL_UNICODE_STRING_TYPE& s) { check_if_executed(); if(eof_intern())return *this; get_next(); switch(sl[cur_col].get_ftype()){ case otl_var_char: if(!eof_intern()){ #if defined(OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR) OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row)); OTL_UNICODE_STRING_TYPE_CAST_FROM_CHAR(s,temp_s+1,*temp_s); #else OTL_UNICODE_CHAR_TYPE* temp_s=OTL_RCAST (OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row)); s.assign(temp_s+1,*temp_s); #endif look_ahead(); } break; case otl_var_varchar_long: if(!eof_intern()){ s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,sl[cur_col].val(this->cur_row)); look_ahead(); } break; case otl_var_clob: if(!eof_intern()){ int len=0; int max_long_sz=this->adb->get_max_long_size(); otl_auto_array_ptr loc_ptr(max_long_sz); unsigned char* temp_buf=OTL_RCAST(unsigned char*,loc_ptr.get_ptr()); int rc=sl[cur_col].get_var_struct().get_blob (this->cur_row, temp_buf, max_long_sz, len); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception (this->adb->get_connect_struct(), this->stm_label?this->stm_label: this->stm_text); } s=OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,temp_buf); look_ahead(); } break; default: check_type(otl_var_char); } return *this; } #endif otl_ref_select_stream& operator>>(unsigned char* s) { check_if_executed(); if(eof_intern())return *this; get_next(); if(check_type(otl_var_char)&&!eof_intern()){ otl_strcpy2(OTL_RCAST(unsigned char*,s), OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)), sl[cur_col].get_len(cur_row) ); look_ahead(); } return *this; } #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) #define OTL_D7(T,T_type) \ otl_ref_select_stream& operator>>(T& n) \ { \ check_if_executed(); \ if(eof_intern())return *this; \ get_next(); \ if(!eof_intern()){ \ int match_found=otl_numeric_convert_T \ (sl[cur_col].get_ftype(), \ sl[cur_col].val(cur_row), \ n); \ if(!match_found) \ strict_check_throw(T_type); \ look_ahead(); \ } \ return *this; \ } #else #define OTL_D7(T,T_type) \ otl_ref_select_stream& operator>>(T& n) \ { \ check_if_executed(); \ if(eof_intern())return *this; \ get_next(); \ if(!eof_intern()){ \ int match_found=otl_numeric_convert_T \ (sl[cur_col].get_ftype(), \ sl[cur_col].val(cur_row), \ n); \ if(!match_found){ \ if(check_type(otl_var_double,T_type)) \ n=OTL_PCONV(T,double,sl[cur_col].val(cur_row)); \ } \ look_ahead(); \ } \ return *this; \ } #endif #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) OTL_D7(int,otl_var_int) OTL_D7(unsigned,otl_var_unsigned_int) OTL_D7(long,otl_var_long_int) OTL_D7(short,otl_var_short) OTL_D7(float,otl_var_float) OTL_D7(double,otl_var_double) #if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\ !defined(OTL_BIGINT_TO_STR)) OTL_D7(OTL_BIGINT,otl_var_bigint) #endif #else template OTL_D7(T,T_type) #endif otl_ref_select_stream& operator>>(otl_long_string& s) { check_if_executed(); if(eof_intern())return *this; get_next(); switch(sl[cur_col].get_ftype()){ case otl_var_varchar_long: case otl_var_raw_long: { if(!eof_intern()){ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); int len=sl[cur_col].get_len(cur_row); if(len>s.get_buf_size()) len=s.get_buf_size(); otl_memcpy(s.v,c,len,sl[cur_col].get_ftype()); s.v[len]=0; s.set_len(len); look_ahead(); } } break; case otl_var_raw: { if(!eof_intern()){ unsigned char* c=OTL_RCAST(unsigned char*,sl[cur_col].val(cur_row)); int len=OTL_SCAST(int,*OTL_RCAST(unsigned short*,c)); if(len>s.get_buf_size()) len=s.get_buf_size(); otl_memcpy(s.v,c+sizeof(short int),len,sl[cur_col].get_ftype()); s.set_len(len); look_ahead(); } } break; case otl_var_blob: case otl_var_clob: { if(!eof_intern()){ int len; int rc=sl[cur_col].get_var_struct().get_blob (cur_row,s.v,s.get_buf_size(),len); if(rc==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception(adb->get_connect_struct(), stm_label?stm_label:stm_text); } s.set_len(len); if(sl[cur_col].get_ftype()==otl_var_clob) s.null_terminate_string(len); look_ahead(); } } break; } return *this; } otl_ref_select_stream& operator>>(otl_lob_stream& s) { check_if_executed(); if(eof_intern())return *this; get_next(); if((sl[cur_col].get_ftype()==otl_var_blob|| sl[cur_col].get_ftype()==otl_var_clob)&& !eof_intern()){ s.init (&sl[cur_col], adb, OTL_RCAST(otl_ref_cursor*,this), cur_row, otl_lob_stream_read_mode, this->is_null()); delay_next=1; } return *this; } otl_ref_select_stream& operator<<(const otl_null& /*n*/) { check_in_var(); this->vl[cur_in]->set_null(0); get_in_next(); return *this; } otl_ref_select_stream& operator<<(const char c) { check_in_var(); if(check_in_type(otl_var_char,1)){ char* tmp=OTL_RCAST(char*,vl[cur_in]->val()); tmp[0]=c; tmp[1]=0; } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } otl_ref_select_stream& operator<<(const unsigned char c) { check_in_var(); if(check_in_type(otl_var_char,1)){ unsigned char* tmp=OTL_RCAST(unsigned char*,vl[cur_in]->val()); tmp[0]=c; tmp[1]=0; } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) otl_ref_select_stream& operator<<(const OTL_STRING_CONTAINER& s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy (OTL_RCAST(unsigned char*,vl[cur_in]->val()), OTL_RCAST(unsigned char*,OTL_CCAST(char*,s.c_str())), overflow, vl[cur_in]->get_elem_size(), OTL_SCAST(int,s.length()) ); if(overflow){ char temp_var_info[256]; otl_var_info_var (vl[cur_in]->get_name(), vl[cur_in]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception (otl_error_msg_4, otl_error_code_4, stm_label?stm_label:stm_text, temp_var_info); } } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } #endif #if defined(OTL_UNICODE_STRING_TYPE) otl_ref_select_stream& operator<<(const OTL_UNICODE_STRING_TYPE& s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy4 (OTL_RCAST(unsigned char*,vl[cur_in]->val()), OTL_RCAST(unsigned char*, OTL_CCAST(OTL_UNICODE_CHAR_TYPE*,s.c_str())), overflow, vl[cur_in]->get_elem_size(), OTL_SCAST(int,s.length()) ); if(overflow){ char temp_var_info[256]; otl_var_info_var (vl[cur_in]->get_name(), vl[cur_in]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count())return *this; if(otl_uncaught_exception()) return *this; throw otl_exception (otl_error_msg_4, otl_error_code_4, stm_label?stm_label:stm_text, temp_var_info); } } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } #endif otl_ref_select_stream& operator<<(const char* s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy (OTL_RCAST(unsigned char*,vl[cur_in]->val()), OTL_RCAST(unsigned char*,OTL_CCAST(char*,s)), overflow, vl[cur_in]->get_elem_size() ); if(overflow){ char temp_var_info[256]; otl_var_info_var (vl[cur_in]->get_name(), vl[cur_in]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception (otl_error_msg_4, otl_error_code_4, stm_label?stm_label:stm_text, temp_var_info); } } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } otl_ref_select_stream& operator<<(const unsigned char* s) { check_in_var(); if(check_in_type(otl_var_char,1)){ int overflow; otl_strcpy4 (OTL_RCAST(unsigned char*,vl[cur_in]->val()), OTL_CCAST(unsigned char*,s), overflow, vl[cur_in]->get_elem_size() ); if(overflow){ char temp_var_info[256]; otl_var_info_var (vl[cur_in]->get_name(), vl[cur_in]->get_ftype(), otl_var_char, temp_var_info, sizeof(temp_var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return *this; if(otl_uncaught_exception()) return *this; throw otl_exception (otl_error_msg_4, otl_error_code_4, stm_label?stm_label:stm_text, temp_var_info); } } this->vl[cur_in]->set_not_null(0); get_in_next(); return *this; } #define OTL_D8(T,T_type) \ otl_ref_select_stream& operator<<(const T n) \ { \ check_in_var(); \ if(check_in_type(T_type,sizeof(T))){ \ *OTL_RCAST(T*,vl[cur_in]->val())=n; \ } \ this->vl[cur_in]->set_not_null(0); \ get_in_next(); \ return *this; \ } #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) OTL_D8(int,otl_var_int) OTL_D8(unsigned,otl_var_unsigned_int) OTL_D8(long,otl_var_long_int) OTL_D8(short,otl_var_short) OTL_D8(float,otl_var_float) OTL_D8(double,otl_var_double) #if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\ !defined(OTL_BIGINT_TO_STR)) OTL_D8(OTL_BIGINT,otl_var_bigint) #endif #else template OTL_D8(T,T_type) #endif int select_list_len(void) const { return sl_len; } int column_ftype(int ndx=0) const { return sl[ndx].get_ftype(); } int column_size(int ndx=0) const { return sl[ndx].get_elem_size(); } int get_sl_len() const {return sl_len; } otl_generic_variable* get_sl() const {return sl;} otl_column_desc* get_sl_desc() const {return sl_desc;} protected: otl_column_desc* sl_desc; int sl_len; otl_generic_variable* sl; int null_fetched; int ret_code; int cur_col; int cur_in; int executed; char var_info[256]; void init(void) { same_sl_flag=0; sl=0; sl_len=0; null_fetched=0; ret_code=0; sl_desc=0; executed=0; cur_in=0; stm_text=0; } void get_next(void) { if(cur_coladb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception (otl_error_msg_0, otl_error_code_0, stm_label?stm_label:stm_text, var_info); } int check_type(int type_code, int actual_data_type=0) { switch(sl[cur_col].get_ftype()){ case otl_var_timestamp: case otl_var_tz_timestamp: case otl_var_ltz_timestamp: if(type_code==otl_var_timestamp) return 1; default: if(sl[cur_col].get_ftype()==type_code) return 1; } return check_type_throw(type_code,actual_data_type); } void look_ahead(void) { if(cur_col==sl_len-1){ ret_code=next(); cur_col=-1; ++_rfc; } } void get_select_list(void) {int i,j,rc; otl_auto_array_ptr loc_ptr(otl_var_list_size); otl_column_desc* sl_desc_tmp=loc_ptr.get_ptr(); int sld_tmp_len=0; int ftype,elem_size; OCIBind* bindpp; if(!sel_cur.get_connected()){ sel_cur.open(*adb); rc=OCIBindByName (cursor_struct.cda, &bindpp, cursor_struct.errhp, OTL_RCAST(text*,cur_placeholder), OTL_SCAST(sb4,strlen(cur_placeholder)), OTL_RCAST(dvoid*,&sel_cur.get_cursor_struct().cda), 0, SQLT_RSET, 0, 0, 0, 0, 0, OTL_SCAST(ub4,OCI_DEFAULT)); if(rc!=0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception(cursor_struct, stm_label?stm_label:stm_text); } } for(i=0;i::bind(*vl[i]); // Executing the PLSQL master block otl_tmpl_cursor ::exec(1,0,otl_sql_exec_from_select_cursor_class); sel_cur.set_connected(1); cur_row=-2; if(same_sl_flag && sl){ // assuming that ref.cur's select list is the same as // in previous executions of the master block. for(i=0;iadb->get_max_long_size(); for(j=0;jlocal_override.getLen()>0?this->local_override:*override, j+1, this->adb->get_connect_struct().get_connection_type()); sl[j].copy_pos(j+1); #if defined(OTL_ORA_UNICODE)||defined(OTL_ORA_UTF8) if(sl_desc_tmp[j].charset_form==2) sl[j].get_var_struct().nls_flag=true; #endif sl[j].init(true, ftype, elem_size, OTL_SCAST(otl_stream_buffer_size_type,array_size), &adb->get_connect_struct() ); } if(sl_desc){ delete[] sl_desc; sl_desc=0; } sl_desc=new otl_column_desc[sl_len==0?1:sl_len]; for(i=0;iget_name(), vl[cur_in]->get_ftype(), type_code, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return 0; if(otl_uncaught_exception()) return 0; throw otl_exception (otl_error_msg_0, otl_error_code_0, stm_label?stm_label:stm_text, var_info); } int check_in_type(int type_code,int tsize) { switch(vl[cur_in]->get_ftype()){ case otl_var_char: if(type_code==otl_var_char) return 1; case otl_var_raw: if(type_code==otl_var_raw) return 1; case otl_var_timestamp: case otl_var_tz_timestamp: case otl_var_ltz_timestamp: if(type_code==otl_var_timestamp) return 1; default: if(vl[cur_in]->get_ftype()==type_code && vl[cur_in]->get_elem_size()==tsize) return 1; } return check_in_type_throw(type_code); } void check_in_var(void) { if(vl_len==0){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception (otl_error_msg_1, otl_error_code_1, stm_label?stm_label:stm_text, 0); } } void check_if_executed(void) { if(!executed){ if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception (otl_error_msg_2, otl_error_code_2, stm_label?stm_label:stm_text, 0); } } #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) void strict_check_throw(int type_code) { otl_var_info_col (sl[cur_col].get_pos(), sl[cur_col].get_ftype(), type_code, var_info, sizeof(var_info)); if(this->adb)this->adb->increment_throw_count(); if(this->adb&&this->adb->get_throw_count()>1)return; if(otl_uncaught_exception()) return; throw otl_exception (otl_error_msg_0, otl_error_code_0, this->stm_label? this->stm_label: this->stm_text, var_info); } #endif private: otl_ref_select_stream (const otl_ref_select_stream&) :otl_ref_cursor(), override(0), delay_next(0), same_sl_flag(0), _rfc(0), sl_desc(0), sl_len(0), sl(0), null_fetched(0), ret_code(0), cur_col(0), cur_in(0), executed(0), var_info() { } otl_ref_select_stream& operator=(const otl_ref_select_stream&) { return *this; } }; class otl_stream_shell: public otl_stream_shell_generic{ public: otl_ref_select_stream* ref_ss; otl_select_stream* ss; otl_inout_stream* io; otl_connect* adb; int auto_commit_flag; bool lob_stream_flag; otl_var_desc* iov; int iov_len; int next_iov_ndx; otl_var_desc* ov; int ov_len; int next_ov_ndx; bool flush_flag; int stream_type; otl_select_struct_override override; #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) OTL_STRING_CONTAINER orig_sql_stm; #endif otl_stream_shell(): otl_stream_shell_generic(), ref_ss(0), ss(0), io(0), adb(0), auto_commit_flag(0), lob_stream_flag(false), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), flush_flag(false), stream_type(otl_no_stream_type), override() #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) ,orig_sql_stm() #endif { should_delete=0; } otl_stream_shell(const int ashould_delete): otl_stream_shell_generic(), ref_ss(0), ss(0), io(0), adb(0), auto_commit_flag(0), lob_stream_flag(false), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), flush_flag(true), stream_type(otl_no_stream_type), override() #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) ,orig_sql_stm() #endif { should_delete=ashould_delete; } virtual ~otl_stream_shell() { if(should_delete){ delete[] iov; delete[] ov; iov=0; iov_len=0; ov=0; ov_len=0; next_iov_ndx=0; next_ov_ndx=0; override.setLen(0); flush_flag=true; delete ss; delete io; delete ref_ss; ss=0; io=0; ref_ss=0; adb=0; } } private: otl_stream_shell(const otl_stream_shell&): otl_stream_shell_generic(), ref_ss(0), ss(0), io(0), adb(0), auto_commit_flag(0), lob_stream_flag(false), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), flush_flag(false), stream_type(otl_no_stream_type), override() #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) ,orig_sql_stm() #endif { } otl_stream_shell& operator=(const otl_stream_shell&) { return *this; } }; class otl_sp_parm_desc{ public: int position; char arg_name[40]; char in_out[20]; char data_type[40]; char bind_var[128]; otl_sp_parm_desc(): position(-1), arg_name(), in_out(), data_type(), bind_var() { arg_name[0]=0; in_out[0]=0; data_type[0]=0; bind_var[0]=0; } otl_sp_parm_desc(const otl_sp_parm_desc& r): position(-1), arg_name(), in_out(), data_type(), bind_var() { copy(r); } otl_sp_parm_desc& operator=(const otl_sp_parm_desc& r) { copy(r); return *this; } ~otl_sp_parm_desc(){} protected: void copy(const otl_sp_parm_desc& r) { position=r.position; OTL_STRCPY_S(arg_name,sizeof(arg_name),r.arg_name); OTL_STRCPY_S(in_out,sizeof(in_out),r.in_out); OTL_STRCPY_S(data_type,sizeof(data_type),r.data_type); OTL_STRCPY_S(bind_var,sizeof(bind_var),r.bind_var); } }; class otl_stream #if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE) : public otl_read_stream_interface #endif { protected: otl_stream_shell* shell; otl_ptr shell_pt; int connected; otl_ref_select_stream** ref_ss; otl_select_stream** ss; otl_inout_stream** io; otl_connect** adb; int* auto_commit_flag; otl_var_desc** iov; int* iov_len; int* next_iov_ndx; otl_var_desc** ov; int* ov_len; int* next_ov_ndx; int end_marker; int oper_int_called; int last_eof_rc; bool last_oper_was_read_op; otl_select_struct_override* override; int buf_size_; void reset_end_marker(void) { last_eof_rc=0; end_marker=-1; oper_int_called=0; } static void convert_bind_var_datatype (char* out_buf, #if defined(_MSC_VER) #if (_MSC_VER >= 1400) // VC++ 8.0 or higher const size_t out_buf_sz, #else const size_t /*out_buf_sz*/, #endif #else const size_t /*out_buf_sz*/, #endif const char* datatype, const int varchar_size, const int all_num2type, const int refcur_buf_size) { out_buf[0]=0; if(strcmp(datatype,"BINARY_INTEGER")==0|| strcmp(datatype,"NATIVE INTEGER")==0|| strcmp(datatype,"FLOAT")==0|| strcmp(datatype,"NUMBER")==0){ switch(all_num2type){ case otl_var_char: OTL_STRCPY_S(out_buf,out_buf_sz,"char[50]"); break; case otl_var_double: OTL_STRCPY_S(out_buf,out_buf_sz,"double"); break; case otl_var_float: OTL_STRCPY_S(out_buf,out_buf_sz,"float"); break; case otl_var_long_int: OTL_STRCPY_S(out_buf,out_buf_sz,"long"); break; case otl_var_int: OTL_STRCPY_S(out_buf,out_buf_sz,"int"); break; case otl_var_unsigned_int: OTL_STRCPY_S(out_buf,out_buf_sz,"unsigned"); break; case otl_var_short: OTL_STRCPY_S(out_buf,out_buf_sz,"short"); break; default: break; } }else if(strcmp(datatype,"DATE")==0) OTL_STRCPY_S(out_buf,out_buf_sz,"timestamp"); #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) else if(strcmp(datatype,"TIMESTAMP")==0) OTL_STRCPY_S(out_buf,out_buf_sz,"timestamp"); #endif else if(strcmp(datatype,"VARCHAR2")==0) #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(out_buf,out_buf_sz,"char[%d]",varchar_size); #else sprintf(out_buf,"char[%d]",varchar_size); #endif #else sprintf(out_buf,"char[%d]",varchar_size); #endif else if(strcmp(datatype,"CHAR")==0) #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(out_buf,out_buf_sz,"char[%d]",varchar_size); #else sprintf(out_buf,"char[%d]",varchar_size); #endif #else sprintf(out_buf,"char[%d]",varchar_size); #endif else if(strcmp(datatype,"REF CURSOR")==0) #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(out_buf,out_buf_sz,"refcur,out[%d]",refcur_buf_size); #else sprintf(out_buf,"refcur,out[%d]",refcur_buf_size); #endif #else sprintf(out_buf,"refcur,out[%d]",refcur_buf_size); #endif } void throw_end_of_row() #if defined(__GNUC__) && (__GNUC__>=4) __attribute__ ((noreturn)) #endif { throw otl_exception (otl_error_msg_34, otl_error_code_34, this->get_stm_text()); } public: bool get_lob_stream_flag() const { if(!shell) return false; else return shell->lob_stream_flag; } int get_adb_max_long_size() const { return this->shell->adb->get_max_long_size(); } void check_end_of_row() { if(next_ov_ndx==0||(*next_ov_ndx)!=0) throw_end_of_row(); if(next_iov_ndx==0||(*next_iov_ndx)!=0) throw_end_of_row(); } int get_dirty_buf_len() const { switch(shell->stream_type){ case otl_no_stream_type: return 0; case otl_inout_stream_type: return (*io)->get_dirty_buf_len(); case otl_select_stream_type: return (*ss)->get_select_row_count(); case otl_refcur_stream_type: return (*ref_ss)->get_select_row_count(); default: return 0; } } otl_stream_shell* get_shell(){return shell;} int get_connected() const {return connected;} void setBufSize(int buf_size) { buf_size_=buf_size; } int getBufSize(void) const { return buf_size_; } operator int(void) OTL_THROWS_OTL_EXCEPTION { if(shell && shell->lob_stream_flag){ if(this->adb&&*this->adb)(*this->adb)->increment_throw_count(); if(this->adb&&*this->adb&&(*this->adb)->get_throw_count()>1)return 0; const char* stm_label=0; const char* stm_text=0; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: stm_label=(*io)->get_stm_label(); stm_text=(*io)->get_stm_text(); break; case otl_select_stream_type: stm_label=(*ss)->get_stm_label(); stm_text=(*ss)->get_stm_text(); break; case otl_refcur_stream_type: stm_label=(*ref_ss)->get_stm_label(); stm_text=(*ref_ss)->get_stm_text(); break; } throw otl_exception (otl_error_msg_24, otl_error_code_24, stm_label?stm_label:stm_text); } if(!last_oper_was_read_op){ if(this->adb&&*this->adb)(*this->adb)->increment_throw_count(); if(this->adb&&*this->adb&&(*this->adb)->get_throw_count()>1)return 0; const char* stm_label=0; const char* stm_text=0; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: stm_label=(*io)->get_stm_label(); stm_text=(*io)->get_stm_text(); break; case otl_select_stream_type: stm_label=(*ss)->get_stm_label(); stm_text=(*ss)->get_stm_text(); break; case otl_refcur_stream_type: stm_label=(*ref_ss)->get_stm_label(); stm_text=(*ref_ss)->get_stm_text(); break; } throw otl_exception (otl_error_msg_18, otl_error_code_18, stm_label?stm_label:stm_text); } if(end_marker==1)return 0; int rc=0; int temp_eof=eof(); if(temp_eof && end_marker==-1 && oper_int_called==0){ end_marker=1; if(last_eof_rc==1) rc=0; else rc=1; }else if(!temp_eof && end_marker==-1) rc=1; else if(temp_eof && end_marker==-1){ end_marker=0; rc=1; }else if(temp_eof && end_marker==0){ end_marker=1; rc=0; } if(!oper_int_called)oper_int_called=1; return rc; } #if !defined(OTL_UNICODE) static void create_stored_proc_call (otl_connect& db, otl_stream& args_strm, char* sql_stm, int& stm_type, char* refcur_placeholder, const char* proc_name, const char* package_name, const char* schema_name=0, const bool schema_name_included=false, const int varchar_size=2001, const int all_num2type=otl_var_double, const int refcur_buf_size=1) { sql_stm[0]=0; stm_type=otl_no_stream_type; refcur_placeholder[0]=0; char full_name[1024]; char temp_buf[1024]; char temp_buf2[1024]; int i; if(package_name==0) #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(full_name,sizeof(full_name),"%s",proc_name); #else sprintf(full_name,"%s",proc_name); #endif #else sprintf(full_name,"%s",proc_name); #endif else #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(full_name,sizeof(full_name),"%s.%s",package_name,proc_name); #else sprintf(full_name,"%s.%s",package_name,proc_name); #endif #else sprintf(full_name,"%s.%s",package_name,proc_name); #endif if(schema_name_included&&schema_name!=0){ #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf,sizeof(temp_buf),"%s.%s",schema_name,full_name); #else sprintf(temp_buf,"%s.%s",schema_name,full_name); #endif #else sprintf(temp_buf,"%s.%s",schema_name,full_name); #endif OTL_STRCPY_S(full_name,sizeof(full_name),temp_buf); } if(!args_strm.good()){ args_strm.open (50, "select position, " " lower(':'||nvl(argument_name,'rc__')) argument_name, " " in_out, " " nvl(data_type,'*') data_type, " " ':'||lower(nvl(argument_name,'rc__'))|| " " decode(data_type,'REF CURSOR',' ', " " '<'||'%s,'|| " " decode(in_out,'IN','in', " " 'OUT','out', " " 'IN/OUT','inout', " " 'xxx') " " ||'>' " " ) || decode(position,0,' := ',' ') " " bind_var " "from all_arguments " "where object_name=upper(:obj_name) " " and (:pkg_name is null and package_name is null or " " :pkg_name is not null " " and (package_name=upper(:pkg_name) " " or package_name = " " (select package_name from " " (select table_name as package_name " " from user_synonyms " " where synonym_name=upper(:pkg_name) " " union all " " select table_name as package_name " " from all_synonyms " " where synonym_name=upper(:pkg_name) " " )" " where rownum = 1)" " )) " " and ((:owner is null " " and owner= " " (select owner from " " (select user as owner " " from user_objects " " where (:pkg_name is not null " " and object_name = upper(:pkg_name) " " and object_type = 'PACKAGE') " " or (:pkg_name is null " " and object_name = upper(:obj_name) " " and object_type in ('FUNCTION','PROCEDURE')) " " union all " " select table_owner as owner " " from user_synonyms " " where (:pkg_name is not null " " and synonym_name = upper(:pkg_name)) " " or (:pkg_name is null " " and synonym_name = upper(:obj_name)) " " union all " " select table_owner as owner " " from all_synonyms " " where (:pkg_name is not null " " and synonym_name = upper(:pkg_name)) " " or (:pkg_name is null " " and synonym_name = upper(:obj_name)) " " ) " " where rownum = 1) " " or " " (:owner is not null and owner=upper(:owner))) " " and data_level=0 )" "order by position", db); } otl_auto_array_ptr< otl_Tptr > desc(otl_var_list_size); int desc_len=0; otl_sp_parm_desc parm; args_strm<>parm.position; args_strm>>parm.arg_name; args_strm>>parm.in_out; args_strm>>parm.data_type; args_strm>>parm.bind_var; ++desc_len; if(desc_len==desc.get_arr_size()){ int j; for(j=0;j= 1400) sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s",full_name); #else sprintf(temp_buf,"procedure %s",full_name); #endif #else sprintf(temp_buf,"procedure %s",full_name); #endif { // last ditch attemp to identify a global SP with no parms bool global_sp_no_parms=false; if(schema_name==0){ // schema name is not specified otl_stream s2 (1, "select 1 cnt " "from user_procedures " "where object_name=UPPER(:obj_name) " " and procedure_name is null " " and object_type='PROCEDURE' " "union all " "select 1 cnt " "from user_synonyms syn " "where syn.synonym_name=UPPER(:obj_name) " " and exists " " (select 'x' " " from all_procedures proc " " where proc.owner=syn.table_owner " " and proc.object_name=syn.table_name) " "union all " "select 1 cnt " "from all_synonyms syn " "where syn.synonym_name=UPPER(:obj_name) " " and syn.owner='PUBLIC' " " and exists " " (select 'x' " " from all_procedures proc " " where proc.owner=syn.table_owner " " and proc.object_name=syn.table_name)", db); s2<) " " and procedure_name is null " " and object_type='PROCEDURE' " " AND owner=UPPER(:owner) " "union all " "select synonym_name " "from all_synonyms syn " "where syn.synonym_name=UPPER(:obj_name) " " AND syn.owner=UPPER(:owner) " " and exists " " (select 'x' " " from all_procedures proc " " where proc.owner=syn.table_owner " " and proc.object_name=syn.table_name)", db); s2<position==1 && desc.get_ptr()[0].get_ptr()->data_type[0]=='*'){ // procedure without any parameters otl_strcat(sql_stm,"BEGIN "); otl_strcat(sql_stm,full_name); otl_strcat(sql_stm,"; END;"); stm_type=otl_constant_sql_type; return; }if(desc.get_ptr()[0].get_ptr()->position==1 && desc.get_ptr()[0].get_ptr()->data_type[0]!='*'){ // procedure with one parameter if(strcmp(desc.get_ptr()[0].get_ptr()->data_type,"REF CURSOR")==0){ // procedure with one parameter of refcur type if(strcmp(desc.get_ptr()[0].get_ptr()->in_out,"IN")==0){ // refcur parameter should be either OUT or IN OUT, not IN. #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s",full_name); #else sprintf(temp_buf,"procedure %s",full_name); #endif #else sprintf(temp_buf,"procedure %s",full_name); #endif throw otl_exception (otl_error_msg_15, otl_error_code_15, temp_buf,0); } otl_strcat(sql_stm,"BEGIN "); otl_strcat(sql_stm,full_name); otl_strcat(sql_stm,"("); otl_strcat(sql_stm,desc.get_ptr()[0].get_ptr()->bind_var); otl_strcat(sql_stm,"); END;"); stm_type=otl_refcur_stream_type; otl_strcpy(OTL_RCAST(unsigned char*,refcur_placeholder), OTL_RCAST(const unsigned char*,desc.get_ptr()[0].get_ptr()->arg_name)); return; }else{ // procedure with one scalar parameter convert_bind_var_datatype (temp_buf,sizeof(temp_buf),desc.get_ptr()[0].get_ptr()->data_type, varchar_size,all_num2type,refcur_buf_size); if(temp_buf[0]==0){ #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s, parameter %s", full_name,desc.get_ptr()[0].get_ptr()->arg_name); #else sprintf(temp_buf,"procedure %s, parameter %s", full_name,desc.get_ptr()[0].get_ptr()->arg_name); #endif #else sprintf(temp_buf,"procedure %s, parameter %s", full_name,desc.get_ptr()[0].get_ptr()->arg_name); #endif throw otl_exception (otl_error_msg_14, otl_error_code_14, temp_buf,0); } #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[0].get_ptr()->bind_var,temp_buf); #else sprintf(temp_buf2,desc.get_ptr()[0].get_ptr()->bind_var,temp_buf); #endif #else sprintf(temp_buf2,desc.get_ptr()[0].get_ptr()->bind_var,temp_buf); #endif otl_strcat(sql_stm,"BEGIN "); otl_strcat(sql_stm,full_name); otl_strcat(sql_stm,"("); otl_strcat(sql_stm,temp_buf2); otl_strcat(sql_stm,"); END;"); stm_type=otl_inout_stream_type; refcur_placeholder[0]=0; return; } }else if(desc.get_ptr()[0].get_ptr()->position==0){ if(strcmp(desc.get_ptr()[0].get_ptr()->data_type,"REF CURSOR")==0){ // refcur function without any parameters otl_strcat(sql_stm,"BEGIN "); otl_strcat(sql_stm,desc.get_ptr()[0].get_ptr()->bind_var); otl_strcat(sql_stm," "); otl_strcat(sql_stm,full_name); otl_strcat(sql_stm,"; END;"); stm_type=otl_refcur_stream_type; otl_strcpy(OTL_RCAST(unsigned char*,refcur_placeholder), OTL_RCAST(const unsigned char*,desc.get_ptr()[0].get_ptr()->arg_name)); return; }else{ // scalar function without any parameters convert_bind_var_datatype (temp_buf,sizeof(temp_buf),desc.get_ptr()[0].get_ptr()->data_type, varchar_size,all_num2type,refcur_buf_size); if(temp_buf[0]==0){ #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf,sizeof(temp_buf), "procedure %s, parameter %s", full_name, desc.get_ptr()[0].get_ptr()->arg_name); #else sprintf(temp_buf, "procedure %s, parameter %s", full_name, desc.get_ptr()[0].get_ptr()->arg_name); #endif #else sprintf(temp_buf, "procedure %s, parameter %s", full_name, desc.get_ptr()[0].get_ptr()->arg_name); #endif throw otl_exception (otl_error_msg_14, otl_error_code_14, temp_buf,0); } #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[0].get_ptr()->bind_var,temp_buf); #else sprintf(temp_buf2,desc.get_ptr()[0].get_ptr()->bind_var,temp_buf); #endif #else sprintf(temp_buf2,desc.get_ptr()[0].get_ptr()->bind_var,temp_buf); #endif otl_strcat(sql_stm,"BEGIN "); otl_strcat(sql_stm,temp_buf2); otl_strcat(sql_stm," "); otl_strcat(sql_stm,full_name); otl_strcat(sql_stm,"; END;"); stm_type=otl_inout_stream_type; refcur_placeholder[0]=0; return; } } } // Checking if the procedure is of the "refcur" type bool refcur_flag=false; bool refcur_outpar=false; int refcur_count=0; bool inpar_only=true; for(i=0;iin_out,"IN")!=0 && strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")!=0) inpar_only=false; if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0){ ++refcur_count; refcur_flag=true; if(refcur_count>1){ if(refcur_outpar) refcur_outpar=strcmp(desc.get_ptr()[i].get_ptr()->in_out,"IN")!=0; }else refcur_outpar=strcmp(desc.get_ptr()[i].get_ptr()->in_out,"IN")!=0; } } if(refcur_flag){ if(!refcur_outpar){ #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s",full_name); #else sprintf(temp_buf,"procedure %s",full_name); #endif #else sprintf(temp_buf,"procedure %s",full_name); #endif throw otl_exception (otl_error_msg_15, otl_error_code_15, temp_buf,0); } stm_type=otl_refcur_stream_type; if(!inpar_only||refcur_count>1) stm_type=otl_mixed_refcur_stream_type; refcur_placeholder[0]=0; sql_stm[0]=0; bool full_name_printed=false; for(i=0;idata_type,"REF CURSOR")==0) otl_strcpy(OTL_RCAST(unsigned char*,refcur_placeholder), OTL_RCAST(const unsigned char*,desc.get_ptr()[i].get_ptr()->arg_name)); } // in case of a function, function's return code if(desc.get_ptr()[i].get_ptr()->position==0){ convert_bind_var_datatype (temp_buf,sizeof(temp_buf),desc.get_ptr()[i].get_ptr()->data_type, varchar_size,all_num2type,refcur_buf_size); if(temp_buf[0]==0&& strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")!=0){ #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #else sprintf(temp_buf,"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #endif #else sprintf(temp_buf,"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #endif throw otl_exception (otl_error_msg_14, otl_error_code_14, temp_buf,0); } if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0&& stm_type==otl_refcur_stream_type) OTL_STRCPY_S(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var); else if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0&& stm_type==otl_mixed_refcur_stream_type){ desc.get_ptr()[i].get_ptr()->bind_var[strlen(desc.get_ptr()[i].get_ptr()->bind_var)-5]=0; #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf2,sizeof(temp_buf2), "%s<%s> := ", desc.get_ptr()[i].get_ptr()->bind_var, temp_buf); #else sprintf(temp_buf2, "%s<%s> := ", desc.get_ptr()[i].get_ptr()->bind_var, temp_buf); #endif #else sprintf(temp_buf2, "%s<%s> := ", desc.get_ptr()[i].get_ptr()->bind_var, temp_buf); #endif }else #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #else sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #endif #else sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #endif otl_strcat(sql_stm,temp_buf2); } // procedure/function's name if(!full_name_printed){ otl_strcat(sql_stm,full_name); otl_strcat(sql_stm,"("); full_name_printed=true; } if(desc.get_ptr()[i].get_ptr()->position!=0){ // normal parameters convert_bind_var_datatype (temp_buf,sizeof(temp_buf),desc.get_ptr()[i].get_ptr()->data_type, varchar_size,all_num2type,refcur_buf_size); if(temp_buf[0]==0&& strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")!=0){ #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #else sprintf(temp_buf,"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #endif #else sprintf(temp_buf,"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #endif throw otl_exception (otl_error_msg_14, otl_error_code_14, temp_buf,0); } if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0&& stm_type==otl_refcur_stream_type) OTL_STRCPY_S(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var); else if(strcmp(desc.get_ptr()[i].get_ptr()->data_type,"REF CURSOR")==0&& stm_type==otl_mixed_refcur_stream_type){ desc.get_ptr()[i].get_ptr()->bind_var[strlen(desc.get_ptr()[i].get_ptr()->bind_var)-2]=0; #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf2,sizeof(temp_buf2), "%s<%s>", desc.get_ptr()[i].get_ptr()->bind_var, temp_buf); #else sprintf(temp_buf2, "%s<%s>", desc.get_ptr()[i].get_ptr()->bind_var, temp_buf); #endif #else sprintf(temp_buf2, "%s<%s>", desc.get_ptr()[i].get_ptr()->bind_var, temp_buf); #endif }else #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #else sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #endif #else sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #endif otl_strcat(sql_stm,temp_buf2); } if(iposition!=0) otl_strcat(sql_stm,","); else if(i==desc_len-1) otl_strcat(sql_stm,"); "); } otl_strcat(sql_stm," END;"); return; } // The procedure is of the "general" type stm_type=otl_inout_stream_type; refcur_placeholder[0]=0; sql_stm[0]=0; bool full_name_printed=false; for(i=0;iposition==0){ convert_bind_var_datatype (temp_buf,sizeof(temp_buf),desc.get_ptr()[i].get_ptr()->data_type, varchar_size,all_num2type,refcur_buf_size); if(temp_buf[0]==0){ #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #else sprintf(temp_buf,"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #endif #else sprintf(temp_buf,"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #endif throw otl_exception (otl_error_msg_14, otl_error_code_14, temp_buf,0); } #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #else sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #endif #else sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #endif otl_strcat(sql_stm,temp_buf2); } // procedure/function's name if(!full_name_printed){ otl_strcat(sql_stm,full_name); otl_strcat(sql_stm,"("); full_name_printed=true; } if(desc.get_ptr()[i].get_ptr()->position!=0){ // normal parameters convert_bind_var_datatype (temp_buf,sizeof(temp_buf),desc.get_ptr()[i].get_ptr()->data_type, varchar_size,all_num2type,refcur_buf_size); if(temp_buf[0]==0){ #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf,sizeof(temp_buf),"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #else sprintf(temp_buf,"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #endif #else sprintf(temp_buf,"procedure %s, parameter %s", full_name,desc.get_ptr()[i].get_ptr()->arg_name); #endif throw otl_exception (otl_error_msg_14, otl_error_code_14, temp_buf,0); } #if defined(_MSC_VER) #if (_MSC_VER >= 1400) sprintf_s(temp_buf2,sizeof(temp_buf2),desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #else sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #endif #else sprintf(temp_buf2,desc.get_ptr()[i].get_ptr()->bind_var,temp_buf); #endif otl_strcat(sql_stm,temp_buf2); } if(iposition!=0) otl_strcat(sql_stm,","); else if(i==desc_len-1) otl_strcat(sql_stm,"); "); } otl_strcat(sql_stm," END;"); } #endif int get_stream_type(void) OTL_NO_THROW { if(shell==0) return otl_no_stream_type; else return shell->stream_type; } void set_column_type(const int column_ndx, const int col_type, const int col_size=0) OTL_NO_THROW { if(shell==0){ init_stream(); shell->flush_flag=true; } override->add_override(column_ndx,col_type,col_size); } void set_all_column_types(const unsigned mask=0) OTL_NO_THROW { if(shell==0){ init_stream(); shell->flush_flag=true; } override->set_all_column_types(mask); } void set_flush(const bool flush_flag=true) OTL_NO_THROW { if(shell==0)init_stream(); shell->flush_flag=flush_flag; } void set_lob_stream_mode(const bool lob_stream_flag=false) OTL_NO_THROW { if(shell==0)return; shell->lob_stream_flag=lob_stream_flag; } void inc_next_ov(void) { if((*ov_len)==0)return; if((*next_ov_ndx)<(*ov_len)-1) ++(*next_ov_ndx); else (*next_ov_ndx)=0; } void inc_next_iov(void) { if((*iov_len)==0)return; if((*next_iov_ndx)<(*iov_len)-1) ++(*next_iov_ndx); else (*next_iov_ndx)=0; } otl_var_desc* describe_in_vars(int& desc_len) OTL_NO_THROW { desc_len=0; if(shell==0)return 0; if(shell->iov==0)return 0; desc_len=shell->iov_len; return shell->iov; } otl_var_desc* describe_out_vars(int& desc_len) OTL_NO_THROW { desc_len=0; if(shell==0)return 0; if(shell->ov==0)return 0; desc_len=shell->ov_len; return shell->ov; } otl_var_desc* describe_next_in_var(void) OTL_NO_THROW { if(shell==0)return 0; if(shell->iov==0)return 0; return &(shell->iov[shell->next_iov_ndx]); } otl_var_desc* describe_next_out_var(void) OTL_NO_THROW { if(shell==0)return 0; if(shell->ov==0)return 0; return &(shell->ov[shell->next_ov_ndx]); } const char* get_stm_text(void) { const char* no_stm_text=OTL_NO_STM_TEXT; switch(shell->stream_type){ case otl_no_stream_type: return no_stm_text; case otl_inout_stream_type: return (*io)->get_stm_label()?(*io)->get_stm_label():(*io)->get_stm_text(); case otl_select_stream_type: return (*ss)->get_stm_label()?(*ss)->get_stm_label():(*ss)->get_stm_text(); case otl_refcur_stream_type: return (*ref_ss)->get_stm_label()? (*ref_ss)->get_stm_label():(*ref_ss)->get_stm_text(); default: return no_stm_text; } } long get_rpc() OTL_THROWS_OTL_EXCEPTION { switch(shell->stream_type){ case otl_no_stream_type: return 0; case otl_inout_stream_type: (*adb)->reset_throw_count(); return (*io)->get_rpc(); case otl_select_stream_type: (*adb)->reset_throw_count(); return (*ss)->get_rfc(); case otl_refcur_stream_type: (*adb)->reset_throw_count(); return (*ref_ss)->get_rfc(); default: return 0; } } void create_var_desc(void) {int i; delete[] (*iov); delete[] (*ov); (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; if((*ss)){ if((*ss)->get_vl_len()>0){ (*iov)=new otl_var_desc[(*ss)->get_vl_len()]; (*iov_len)=(*ss)->get_vl_len(); for(i=0;i<(*ss)->get_vl_len();++i) (*ss)->get_vl()[i]->copy_var_desc((*iov)[i]); } if((*ss)->get_sl_len()>0){ (*ov)=new otl_var_desc[(*ss)->get_sl_len()]; (*ov_len)=(*ss)->get_sl_len(); for(i=0;i<(*ss)->get_sl_len();++i){ (*ss)->get_sl()[i].copy_var_desc((*ov)[i]); (*ov)[i].copy_name((*ss)->get_sl_desc()[i].name); } } }else if((*io)){ if((*io)->get_vl_len()>0){ (*iov)=new otl_var_desc[(*io)->get_vl_len()]; (*iov_len)=(*io)->get_vl_len(); for(i=0;i<(*io)->get_vl_len();++i) (*io)->get_vl()[i]->copy_var_desc((*iov)[i]); } if((*io)->get_iv_len()>0){ (*ov)=new otl_var_desc[(*io)->get_iv_len()]; (*ov_len)=(*io)->get_iv_len(); for(i=0;i<(*io)->get_iv_len();++i) (*io)->get_in_vl()[i]->copy_var_desc((*ov)[i]); } }else if((*ref_ss)){ if((*ref_ss)->get_vl_len()>0){ (*iov)=new otl_var_desc[(*ref_ss)->get_vl_len()]; (*iov_len)=(*ref_ss)->get_vl_len(); for(i=0;i<(*ref_ss)->get_vl_len();++i) (*ref_ss)->get_vl()[i]->copy_var_desc((*iov)[i]); } if((*ref_ss)->get_sl_len()>0){ (*ov)=new otl_var_desc[(*ref_ss)->get_sl_len()]; (*ov_len)=(*ref_ss)->get_sl_len(); for(i=0;i<(*ref_ss)->get_sl_len();++i){ (*ref_ss)->get_sl()[i].copy_var_desc((*ov)[i]); (*ov)[i].copy_name((*ref_ss)->get_sl_desc()[i].name); } } } } void init_stream(void) { buf_size_=1; last_oper_was_read_op=false; shell=0; shell=new otl_stream_shell(0); shell_pt.assign(&shell); connected=0; ref_ss=&(shell->ref_ss); ss=&(shell->ss); io=&(shell->io); adb=&(shell->adb); auto_commit_flag=&(shell->auto_commit_flag); iov=&(shell->iov); iov_len=&(shell->iov_len); next_iov_ndx=&(shell->next_iov_ndx); ov=&(shell->ov); ov_len=&(shell->ov_len); next_ov_ndx=&(shell->next_ov_ndx); override=&(shell->override); (*ref_ss)=0; (*io)=0; (*ss)=0; (*adb)=0; (*ov)=0; (*ov_len)=0; (*next_iov_ndx)=0; (*next_ov_ndx)=0; (*auto_commit_flag)=1; (*iov)=0; (*iov_len)=0; } otl_stream (const otl_stream_buffer_size_type arr_size, const char* sqlstm, otl_connect& db, const char* ref_cur_placeholder=0, const char* sqlstm_label=0) OTL_THROWS_OTL_EXCEPTION: #if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE) otl_read_stream_interface(), #endif shell(0), shell_pt(), connected(0), ref_ss(0), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), end_marker(0), oper_int_called(0), last_eof_rc(0), last_oper_was_read_op(false), override(0), buf_size_(0) { init_stream(); (*io)=0; (*ss)=0; (*ref_ss)=0; (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; (*auto_commit_flag)=1; (*next_iov_ndx)=0; (*next_ov_ndx)=0; (*adb)=&db; shell->flush_flag=true; open(arr_size,sqlstm,db,ref_cur_placeholder,sqlstm_label); } otl_stream() OTL_NO_THROW: #if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE) otl_read_stream_interface(), #endif shell(0), shell_pt(), connected(0), ref_ss(0), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), end_marker(0), oper_int_called(0), last_eof_rc(0), last_oper_was_read_op(false), override(0), buf_size_(0) { init_stream(); shell->flush_flag=true; } virtual ~otl_stream() #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) OTL_THROWS_OTL_EXCEPTION #endif { if(!connected)return; try{ if((*io)!=0&&shell->flush_flag==false) (*io)->set_flush_flag2(false); close(); if(shell!=0){ if((*io)!=0) (*io)->set_flush_flag2(true); } }catch(OTL_CONST_EXCEPTION otl_exception&){ if(shell!=0){ if((*io)!=0) (*io)->set_flush_flag2(true); } #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) clean(1); if(shell!=0) shell->set_should_delete(1); shell_pt.destroy(); #else shell_pt.destroy(); #endif #if !defined(OTL_DESTRUCTORS_DO_NOT_THROW) throw; #endif } #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) if((adb && (*adb) && (*adb)->get_throw_count()>0) #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) || otl_uncaught_exception() #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) || otl_uncaught_exception() #endif ){ // } #else shell_pt.destroy(); #endif } int eof(void) OTL_NO_THROW { if((*io)){ (*adb)->reset_throw_count(); return (*io)->eof(); }else if((*ss)){ (*adb)->reset_throw_count(); return (*ss)->eof(); }else if((*ref_ss)){ (*adb)->reset_throw_count(); return (*ref_ss)->eof(); }else return 1; } void skip_to_end_of_row() { if(next_ov_ndx==0) return; if((*ov_len)==0)return; last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->skip_to_end_of_row(); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); (*ss)->skip_to_end_of_row(); break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->skip_to_end_of_row(); break; } while ((*next_ov_ndx)<(*ov_len)-1) ++(*next_ov_ndx); } void reset_to_last_valid_row() { if((*io)){ (*adb)->reset_throw_count(); (*io)->reset_to_last_valid_row(); } } void flush(const int rowoff=0,const bool force_flush=false) OTL_THROWS_OTL_EXCEPTION { if((*io)){ (*adb)->reset_throw_count(); (*io)->flush(rowoff,force_flush); } } void clean(const int clean_up_error_flag=0) OTL_THROWS_OTL_EXCEPTION { if((*io)){ (*adb)->reset_throw_count(); (*io)->clean(clean_up_error_flag); }else if(*ss){ (*adb)->reset_throw_count(); (*ss)->clean(); }else if(*ref_ss){ (*adb)->reset_throw_count(); (*ref_ss)->clean(); } } void rewind(void) OTL_THROWS_OTL_EXCEPTION { if((*io)){ (*adb)->reset_throw_count(); (*io)->rewind(); }else if((*ss)){ (*adb)->reset_throw_count(); (*ss)->rewind(); }else if((*ref_ss)){ (*adb)->reset_throw_count(); (*ref_ss)->rewind(); } } int is_null(void) OTL_NO_THROW { if((*io)) return (*io)->is_null(); else if((*ss)) return (*ss)->is_null(); else if((*ref_ss)) return (*ref_ss)->is_null(); else return 0; } void set_commit(int auto_commit=0) OTL_NO_THROW { (*auto_commit_flag)=auto_commit; if((*io)){ (*adb)->reset_throw_count(); (*io)->set_commit(auto_commit); } } void open (const otl_stream_buffer_size_type arr_size, const char* sqlstm, otl_connect& db, const char* ref_cur_placeholder=0, const char* sqlstm_label=0) OTL_THROWS_OTL_EXCEPTION { reset_end_marker(); if(this->good()){ const char* temp_stm_text=0; switch(shell->stream_type){ case otl_no_stream_type: temp_stm_text=OTL_NO_STM_TEXT; break; case otl_inout_stream_type: temp_stm_text=(*io)->get_stm_label()?(*io)->get_stm_label():(*io)->get_stm_text(); break; case otl_select_stream_type: temp_stm_text=(*ss)->get_stm_label()?(*ss)->get_stm_label():(*ss)->get_stm_text(); break; case otl_refcur_stream_type: temp_stm_text=(*ref_ss)->get_stm_label()? (*ref_ss)->get_stm_label():(*ref_ss)->get_stm_text(); break; default: temp_stm_text=OTL_NO_STM_TEXT; break; } throw otl_exception (otl_error_msg_29, otl_error_code_29, temp_stm_text); } if(shell==0) init_stream(); buf_size_=arr_size; OTL_TRACE_STREAM_OPEN2 #if defined(OTL_STL) && defined(OTL_STREAM_POOLING_ON) char temp_buf[128]; otl_itoa(arr_size,temp_buf); OTL_STRING_CONTAINER sql_stm= OTL_STRING_CONTAINER(temp_buf)+ OTL_STRING_CONTAINER("===>")+sqlstm; otl_stream_shell_generic* temp_shell=db.get_sc().find(sql_stm); if(temp_shell){ if(shell!=0) shell_pt.destroy(); shell=OTL_RCAST(otl_stream_shell*,temp_shell); ref_ss=&(shell->ref_ss); ss=&(shell->ss); io=&(shell->io); if((*io)!=0)(*io)->set_flush_flag2(true); adb=&(shell->adb); auto_commit_flag=&(shell->auto_commit_flag); iov=&(shell->iov); iov_len=&(shell->iov_len); next_iov_ndx=&(shell->next_iov_ndx); ov=&(shell->ov); ov_len=&(shell->ov_len); next_ov_ndx=&(shell->next_ov_ndx); override=&(shell->override); override->set_master_stream_ptr(OTL_RCAST(void*,this)); try{ if((*iov_len)==0)this->rewind(); }catch(OTL_CONST_EXCEPTION otl_exception&){ if((*adb)) (*adb)->get_sc().remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; throw; } connected=1; return; } shell->orig_sql_stm=sql_stm; #endif delete[] (*iov); delete[] (*ov); (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; (*next_iov_ndx)=0; (*next_ov_ndx)=0; char tmp[7]; char* c=OTL_CCAST(char*,sqlstm); while(otl_isspace(*c)||(*c)=='(')++c; OTL_STRNCPY_S(tmp,sizeof(tmp),c,6); tmp[6]=0; c=tmp; while(*c){ *c=OTL_SCAST(char,otl_to_upper(*c)); ++c; } if(adb==0)adb=&(shell->adb); (*adb)=&db; (*adb)->reset_throw_count(); try{ if((strncmp(tmp,"SELECT",6)==0|| strncmp(tmp,"WITH",4)==0)&& ref_cur_placeholder==0){ override->set_master_stream_ptr(OTL_RCAST(void*,this)); (*ss)=new otl_select_stream(override,arr_size, sqlstm,db,otl_explicit_select, sqlstm_label); shell->stream_type=otl_select_stream_type; }else if(ref_cur_placeholder!=0){ override->set_master_stream_ptr(OTL_RCAST(void*,this)); (*ref_ss)=new otl_ref_select_stream (override,arr_size,sqlstm,ref_cur_placeholder, db,sqlstm_label); shell->stream_type=otl_refcur_stream_type; }else{ (*io)=new otl_inout_stream (arr_size, sqlstm, db, OTL_RCAST(void*,this), false,sqlstm_label); (*io)->set_flush_flag(shell->flush_flag); shell->stream_type=otl_inout_stream_type; } }catch(OTL_CONST_EXCEPTION otl_exception&){ shell_pt.destroy(); throw; } if((*io))(*io)->set_commit((*auto_commit_flag)); create_var_desc(); connected=1; } void intern_cleanup(void) { delete[] (*iov); delete[] (*ov); (*iov)=0; (*iov_len)=0; (*ov)=0; (*ov_len)=0; (*next_iov_ndx)=0; (*next_ov_ndx)=0; override->setLen(0); switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: try{ (*io)->flush(); (*io)->close(); }catch(OTL_CONST_EXCEPTION otl_exception&){ clean(1); (*io)->close(); delete (*io); (*io)=0; shell->stream_type=otl_no_stream_type; throw; } delete (*io); (*io)=0; shell->stream_type=otl_no_stream_type; break; case otl_select_stream_type: try{ (*ss)->close(); }catch(OTL_CONST_EXCEPTION otl_exception&){ delete (*ss); (*ss)=0; shell->stream_type=otl_no_stream_type; throw; } delete (*ss); (*ss)=0; shell->stream_type=otl_no_stream_type; break; case otl_refcur_stream_type: try{ (*ref_ss)->close(); }catch(OTL_CONST_EXCEPTION otl_exception&){ delete (*ref_ss); (*ref_ss)=0; shell->stream_type=otl_no_stream_type; throw; } delete (*ref_ss); (*ref_ss)=0; shell->stream_type=otl_no_stream_type; break; } (*ss)=0; (*io)=0; (*ref_ss)=0; if(adb!=0)(*adb)=0; adb=0; } #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) void close(const bool save_in_stream_pool=true) #else void close(void) #endif { if(shell==0)return; OTL_TRACE_FUNC(0x4,"otl_stream","close","") #if (defined(OTL_STL)||defined(OTL_ACE)) && defined(OTL_STREAM_POOLING_ON) if(save_in_stream_pool&&(*adb)&& #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) !otl_uncaught_exception()&& #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) !otl_uncaught_exception()&& #endif (*adb)->get_throw_count()==0){ try{ this->flush(); this->clean(1); }catch(OTL_CONST_EXCEPTION otl_exception&){ this->clean(1); throw; } if((*adb) && (*adb)->get_throw_count()>0){ (*adb)->get_sc().remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; return; } #if defined(OTL_STL) && defined(OTL_UNCAUGHT_EXCEPTION_ON) if(otl_uncaught_exception()){ if((*adb)) (*adb)->get_sc().remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; return; } #elif defined(OTL_UNCAUGHT_EXCEPTION_ON) if(otl_uncaught_exception()){ if((*adb)) (*adb)->get_sc().remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; return; } #endif (*adb)->get_sc().add(shell,shell->orig_sql_stm.c_str()); shell_pt.disconnect(); connected=0; }else{ if((*adb)) (*adb)->get_sc().remove(shell,shell->orig_sql_stm); intern_cleanup(); shell_pt.destroy(); connected=0; } #else intern_cleanup(); connected=0; #endif } otl_column_desc* describe_select(int& desc_len) OTL_NO_THROW { desc_len=0; switch(shell->stream_type){ case otl_no_stream_type: return 0; case otl_inout_stream_type: return 0; case otl_select_stream_type: (*adb)->reset_throw_count(); desc_len=(*ss)->get_sl_len(); return (*ss)->get_sl_desc(); case otl_refcur_stream_type: (*adb)->reset_throw_count(); desc_len=(*ref_ss)->get_sl_len(); return (*ref_ss)->get_sl_desc(); default: return 0; } } int good(void) OTL_NO_THROW { if(!connected)return 0; if((*io)||(*ss)||(*ref_ss)){ (*adb)->reset_throw_count(); return 1; }else return 0; } otl_stream& operator>>(otl_stream& (*pf) (otl_stream&)) { (*pf)(*this); return *this; } otl_stream& operator<<(otl_stream& (*pf) (otl_stream&)) { (*pf)(*this); return *this; } otl_stream& operator>>(otl_pl_tab_generic& tab) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; if((*io)){ last_eof_rc=(*io)->eof(); (*io)->operator>>(tab); OTL_TRACE_WRITE(", tab len="<>","PL/SQL Tab&") inc_next_ov(); } return *this; } otl_stream& operator>>(otl_refcur_stream& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; if((*io)){ last_eof_rc=(*io)->eof(); (*io)->operator>>(s); OTL_TRACE_WRITE(" ref.cur.stream","operator >>","otl_refcur_stream&") inc_next_ov(); } return *this; } otl_stream& operator<<(otl_pl_tab_generic& tab) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); if((*io)){ (*io)->operator<<(tab); OTL_TRACE_READ(", tab len="<>(otl_pl_vec_generic& vec) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; if((*io)){ last_eof_rc=(*io)->eof(); (*io)->operator>>(vec); OTL_TRACE_WRITE(", tab len="<>","PL/SQL Tab&") inc_next_ov(); } return *this; } otl_stream& operator<<(otl_pl_vec_generic& vec) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); if((*io)){ (*io)->operator<<(vec); OTL_TRACE_READ(", tab len="<operator<<(s); OTL_TRACE_READ(", lob stream","operator <<","PL/otl_lob_stream&") inc_next_iov(); } return *this; } otl_stream& operator>>(otl_time0& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: { last_eof_rc=(*io)->eof(); (*io)->operator>>(s); #if defined(OTL_ORA_TIMESTAMP) OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&"); #endif break; } case otl_select_stream_type: { last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); #if defined(OTL_ORA_TIMESTAMP) OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&"); #endif break; } case otl_refcur_stream_type: { last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); #if defined(OTL_ORA_TIMESTAMP) OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&"); #endif break; } } #if defined(OTL_ORA_TIMESTAMP) inc_next_ov(); #endif return *this; } otl_stream& operator<<(const otl_time0& n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: { (*io)->operator<<(n); #if defined(OTL_ORA_TIMESTAMP) OTL_TRACE_READ(OTL_TRACE_FORMAT_DATETIME(n), "operator <<", "otl_datetime&"); #endif break; } case otl_select_stream_type: { (*ss)->operator<<(n); #if defined(OTL_ORA_TIMESTAMP) OTL_TRACE_READ(OTL_TRACE_FORMAT_DATETIME(n), "operator <<", "otl_datetime&"); #endif break; } case otl_refcur_stream_type: { (*ref_ss)->operator<<(n); if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); #if defined(OTL_ORA_TIMESTAMP) OTL_TRACE_READ(OTL_TRACE_FORMAT_DATETIME(n), "operator <<", "otl_datetime&"); #endif break; } } #if defined(OTL_ORA_TIMESTAMP) inc_next_iov(); #endif return *this; } #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) // already declared #else OTL_ORA_COMMON_READ_STREAM& operator>>(otl_datetime& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; #if defined(OTL_ORA7_STRING_TO_TIMESTAMP) if(describe_next_out_var()->ftype==otl_var_char){ #if defined(OTL_UNICODE) OTL_CHAR tmp_str[100]; #elif defined(OTL_UNICODE) && defined(OTL_UNICODE_CHAR_TYPE) OTL_UNICODE_CHAR_TYPE tmp_str[100]; #else char tmp_str[100]; #endif (*this)>>tmp_str; #if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_DATETIME_NULL_TO_VAL; else OTL_ORA7_STRING_TO_TIMESTAMP(tmp_str,s); #else OTL_ORA7_STRING_TO_TIMESTAMP(tmp_str,s); #endif OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&"); return *this; }else{ otl_time0 tmp; (*this)>>tmp; #if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_DATETIME_NULL_TO_VAL; else{ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100); s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour-1; s.minute=tmp.minute-1; s.second=tmp.second-1; } #else s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100); s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour-1; s.minute=tmp.minute-1; s.second=tmp.second-1; #endif OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&") inc_next_ov(); return *this; } #else otl_time0 tmp; (*this)>>tmp; #if defined(OTL_DEFAULT_DATETIME_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_DATETIME_NULL_TO_VAL; else{ s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100); s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour-1; s.minute=tmp.minute-1; s.second=tmp.second-1; } #else s.year=(OTL_SCAST(int,tmp.century)-100)*100+(OTL_SCAST(int,tmp.year)-100); s.month=tmp.month; s.day=tmp.day; s.hour=tmp.hour-1; s.minute=tmp.minute-1; s.second=tmp.second-1; #endif OTL_TRACE_WRITE (OTL_TRACE_FORMAT_DATETIME(s), "operator >>", "otl_datetime&"); inc_next_ov(); return *this; #endif } #endif #if (defined(OTL_ORA8I)||defined(OTL_ORA9I))&&defined(OTL_ORA_TIMESTAMP) // already declared #else otl_stream& operator<<(const otl_datetime& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); #if defined(OTL_ORA7_TIMESTAMP_TO_STRING) if(describe_next_in_var()->ftype==otl_var_char){ #if defined(OTL_UNICODE) OTL_CHAR tmp_str[100]; #elif defined(OTL_UNICODE) && defined(OTL_UNICODE_CHAR_TYPE) OTL_UNICODE_CHAR_TYPE tmp_str[100]; #else char tmp_str[100]; #endif OTL_ORA7_TIMESTAMP_TO_STRING(s,tmp_str); OTL_TRACE_READ (OTL_TRACE_FORMAT_DATETIME(s), "operator <<", "otl_datetime&"); (*this)<>(char& c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(c); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(c); break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(c); break; } #if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL) if((*this).is_null()) c=OTL_DEFAULT_CHAR_NULL_TO_VAL; #endif OTL_TRACE_WRITE("'"<>","char&") inc_next_ov(); return *this; } #endif OTL_ORA_COMMON_READ_STREAM& operator>>(unsigned char& c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(c); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(c); break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(c); break; } #if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL) if((*this).is_null()) c=OTL_DEFAULT_CHAR_NULL_TO_VAL; #endif OTL_TRACE_WRITE("'"<>","unsigned char&") inc_next_ov(); return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) OTL_ORA_COMMON_READ_STREAM& operator>>(OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); break; } #if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL) if((*this).is_null()){ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s); } #elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) s=OTL_DEFAULT_STRING_NULL_TO_VAL; #endif OTL_TRACE_WRITE("\""<>","OTL_STRING_CONTAINER&") inc_next_ov(); return *this; } #endif #if !defined(OTL_UNICODE) OTL_ORA_COMMON_READ_STREAM& operator>>(char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); break; } #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL)); #endif OTL_TRACE_WRITE("\""<>","char*") inc_next_ov(); return *this; } #endif #if defined(OTL_UNICODE_STRING_TYPE) OTL_ORA_COMMON_READ_STREAM& operator>>(OTL_UNICODE_STRING_TYPE& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); break; } #if defined(OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL) if((*this).is_null()){ OTL_USER_DEFINED_STRING_CLASS_DEFAULT_NULL_TO_VAL(s); } #elif defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) s=OTL_RCAST(const OTL_UNICODE_CHAR_TYPE*, OTL_DEFAULT_STRING_NULL_TO_VAL); #endif OTL_TRACE_WRITE ("\""<>", "OTL_UNICODE_STRING_TYPE&"); inc_next_ov(); return *this; } otl_stream& operator<<(const OTL_UNICODE_STRING_TYPE& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("\""<stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(s); break; case otl_select_stream_type: (*ss)->operator<<(s); break; case otl_refcur_stream_type: (*ref_ss)->operator<<(s); if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #endif OTL_ORA_COMMON_READ_STREAM& operator>>(unsigned char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); break; } #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL) ); #endif #if defined(OTL_UNICODE) OTL_TRACE_WRITE ("\""<>", OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*") #else OTL_TRACE_WRITE("\""<>","unsigned char*") #endif inc_next_ov(); return *this; } #if defined(OTL_UNICODE) OTL_ORA_COMMON_READ_STREAM& operator>>(OTL_UNICODE_CHAR_TYPE* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(OTL_RCAST(unsigned char*,s)); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(OTL_RCAST(unsigned char*,s)); break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(OTL_RCAST(unsigned char*,s)); break; } #if defined(OTL_DEFAULT_STRING_NULL_TO_VAL) if((*this).is_null()) otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,OTL_DEFAULT_STRING_NULL_TO_VAL)); #endif OTL_TRACE_WRITE(OTL_RCAST(OTL_UNICODE_CHAR_TYPE*,s), "operator >>", OTL_UNICODE_CHAR_TYPE_TRACE_NAME "*") inc_next_ov(); return *this; } OTL_ORA_COMMON_READ_STREAM& operator>>(OTL_UNICODE_CHAR_TYPE& c) OTL_THROWS_OTL_EXCEPTION { OTL_UNICODE_CHAR_TYPE s[1024]; last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(OTL_RCAST(unsigned char*,s)); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(OTL_RCAST(unsigned char*,s)); break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(OTL_RCAST(unsigned char*,s)); break; } c=s[0]; #if defined(OTL_DEFAULT_CHAR_NULL_TO_VAL) if((*this).is_null()) c=OTL_DEFAULT_CHAR_NULL_TO_VAL; #endif OTL_TRACE_WRITE(c,"operator >>", OTL_UNICODE_CHAR_TYPE_TRACE_NAME "") inc_next_ov(); return *this; } #endif #if defined(OTL_BIGINT) && (defined(OTL_ORA11G_R2)&&!defined(OTL_STR_TO_BIGINT)&&\ !defined(OTL_BIGINT_TO_STR)) OTL_ORA_COMMON_READ_STREAM& operator>>(OTL_BIGINT& n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(n); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(n); #else (*ss)->operator>>(n); #endif break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(n); #else (*ref_ss)->operator>>(n); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) n=OTL_SCAST(int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(n,"operator >>","OTL_BIGINT&") inc_next_ov(); return *this; } #endif OTL_ORA_COMMON_READ_STREAM& operator>>(int& n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(n); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(n); #else (*ss)->operator>>(n); #endif break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(n); #else (*ref_ss)->operator>>(n); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) n=OTL_SCAST(int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(n,"operator >>","int&") inc_next_ov(); return *this; } OTL_ORA_COMMON_READ_STREAM& operator>>(unsigned& u) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(u); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(u); #else (*ss)->operator>>(u); #endif break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(u); #else (*ref_ss)->operator>>(u); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) u=OTL_SCAST(unsigned int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(u,"operator >>","unsigned&") inc_next_ov(); return *this; } OTL_ORA_COMMON_READ_STREAM& operator>>(short& sh) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(sh); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(sh); #else (*ss)->operator>>(sh); #endif break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(sh); #else (*ref_ss)->operator>>(sh); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) sh=OTL_SCAST(short int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(sh,"operator >>","short int&") inc_next_ov(); return *this; } OTL_ORA_COMMON_READ_STREAM& operator>>(long int& l) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(l); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(l); #else (*ss)->operator>>(l); #endif break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(l); #else (*ref_ss)->operator>>(l); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) l=OTL_SCAST(long int,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(l,"operator >>","long int&") inc_next_ov(); return *this; } OTL_ORA_COMMON_READ_STREAM& operator>>(float& f) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(f); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(f); #else (*ss)->operator>>(f); #endif break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(f); #else (*ref_ss)->operator>>(f); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) f=OTL_SCAST(float,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(f,"operator >>","float&") inc_next_ov(); return *this; } OTL_ORA_COMMON_READ_STREAM& operator>>(double& d) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(d); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator>>(d); #else (*ss)->operator>>(d); #endif break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator>>(d); #else (*ref_ss)->operator>>(d); #endif break; } #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if((*this).is_null()) d=OTL_SCAST(double,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif OTL_TRACE_WRITE(d,"operator >>","double&") inc_next_ov(); return *this; } OTL_ORA_COMMON_READ_STREAM& operator>>(otl_long_string& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator>>(s); break; case otl_select_stream_type: (*ss)->operator>>(s); break; case otl_refcur_stream_type: (*ref_ss)->operator>>(s); break; } OTL_TRACE_WRITE(" len="<>","otl_long_string&") inc_next_ov(); return *this; } OTL_ORA_COMMON_READ_STREAM& operator>>(otl_lob_stream& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=true; switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: last_eof_rc=(*io)->eof(); (*io)->operator>>(s); break; case otl_select_stream_type: last_eof_rc=(*ss)->eof(); (*ss)->operator>>(s); break; case otl_refcur_stream_type: last_eof_rc=(*ref_ss)->eof(); (*ref_ss)->operator>>(s); break; } shell->lob_stream_flag=true; OTL_TRACE_WRITE(" lob stream","operator >>","otl_lob_stream&") inc_next_ov(); return *this; } #if !defined(OTL_UNICODE) otl_stream& operator<<(const char c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("'"<stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(c); break; case otl_select_stream_type: (*ss)->operator<<(c); break; case otl_refcur_stream_type: (*ref_ss)->operator<<(c); if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #endif otl_stream& operator<<(const unsigned char c) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("'"<stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(c); break; case otl_select_stream_type: (*ss)->operator<<(c); break; case otl_refcur_stream_type: (*ref_ss)->operator<<(c); if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) otl_stream& operator<<(const OTL_STRING_CONTAINER& s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("\""<stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(s); break; case otl_select_stream_type: (*ss)->operator<<(s); break; case otl_refcur_stream_type: (*ref_ss)->operator<<(s); if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #endif #if !defined(OTL_UNICODE) otl_stream& operator<<(const char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("\""<stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(s); break; case otl_select_stream_type: (*ss)->operator<<(s); break; case otl_refcur_stream_type: (*ref_ss)->operator<<(s); if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #endif otl_stream& operator<<(const unsigned char* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); #if defined(OTL_UNICODE) OTL_TRACE_READ ("\""<stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(s); break; case otl_select_stream_type: (*ss)->operator<<(s); break; case otl_refcur_stream_type: (*ref_ss)->operator<<(s); if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #if defined(OTL_UNICODE) otl_stream& operator<<(const OTL_UNICODE_CHAR_TYPE* s) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ ("\""<stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(OTL_RCAST(const unsigned char*,s)); break; case otl_select_stream_type: (*ss)->operator<<(OTL_RCAST(const unsigned char*,s)); break; case otl_refcur_stream_type: (*ref_ss)->operator<<(OTL_RCAST(const unsigned char*,s)); if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const OTL_UNICODE_CHAR_TYPE c) OTL_THROWS_OTL_EXCEPTION { OTL_UNICODE_CHAR_TYPE s[2]; s[0]=c; s[1]=0; (*this)<stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(n); break; case otl_select_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(n); #else (*ss)->operator<<(n); #endif break; case otl_refcur_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(n); #else (*ref_ss)->operator<<(n); #endif if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } #endif otl_stream& operator<<(const int n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(n,"operator <<","int"); switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(n); break; case otl_select_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(n); #else (*ss)->operator<<(n); #endif break; case otl_refcur_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(n); #else (*ref_ss)->operator<<(n); #endif if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const unsigned u) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(u,"operator <<","unsigned"); switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(u); break; case otl_select_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(u); #else (*ss)->operator<<(u); #endif break; case otl_refcur_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(u); #else (*ref_ss)->operator<<(u); #endif if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const short sh) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(sh,"operator <<","short int"); switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(sh); break; case otl_select_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(sh); #else (*ss)->operator<<(sh); #endif break; case otl_refcur_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(sh); #else (*ref_ss)->operator<<(sh); #endif if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const long int l) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(l,"operator <<","long int"); switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(l); break; case otl_select_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(l); #else (*ss)->operator<<(l); #endif break; case otl_refcur_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(l); #else (*ref_ss)->operator<<(l); #endif if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const float f) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(f,"operator <<","float"); switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(f); break; case otl_select_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(f); #else (*ss)->operator<<(f); #endif break; case otl_refcur_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(f); #else (*ref_ss)->operator<<(f); #endif if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const double d) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(d,"operator <<","double"); switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(d); break; case otl_select_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ss)->operator<<(d); #else (*ss)->operator<<(d); #endif break; case otl_refcur_stream_type: #if defined(OTL_NO_TMPL_MEMBER_FUNC_SUPPORT) (*ref_ss)->operator<<(d); #else (*ref_ss)->operator<<(d); #endif if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const otl_null& n) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ("NULL","operator <<","otl_null&"); switch(shell->stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(n); break; case otl_select_stream_type: (*ss)->operator<<(n); break; case otl_refcur_stream_type: (*ref_ss)->operator<<(n); if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } otl_stream& operator<<(const otl_long_string& d) OTL_THROWS_OTL_EXCEPTION { last_oper_was_read_op=false; reset_end_marker(); OTL_TRACE_READ(" len="<stream_type){ case otl_no_stream_type: break; case otl_inout_stream_type: (*io)->operator<<(d); break; case otl_select_stream_type: (*ss)->operator<<(d); break; case otl_refcur_stream_type: (*ref_ss)->operator<<(d); if(!(*ov)&&(*ref_ss)->get_sl()) create_var_desc(); break; } inc_next_iov(); return *this; } private: otl_stream& operator=(const otl_stream&) { return *this; } otl_stream(const otl_stream&): #if defined(OTL_ORA_DECLARE_COMMON_READ_STREAM_INTERFACE) otl_read_stream_interface(), #endif shell(0), shell_pt(), connected(0), ref_ss(0), ss(0), io(0), adb(0), auto_commit_flag(0), iov(0), iov_len(0), next_iov_ndx(0), ov(0), ov_len(0), next_ov_ndx(0), end_marker(0), oper_int_called(0), last_eof_rc(0), last_oper_was_read_op(false), override(0), buf_size_(0) { } #if !defined(OTL_STREAM_NO_PRIVATE_BOOL_OPERATORS) otl_stream& operator>>(bool&) OTL_NO_THROW { return *this; } otl_stream& operator<<(const bool) OTL_NO_THROW { return *this; } #endif #if !defined(OTL_STREAM_NO_PRIVATE_UNSIGNED_LONG_OPERATORS) otl_stream& operator>>(unsigned long int&) OTL_NO_THROW { return *this; } otl_stream& operator<<(const unsigned long int) OTL_NO_THROW { return *this; } #endif }; #if defined(OTL_ORA_SUBSCRIBE) #if !defined(OTL_ORA_OCI_ENV_CREATE) #error OTL_ORA_SUBSCRIBE requires #define OTL_ORA_OCI_ENV_CREATE to be enabled #endif #if !defined(OTL_ORA_OCI_ENV_CREATE_MODE) #error OTL_ORA_SUBSCRIBE requires #define OTL_ORA_OCI_ENV_CREATE_MODE to be \ enabled and to have OCI_THREADED|OCI_OBJECT|OCI_EVENTS #endif class otl_subscriber{ public: otl_subscriber(otl_connect* adb=0): db(adb), subscrhp(0) { } virtual ~otl_subscriber(void) { unsubscribe(); } void subscribe(const char *name=0,int port=0,int timeout=1800) { if(subscrhp) unsubscribe(); if(!db||(db&&!db->connected)) throw otl_exception (otl_error_msg_32, otl_error_code_32); OCIEnv *envhp=db->get_connect_struct().get_envhp(); OCIError *errhp=db->get_connect_struct().get_errhp(); OCISvcCtx *svchp=db->get_connect_struct().get_svchp(); if(port) check(OCIAttrSet(OTL_RCAST(dvoid*,envhp), OTL_SCAST(ub4,OCI_HTYPE_ENV), OTL_RCAST(dvoid*,&port), 0, OCI_ATTR_SUBSCR_PORTNO, errhp)); OCISubscription** temp_subscrhp=&subscrhp; check(OCIHandleAlloc(OTL_RCAST(dvoid*,envhp), OTL_RCAST(dvoid**,temp_subscrhp), OCI_HTYPE_SUBSCRIPTION, OTL_SCAST(size_t,0), OTL_RCAST(dvoid**,0))); if(name && *name) check(OCIAttrSet(subscrhp, OCI_HTYPE_SUBSCRIPTION, OTL_RCAST(void*,OTL_CCAST(char*,name)), OTL_SCAST(ub4,strlen(name)), OCI_ATTR_SUBSCR_NAME, errhp)); ub4 nspace = OCI_SUBSCR_NAMESPACE_DBCHANGE; check(OCIAttrSet(subscrhp, OCI_HTYPE_SUBSCRIPTION, OTL_RCAST(dvoid*,&nspace), sizeof(ub4), OCI_ATTR_SUBSCR_NAMESPACE, errhp)); check(OCIAttrSet(subscrhp, OCI_HTYPE_SUBSCRIPTION, #if defined(__GNUC__) && (__GNUC__<4) (void*)common_notification_callback, #else OTL_RCAST(void*,common_notification_callback), #endif 0, OCI_ATTR_SUBSCR_CALLBACK, errhp)); int rowids_needed=1; check(OCIAttrSet(subscrhp, OCI_HTYPE_SUBSCRIPTION, OTL_RCAST(dvoid*,&rowids_needed), sizeof(ub4), OCI_ATTR_CHNF_ROWIDS, errhp)); check(OCIAttrSet(subscrhp, OTL_SCAST(ub4,OCI_HTYPE_SUBSCRIPTION), OTL_RCAST(dvoid*,this), 0, OCI_ATTR_SUBSCR_CTX, errhp)); if(timeout) check(OCIAttrSet(subscrhp, OCI_HTYPE_SUBSCRIPTION, OTL_RCAST(dvoid*,&timeout), 0, OCI_ATTR_SUBSCR_TIMEOUT, errhp)); check(OCISubscriptionRegister(svchp,&subscrhp,1,errhp,OCI_DEFAULT)); } void unsubscribe(void) { if(!subscrhp) return; if(!db||(db&&!db->connected)) throw otl_exception (otl_error_msg_32, otl_error_code_32); OCIError *errhp=db->get_connect_struct().get_errhp(); OCISvcCtx *svchp=db->get_connect_struct().get_svchp(); OCISubscriptionUnRegister(svchp,subscrhp,errhp,OCI_DEFAULT); OCIHandleFree(OTL_RCAST(dvoid*,subscrhp),OCI_HTYPE_SUBSCRIPTION); subscrhp=0; } void associate_table(const char *table_name) { if(!db||(db&&!db->connected)) throw otl_exception (otl_error_msg_32, otl_error_code_32); char sql_stmt[1024]; OTL_STRCPY_S(sql_stmt,sizeof(sql_stmt),"select :i from "); OTL_STRCAT_S(sql_stmt,sizeof(sql_stmt),table_name); int arg=0; otl_stream s(1,sql_stmt,*db); if(!s.get_shell() || !s.get_shell()->ss) throw otl_exception(db->get_connect_struct(),sql_stmt); OCIError *errhp=db->get_connect_struct().get_errhp(); OCIStmt *stmthp=s.get_shell()->ss->get_cursor_struct().cda; check(OCIAttrSet(stmthp, OCI_HTYPE_STMT, subscrhp, 0, OCI_ATTR_CHNF_REGHANDLE, errhp)); s<connected)) throw otl_exception (otl_error_msg_32, otl_error_code_32); otl_stream s(1,stmt,*db); if(!s.get_shell() || !s.get_shell()->ss) throw otl_exception(db->get_connect_struct(),stmt); OCIError *errhp=db->get_connect_struct().get_errhp(); OCIStmt *stmthp=s.get_shell()->ss->get_cursor_struct().cda; check(OCIAttrSet(stmthp, OCI_HTYPE_STMT, subscrhp, 0, OCI_ATTR_CHNF_REGHANDLE, errhp)); s<<0; } protected: void check(ub4 ret_code) { if(ret_code!=OCI_SUCCESS) throw otl_exception(db->get_connect_struct()); } virtual void OnException(OTL_CONST_EXCEPTION otl_exception& e) = 0; virtual void OnDeRegistration(void) = 0; //--- DB events: virtual void OnStartup(void) = 0; virtual void OnInstanceShutdown(void) = 0; virtual void OnAnyInstanceShutdown(void) = 0; //--- Table events: virtual void OnTableInvalidate(text *table_name) = 0; virtual void OnTableAlter(text *table_name, bool all_rows=false) = 0; virtual void OnTableDrop(text *table_name, bool all_rows=false) = 0; virtual void OnTableChange(text *table_name, bool all_rows=false) = 0; //--- Row events: virtual void OnRowInsert( text *table_name, text *row_id ) = 0; virtual void OnRowUpdate( text *table_name, text *row_id ) = 0; virtual void OnRowDelete( text *table_name, text *row_id ) = 0; protected: otl_connect* db; private: OCISubscription *subscrhp; void notification_callback (dvoid* /*payload*/, ub4 /*paylen*/, dvoid *desc, ub4 /*mode*/) { if(!db||(db&&!db->connected)) return; ub4 num_rows = 0; OCIColl *row_changes=0; dvoid *row_desc, **row_descp; dvoid*** temp_row_descp=&row_descp; text *row_id; ub4 rowid_size; unsigned int j; try{ OCIEnv *envhp=db->get_connect_struct().get_envhp(); OCIError *errhp=db->get_connect_struct().get_errhp(); //---------------- ub4 notify_type; check(OCIAttrGet(desc, OCI_DTYPE_CHDES, ¬ify_type, 0, OCI_ATTR_CHDES_NFYTYPE, errhp)); switch(notify_type){ case OCI_EVENT_STARTUP: OnStartup(); return; case OCI_EVENT_SHUTDOWN: OnInstanceShutdown(); return; case OCI_EVENT_SHUTDOWN_ANY: OnAnyInstanceShutdown(); return; case OCI_EVENT_DEREG: OnDeRegistration(); return; case OCI_EVENT_OBJCHANGE: break; default: return; } OCIColl *table_changes=0; check(OCIAttrGet(desc, OCI_DTYPE_CHDES, &table_changes, 0, OCI_ATTR_CHDES_TABLE_CHANGES, errhp)); if(!table_changes)return; ub4 num_tables=0; check(OCICollSize(envhp, errhp, OTL_RCAST(CONST OCIColl*,table_changes), OTL_RCAST(sb4*,&num_tables))); if(!num_tables)return; for(unsigned int i=0;inotification_callback(payload,paylen,desc,mode); } public: bool is_online(void){ return subscrhp!=0; } private: otl_subscriber(const otl_subscriber&): db(0), subscrhp(0) { } otl_subscriber& operator=(const otl_subscriber&) { return *this; } }; #endif inline otl_connect& operator>>(otl_connect& connect, otl_stream& s) { const char* cmd=connect.getCmd(); const char* invalid_cmd="*** INVALID COMMAND ***"; if(!cmd) cmd=invalid_cmd; s.open(s.getBufSize(),cmd,connect); return connect; } #if (defined(OTL_STL)||defined(OTL_VALUE_TEMPLATE_ON)) \ && defined(OTL_VALUE_TEMPLATE) template otl_stream& operator<<(otl_stream& s, const otl_value& var) OTL_THROWS_OTL_EXCEPTION { if(var.ind) s< otl_stream& operator>>(otl_stream& s, otl_value& var) OTL_THROWS_OTL_EXCEPTION { s>>var.v; if(s.is_null()) var.ind=true; else var.ind=false; return s; } template otl_refcur_stream& operator>>(otl_refcur_stream& s, otl_value& var) OTL_THROWS_OTL_EXCEPTION { s>>var.v; if(s.is_null()) var.ind=true; else var.ind=false; return s; } #endif typedef otl_tmpl_nocommit_stream otl_nocommit_stream; #if defined(OTL_BIGINT) && defined(OTL_STR_TO_BIGINT) && \ defined(OTL_BIGINT_TO_STR) inline otl_stream& operator>>(otl_stream& s, OTL_BIGINT& n) OTL_THROWS_OTL_EXCEPTION { char temp_val[otl_bigint_str_size]; #if defined(OTL_UNICODE) OTL_CHAR unitemp_val[otl_bigint_str_size]; s>>OTL_RCAST(unsigned char*,unitemp_val); OTL_CHAR* uc=unitemp_val; char* c=temp_val; while(*uc){ *c=OTL_SCAST(char,*uc); ++uc; ++c; } *c=0; #else s>>temp_val; #endif if(s.is_null()){ #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if(s.is_null()) n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif return s; } OTL_STR_TO_BIGINT(temp_val,n) return s; } inline otl_refcur_stream& operator>>(otl_refcur_stream& s, OTL_BIGINT& n) OTL_THROWS_OTL_EXCEPTION { char temp_val[otl_bigint_str_size]; s>>temp_val; if(s.is_null()){ #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if(s.is_null()) n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif return s; } OTL_STR_TO_BIGINT(temp_val,n) return s; } inline otl_stream& operator<<(otl_stream& s, const OTL_BIGINT n) OTL_THROWS_OTL_EXCEPTION { #if defined(OTL_UNICODE) char temp_val[otl_bigint_str_size]; OTL_BIGINT_TO_STR(n,temp_val) OTL_CHAR unitemp_val[otl_bigint_str_size]; OTL_CHAR* uc=unitemp_val; char* c=temp_val; while(*c){ *uc=OTL_SCAST(OTL_CHAR,*c); ++uc; ++c; } *uc=0; s<>(otl_stream& s, OTL_BIGINT& n) OTL_THROWS_OTL_EXCEPTION { long temp_val; s>>temp_val; if(s.is_null()){ #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if(s.is_null()) n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif return s; } n=OTL_SCAST(OTL_BIGINT,temp_val); return s; } inline otl_refcur_stream& operator>>(otl_refcur_stream& s, OTL_BIGINT& n) OTL_THROWS_OTL_EXCEPTION { long temp_val; s>>temp_val; if(s.is_null()){ #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if(s.is_null()) n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); #endif return s; } n=OTL_SCAST(OTL_BIGINT,temp_val); return s; } inline otl_stream& operator<<(otl_stream& s, const OTL_BIGINT n) OTL_THROWS_OTL_EXCEPTION { long temp_val=OTL_SCAST(long,n); s< #define STL_OUTPUT_ITERATOR_TO_DERIVE_FROM \ : public STD_NAMESPACE_PREFIX iterator \ #endif #if defined(OTL_STL) || defined(OTL_STLPORT) #define OTL_ITERATORS \ template \ class otl_input_iterator STL_INPUT_ITERATOR_TO_DERIVE_FROM { \ public: \ \ typedef STD_NAMESPACE_PREFIX input_iterator_tag iterator_category; \ typedef T value_type; \ typedef Distance difference_type; \ typedef const T* pointer; \ typedef const T& reference; \ \ otl_stream* stream; \ T value; \ int end_marker; \ \ void read() \ { \ if(!stream){ \ end_marker=-1; \ return; \ } \ if(stream->eof()){ \ end_marker=-1; \ return; \ } \ end_marker=stream->eof(); \ if(!end_marker)*stream>>value; \ if(stream->eof())end_marker=1; \ } \ \ otl_input_iterator() : stream(0), value(), end_marker(-1){} \ otl_input_iterator(otl_stream& s) : stream(&s), value(),end_marker(0){read();} \ \ const T& operator*() const { return value; } \ \ otl_input_iterator& operator++(){read(); return *this;} \ \ otl_input_iterator operator++(int) \ { \ otl_input_iterator tmp = *this; \ read(); \ return tmp; \ } \ \ otl_input_iterator(const otl_input_iterator& src): \ stream(src.stream),value(src.value),end_marker(src.end_marker){} \ \ otl_input_iterator& operator=(const otl_input_iterator& src) \ { \ stream=src.stream; \ value=src.value; \ end_marker=src.end_marker; \ return *this; \ } \ }; \ \ template \ inline STD_NAMESPACE_PREFIX input_iterator_tag iterator_category( \ const otl_input_iterator& \ ) \ { \ return STD_NAMESPACE_PREFIX input_iterator_tag(); \ } \ \ template \ inline T* value_type(const otl_input_iterator&) \ { \ return 0; \ } \ \ template \ inline Distance* distance_type(const otl_input_iterator&) \ { \ return 0; \ } \ \ template \ bool operator==(const otl_input_iterator& x, \ const otl_input_iterator& y) \ { \ return (x.stream == y.stream && x.end_marker == y.end_marker) || \ (x.end_marker == -1 && y.end_marker == -1); \ } \ \ template \ bool operator!=(const otl_input_iterator& x, \ const otl_input_iterator& y) \ { \ return !(x==y); \ } \ \ template \ class otl_output_iterator STL_OUTPUT_ITERATOR_TO_DERIVE_FROM { \ protected: \ otl_stream* stream; \ public: \ \ typedef STD_NAMESPACE_PREFIX output_iterator_tag iterator_category; \ typedef void value_type; \ typedef void difference_type; \ typedef void pointer; \ typedef void reference; \ \ otl_output_iterator(otl_stream& s) : stream(&s){} \ otl_output_iterator& operator=(const T& value) \ { \ *stream << value; \ return *this; \ } \ otl_output_iterator& operator*() { return *this; } \ otl_output_iterator& operator++() { return *this; } \ otl_output_iterator operator++(int) { return *this; } \ \ }; \ \ template \ inline STD_NAMESPACE_PREFIX output_iterator_tag \ iterator_category(const otl_output_iterator&) { \ return STD_NAMESPACE_PREFIX output_iterator_tag(); \ } #if defined(OTL_ORA7) OTL_ORA7_NAMESPACE_BEGIN OTL_ITERATORS OTL_ORA7_NAMESPACE_END #endif #if defined(OTL_ORA8) OTL_ORA8_NAMESPACE_BEGIN OTL_ITERATORS OTL_ORA8_NAMESPACE_END #endif #if defined(OTL_ODBC) OTL_ODBC_NAMESPACE_BEGIN OTL_ITERATORS OTL_ODBC_NAMESPACE_END #endif #endif #if defined(OTL_STREAM_READ_ITERATOR_ON) #if defined(OTL_UNICODE) #error UNICODE is not supported when #define OTL_STREAM_READ_ITERATOR_ON is enabled #endif #if defined(OTL_STL) #include #endif #if defined(OTL_ACE) #include #include #include #include #include #endif #if defined(OTL_STL)||defined(OTL_ACE) class otl_ltcharstar{ public: #if defined(OTL_STL) bool #else int #endif operator()(const char* s1, const char* s2) const { #if defined(__BORLANDC__) || defined(_MSC_VER) return stricmp(s1,s2)<0; #else #if defined(__STRICT_ANSI__) while(otl_to_upper(*s1)==otl_to_upper(*s2)&&*s1){ ++s1; ++s2; } return *s1 < *s2; #else return strcasecmp(s1,s2)<0; #endif #endif } }; #endif template class otl_stream_read_iterator{ public: otl_stream_read_iterator(OTLStream& s) { set(); attach(s); } otl_stream_read_iterator(): out_vars_(0), out_vars_len_(0), str_(0), out_vars_arr_(0), out_vars_null_arr_(0), out_vars_constructed_(0), lob_stream_mode_flag_(false) #if defined(OTL_STL) ,var_name2pos_map_() #endif #if defined(OTL_ACE) ,var_name2pos_map_() #endif { set(); } ~otl_stream_read_iterator() { reset(); } void attach(OTLStream& s) { reset(); str_=&s; if(!str_->good()){ str_=0; throw OTLException(otl_error_msg_19,otl_error_code_19); } out_vars_=str_->describe_out_vars(out_vars_len_); if(!out_vars_){ throw OTLException(otl_error_msg_21,otl_error_code_21); } lob_stream_mode_flag_=str_->get_lob_stream_flag(); allocate_arrays(); } void reattach() { if(!str_->good()){ reset(); throw OTLException(otl_error_msg_19,otl_error_code_19); } out_vars_=str_->describe_out_vars(out_vars_len_); if(!out_vars_){ reset(); throw OTLException(otl_error_msg_21,otl_error_code_21); }else{ #if defined(OTL_STL) var_name2pos_map_.clear(); for(int i=0;iget_lob_stream_flag(); } void detach(void) { reset(); } const otl_var_desc* describe(int& var_desc_len) { var_desc_len=out_vars_len_; return out_vars_; } bool next_row(void) { if(str_->eof())return false; for(int i=0;i>OTL_RCAST(char*,curr_ptr); break; case otl_var_double: (*str_)>>*OTL_RCAST(double*,curr_ptr); break; case otl_var_float: (*str_)>>*OTL_RCAST(float*,curr_ptr); break; case otl_var_int: (*str_)>>*OTL_RCAST(int*,curr_ptr); break; case otl_var_unsigned_int: (*str_)>>*OTL_RCAST(unsigned*,curr_ptr); break; case otl_var_short: (*str_)>>*OTL_RCAST(short int*,curr_ptr); break; case otl_var_long_int: (*str_)>>*OTL_RCAST(long int*,curr_ptr); break; case otl_var_raw: (*str_)>>*OTL_RCAST(otl_long_string*,curr_ptr); break; case otl_var_timestamp: case otl_var_db2time: case otl_var_db2date: case otl_var_tz_timestamp: case otl_var_ltz_timestamp: (*str_)>>*OTL_RCAST(otl_datetime*,curr_ptr); break; case otl_var_varchar_long: case otl_var_raw_long: case otl_var_clob: case otl_var_blob: #if !defined(OTL_ORA7) if(lob_stream_mode_flag_) (*str_)>>*OTL_RCAST(OTLLobStream*,curr_ptr); else #endif (*str_)>>*OTL_RCAST(otl_long_string*,curr_ptr); break; #if defined(OTL_BIGINT) case otl_var_bigint: (*str_)>>*OTL_RCAST(OTL_BIGINT*,curr_ptr); break; #endif } out_vars_null_arr_[i]=str_->is_null()==1; } return true; } #if !defined(OTL_ORA7) void get(const int pos, OTLLobStream*& s) { check_pos(pos); check_type(pos,otl_var_long_string,true); if(!lob_stream_mode_flag_){ char var_info[255]; otl_var_info_var3 (out_vars_[pos-1].name, out_vars_[pos-1].ftype, otl_var_lob_stream, var_info, sizeof(var_info)); throw OTLException (otl_error_msg_25, otl_error_code_25, str_->get_stm_text(), var_info); } unsigned char* curr_ptr=out_vars_arr_[pos-1]; s=OTL_RCAST(OTLLobStream*,curr_ptr); } #endif #if defined(OTL_STL) && !defined(OTL_ORA7) void get(const char* var_name,OTLLobStream*& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) && !defined(OTL_ORA7) void get(const char* var_name,OTLLobStream*& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, char& c) { check_pos(pos); check_type(pos,otl_var_char); unsigned char* curr_ptr=out_vars_arr_[pos-1]; c=OTL_SCAST(char,*curr_ptr); } #if defined(OTL_STL) void get(const char* var_name, char& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, char& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, unsigned char& c) { check_pos(pos); check_type(pos,otl_var_char); unsigned char* curr_ptr=out_vars_arr_[pos-1]; c=*curr_ptr; } #if defined(OTL_STL) void get(const char* var_name, unsigned char& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, unsigned char& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, char* s) { check_pos(pos); check_type(pos,otl_var_char); unsigned char* curr_ptr=out_vars_arr_[pos-1]; otl_strcpy(OTL_RCAST(unsigned char*,s), OTL_RCAST(const unsigned char*,curr_ptr)); } #if defined(OTL_STL) void get(const char* var_name, char* n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, char* n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, unsigned char* s) { check_pos(pos); check_type(pos,otl_var_char); unsigned char* curr_ptr=out_vars_arr_[pos-1]; otl_strcpy(OTL_RCAST(unsigned char*,s),OTL_RCAST(const unsigned char*,curr_ptr)); } #if defined(OTL_STL) void get(const char* var_name, unsigned char* n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, unsigned char* n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, unsigned int& n) { check_pos(pos); void* curr_ptr=out_vars_arr_[pos-1]; #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #else int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #endif if(match_found)return; check_type(pos,otl_var_unsigned_int); } #if defined(OTL_STL) void get(const char* var_name, unsigned int& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, unsigned int& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, int& n) { check_pos(pos); void* curr_ptr=out_vars_arr_[pos-1]; #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #else int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #endif if(match_found)return; check_type(pos,otl_var_unsigned_int); } #if defined(OTL_STL) void get(const char* var_name, int& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, int& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, short int& n) { check_pos(pos); void* curr_ptr=out_vars_arr_[pos-1]; #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #else int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #endif if(match_found)return; check_type(pos,otl_var_short); } #if defined(OTL_STL) void get(const char* var_name, short int& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, short int& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, long int& n) { check_pos(pos); void* curr_ptr=out_vars_arr_[pos-1]; #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #else int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #endif if(match_found)return; check_type(pos,otl_var_long_int); } #if defined(OTL_STL) void get(const char* var_name, long int& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, long int& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, float& n) { check_pos(pos); void* curr_ptr=out_vars_arr_[pos-1]; #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #else int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #endif if(match_found)return; check_type(pos,otl_var_double); } #if defined(OTL_STL) void get(const char* var_name, float& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, float& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, double& n) { check_pos(pos); void* curr_ptr=out_vars_arr_[pos-1]; #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #else int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #endif if(match_found)return; check_type(pos,otl_var_double); } #if defined(OTL_STL) void get(const char* var_name, double& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, double& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif #if defined(OTL_BIGINT) void get(const int pos, OTL_BIGINT& n) { check_pos(pos); void* curr_ptr=out_vars_arr_[pos-1]; #if defined(OTL_STRICT_NUMERIC_TYPE_CHECK_ON_SELECT) int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #else int match_found=otl_numeric_convert_T (out_vars_[pos-1].ftype, curr_ptr, n); #endif if(match_found)return; #if defined(OTL_STR_TO_BIGINT) && defined(OTL_BIGINT_TO_STR) if(out_vars_[pos-1].ftype==otl_var_char){ char* temp_val=OTL_RCAST(char*,curr_ptr); #if defined(OTL_DEFAULT_NUMERIC_NULL_TO_VAL) if(is_null(pos)){ n=OTL_SCAST(OTL_BIGINT,OTL_DEFAULT_NUMERIC_NULL_TO_VAL); return; } #endif OTL_STR_TO_BIGINT(temp_val,n); return; } check_type(pos,otl_var_bigint); #else check_type(pos,otl_var_bigint); #endif } #if defined(OTL_STL) void get(const char* var_name, OTL_BIGINT& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, OTL_BIGINT& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif #endif bool is_null(const int pos) { check_pos(pos); return out_vars_null_arr_[pos-1]; } #if defined(OTL_STL) bool is_null(const char* var_name) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); return is_null((*it).second+1); } #endif #if defined(OTL_ACE) bool is_null(const char* var_name) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); return is_null(it->item()+1); } #endif #if defined(OTL_STL) || defined(USER_DEFINED_STRING_CLASS) void get(const int pos, OTL_STRING_CONTAINER& s) { check_pos(pos); otl_var_desc& curr_var=out_vars_[pos-1]; unsigned char* curr_ptr=out_vars_arr_[pos-1]; switch(curr_var.ftype){ case otl_var_varchar_long: case otl_var_raw_long: case otl_var_clob: case otl_var_blob: { otl_long_string* ls=OTL_RCAST(otl_long_string*,curr_ptr); int len=ls->len(); s.assign(OTL_RCAST(char*,ls->v),len); } break; case otl_var_char: s=OTL_RCAST(char*,curr_ptr); break; default: { char var_info[255]; otl_var_info_var3 (out_vars_[pos-1].name, out_vars_[pos-1].ftype, otl_var_char, var_info, sizeof(var_info)); throw OTLException (otl_error_msg_23, otl_error_code_23, str_->get_stm_text(), var_info); } } } #endif #if defined(OTL_STL) void get(const char* var_name, OTL_STRING_CONTAINER& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, OTL_STRING_CONTAINER& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, otl_long_string& s) { check_pos(pos); check_type(pos,otl_var_long_string); unsigned char* curr_ptr=out_vars_arr_[pos-1]; s=*OTL_RCAST(otl_long_string*,curr_ptr); } #if defined(OTL_STL) void get(const char* var_name, otl_long_string& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, otl_long_string& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, otl_long_string*& s) { check_pos(pos); check_type(pos,otl_var_long_string); unsigned char* curr_ptr=out_vars_arr_[pos-1]; s=OTL_RCAST(otl_long_string*,curr_ptr); } #if defined(OTL_STL) void get(const char* var_name, otl_long_string*& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, otl_long_string*& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif void get(const int pos, otl_datetime& s) { check_pos(pos); check_type(pos,otl_var_timestamp); unsigned char* curr_ptr=out_vars_arr_[pos-1]; s=*OTL_RCAST(otl_datetime*,curr_ptr); } #if defined(OTL_STL) void get(const char* var_name, otl_datetime& n) { var_name2pos_map_type::iterator it=var_name2pos_map_.find(var_name); check_name(it,var_name); get((*it).second+1,n); } #endif #if defined(OTL_ACE) void get(const char* var_name, otl_datetime& n) { var_name2pos_map_type::ENTRY* it=0; var_name2pos_map_.find(var_name,it); check_name(it,var_name); get(it->item()+1,n); } #endif protected: otl_var_desc* out_vars_; int out_vars_len_; OTLStream* str_; unsigned char** out_vars_arr_; bool* out_vars_null_arr_; bool out_vars_constructed_; bool lob_stream_mode_flag_; #if defined(OTL_STL) typedef STD_NAMESPACE_PREFIX map var_name2pos_map_type; var_name2pos_map_type var_name2pos_map_; #endif #if defined(OTL_ACE) typedef ACE_RB_Tree var_name2pos_map_type; var_name2pos_map_type var_name2pos_map_; #endif void check_pos(const int pos) { int actual_pos=pos-1; if(actual_pos<0 || actual_pos>out_vars_len_-1){ throw OTLException (otl_error_msg_22, otl_error_code_22, str_->get_stm_text()); } } #if defined(OTL_STL) void check_name(var_name2pos_map_type::iterator& it, const char* var_name) { if(it==var_name2pos_map_.end()) throw OTLException (otl_error_msg_26, otl_error_code_26, str_->get_stm_text(), var_name); } #endif #if defined(OTL_ACE) void check_name(var_name2pos_map_type::ENTRY* it,const char* var_name) { if(!it){ throw OTLException (otl_error_msg_26, otl_error_code_26, str_->get_stm_text(), var_name); } } #endif void check_type(const int pos, const int type_code, const bool lob_stream_arg=false) { switch(out_vars_[pos-1].ftype){ case otl_var_timestamp: case otl_var_tz_timestamp: case otl_var_ltz_timestamp: if(type_code==otl_var_timestamp) return; case otl_var_varchar_long: case otl_var_raw_long: case otl_var_clob: case otl_var_blob: if(type_code==otl_var_long_string) return; case otl_var_raw: if(type_code==otl_var_long_string && lob_stream_mode_flag_ && lob_stream_arg){ char var_info1[255]; otl_var_info_var4 (out_vars_[pos-1].name, out_vars_[pos-1].ftype, otl_var_lob_stream, var_info1, sizeof(var_info1)); throw OTLException (otl_error_msg_28, otl_error_code_28, str_->get_stm_text(), var_info1); }else return; default: if(out_vars_[pos-1].ftype==type_code) return; } char var_info2[255]; otl_var_info_var3 (out_vars_[pos-1].name, out_vars_[pos-1].ftype, type_code, var_info2, sizeof(var_info2)); throw OTLException (otl_error_msg_23, otl_error_code_23, str_->get_stm_text(), var_info2); } void set(void) { out_vars_=0; out_vars_len_=0; str_=0; out_vars_arr_=0; out_vars_null_arr_=0; out_vars_constructed_=false; lob_stream_mode_flag_=false; } void reset(void) { if(out_vars_constructed_){ for(int i=0;iget_adb_max_long_size())); break; #if defined(OTL_BIGINT) case otl_var_bigint: out_vars_arr_[i]=OTL_RCAST(unsigned char*,new OTL_BIGINT(0)); break; #endif } #if defined(OTL_STL) var_name2pos_map_[curr_var.name]=i; #endif #if defined(OTL_ACE) var_name2pos_map_.bind(curr_var.name,i); #endif } out_vars_constructed_=true; } private: otl_stream_read_iterator(const otl_stream_read_iterator&): out_vars_(0), out_vars_len_(0), str_(0), out_vars_arr_(0), out_vars_null_arr_(0), out_vars_constructed_(0), lob_stream_mode_flag_(false) #if defined(OTL_STL) ,var_name2pos_map_() #endif #if defined(OTL_ACE) ,var_name2pos_map_() #endif { } otl_stream_read_iterator& operator=(const otl_stream_read_iterator&) { return *this; } }; #endif #if defined(OTL_ORA_TEXT_ON)&&defined(text) #undef text #endif #endif saga-2.3.1/src/modules/db/db_odbc/get_connection.h0000744000175000017500000001455712737416155023163 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: get_connection.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_odbc // // // //-------------------------------------------------------// // // // Get_Connection.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Get_Connection_H #define HEADER_INCLUDED__Get_Connection_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGet_Servers : public CSG_Module { public: CGet_Servers(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGet_Connection : public CSG_Module { public: CGet_Connection(void); protected: virtual bool On_Before_Execution (void); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDel_Connection : public CSG_ODBC_Module { public: CDel_Connection(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDel_Connections : public CSG_Module { public: CDel_Connections(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Before_Execution (void); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTransaction : public CSG_ODBC_Module { public: CTransaction(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Before_Execution (void); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CExecute_SQL : public CSG_ODBC_Module { public: CExecute_SQL(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Get_Connection_H saga-2.3.1/src/modules/db/db_odbc/table.h0000744000175000017500000001517312737416155021247 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_odbc // // // //-------------------------------------------------------// // // // Table.h // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Table_H #define HEADER_INCLUDED__Table_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_List : public CSG_ODBC_Module { public: CTable_List(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Info : public CSG_ODBC_Module { public: CTable_Info(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Load : public CSG_ODBC_Module { public: CTable_Load(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tables") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Save : public CSG_ODBC_Module { public: CTable_Save(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tables") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Drop : public CSG_ODBC_Module { public: CTable_Drop(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tables") ); } protected: virtual void On_Connection_Changed (CSG_Parameters *pParameters); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Query : public CSG_ODBC_Module { public: CTable_Query(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tables") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Table_H saga-2.3.1/src/modules/db/db_odbc/Makefile.in0000664000175000017500000005540612737447615022065 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/db/db_odbc ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libdb_odbc_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libdb_odbc_la_OBJECTS = get_connection.lo MLB_Interface.lo odbc.lo \ table.lo libdb_odbc_la_OBJECTS = $(am_libdb_odbc_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdb_odbc_la_SOURCES) DIST_SOURCES = $(libdb_odbc_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1828 2013-09-05 21:36:10Z manfred-e $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) $(DEP_LIBS) -shared -lodbc -avoid-version pkglib_LTLIBRARIES = libdb_odbc.la libdb_odbc_la_SOURCES = \ get_connection.cpp\ MLB_Interface.cpp\ odbc.cpp\ table.cpp\ get_connection.h\ MLB_Interface.h\ odbc.h\ otlv4.h\ table.h libdb_odbc_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/db/db_odbc/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/db/db_odbc/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libdb_odbc.la: $(libdb_odbc_la_OBJECTS) $(libdb_odbc_la_DEPENDENCIES) $(EXTRA_libdb_odbc_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libdb_odbc_la_OBJECTS) $(libdb_odbc_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_connection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/odbc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/table.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/db/db_odbc/odbc.h0000744000175000017500000002524612737416155021071 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: saga_odbc.h 1507 2012-10-31 18:49:02Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_odbc // // // //-------------------------------------------------------// // // // saga_odbc.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__saga_odbc_H #define HEADER_INCLUDED__saga_odbc_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef db_odbc_EXPORTS #define db_odbc_EXPORT _SAGA_DLL_EXPORT #else #define db_odbc_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SG_ODBC_PRIMARY_KEY 0x01 #define SG_ODBC_NOT_NULL 0x02 #define SG_ODBC_UNIQUE 0x04 //--------------------------------------------------------- typedef enum ESG_ODBC_DBMS { SG_ODBC_DBMS_PostgreSQL, SG_ODBC_DBMS_MySQL, SG_ODBC_DBMS_Oracle, SG_ODBC_DBMS_MSSQLServer, SG_ODBC_DBMS_Access, SG_ODBC_DBMS_Unknown } TSG_ODBC_DBMS; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class db_odbc_EXPORT CSG_ODBC_Connection { friend class CSG_ODBC_Connections; public: bool is_Connected (void) const { return( m_pConnection != NULL ); } void Set_Auto_Commit (bool bOn); bool Get_Auto_Commit (void) const { return( m_bAutoCommit ); } int Get_Size_Buffer (void) const { return( m_Size_Buffer ); } bool Set_Size_Buffer (int Size); int Get_Size_LOB_Max (void) const; bool Set_Size_LOB_Max (int Size); CSG_String Get_DBMS_Name (void) const; CSG_String Get_DBMS_Version (void) const; TSG_ODBC_DBMS Get_DBMS (void) const { return( m_DBMS ); } bool is_PostgreSQL (void) const { return( m_DBMS == SG_ODBC_DBMS_PostgreSQL ); } bool is_MySQL (void) const { return( m_DBMS == SG_ODBC_DBMS_MySQL ); } bool is_Oracle (void) const { return( m_DBMS == SG_ODBC_DBMS_Oracle ); } bool is_MSSQLServer (void) const { return( m_DBMS == SG_ODBC_DBMS_MSSQLServer ); } bool is_Access (void) const { return( m_DBMS == SG_ODBC_DBMS_Access ); } CSG_String Get_Server (void) const { return( m_DSN ); } int Get_Tables (CSG_Strings &Tables) const; CSG_String Get_Tables (void) const; CSG_String Get_Field_Names (const CSG_String &Table_Name) const; CSG_Table Get_Field_Desc (const CSG_String &Table_Name) const; bool Execute (const CSG_String &SQL, bool bCommit = false); bool Commit (void); bool Rollback (void); bool Table_Exists (const CSG_String &Table_Name) const; bool Table_Create (const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags = 0, bool bCommit = true); bool Table_Drop (const CSG_String &Table_Name , bool bCommit = true); bool Table_Insert (const CSG_String &Table_Name, const CSG_Table &Table , bool bCommit = true); bool Table_Save (const CSG_String &Table_Name, const CSG_Table &Table, const CSG_Buffer &Flags = 0, bool bCommit = true); bool Table_Load (CSG_Table &Table , const CSG_String &Table_Name , bool bLOB = false); bool Table_Load (CSG_Table &Table , const CSG_String &Table_Names, const CSG_String &Fields, const CSG_String &Where = SG_T(""), const CSG_String &Group = SG_T(""), const CSG_String &Having = SG_T(""), const CSG_String &Order = SG_T(""), bool bDistinct = false, bool bLOB = false); bool Table_Load_BLOBs (CSG_Bytes_Array &BLOBs, const CSG_String &Table_Name , const CSG_String &Field , const CSG_String &Where = SG_T(""), const CSG_String &Order = SG_T("")); private: CSG_ODBC_Connection(const CSG_String &Server, const CSG_String &User, const CSG_String &Password, bool bAutoCommit = false); virtual ~CSG_ODBC_Connection(void); TSG_ODBC_DBMS m_DBMS; bool m_bAutoCommit; int m_Size_Buffer; void *m_pConnection; CSG_String m_DSN; CSG_String _Get_DBMS_Info (int What) const; int _Get_Type_To_SQL (TSG_Data_Type Type); TSG_Data_Type _Get_Type_From_SQL (int Type); bool _Table_Load (CSG_Table &Table, const CSG_String &Select, const CSG_String &Name, bool bLOB); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class db_odbc_EXPORT CSG_ODBC_Connections { public: CSG_ODBC_Connections(void); virtual ~CSG_ODBC_Connections(void); bool Create (void); bool Destroy (void); int Get_Servers (CSG_String &Servers); int Get_Servers (CSG_Strings &Servers); CSG_Strings Get_Servers (void); int Get_Connections (CSG_String &Connections); CSG_Strings Get_Connections (void); int Get_Count (void) { return( m_nConnections ); } CSG_ODBC_Connection * Get_Connection (int Index) { return( Index >= 0 && Index < m_nConnections ? m_pConnections[Index] : NULL ); } CSG_ODBC_Connection * Get_Connection (const CSG_String &Server); CSG_ODBC_Connection * Add_Connection (const CSG_String &Server, const CSG_String &User, const CSG_String &Password); bool Del_Connection (int Index , bool bCommit); bool Del_Connection (const CSG_String &Server , bool bCommit); bool Del_Connection (CSG_ODBC_Connection *pConnection, bool bCommit); private: void *m_hEnv; int m_nConnections; CSG_ODBC_Connection **m_pConnections; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class db_odbc_EXPORT CSG_ODBC_Module : public CSG_Module { public: CSG_ODBC_Module(void); protected: virtual bool On_Before_Execution (void); virtual bool On_After_Execution (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual void On_Connection_Changed (CSG_Parameters *pParameters) {} CSG_ODBC_Connection * Get_Connection (void) { return( m_pConnection ); } static bool Set_Constraints (CSG_Parameters *pParameters, CSG_Table *pTable); static CSG_Buffer Get_Constraints (CSG_Parameters *pParameters, CSG_Table *pTable); private: CSG_ODBC_Connection *m_pConnection; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- db_odbc_EXPORT CSG_ODBC_Connections & SG_ODBC_Get_Connection_Manager (void); //--------------------------------------------------------- db_odbc_EXPORT bool SG_ODBC_is_Supported (void); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__saga_odbc_H saga-2.3.1/src/modules/db/db_odbc/Makefile.am0000744000175000017500000000117212737416155022035 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1828 2013-09-05 21:36:10Z manfred-e $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) $(DEP_LIBS) -shared -lodbc -avoid-version pkglib_LTLIBRARIES = libdb_odbc.la libdb_odbc_la_SOURCES =\ get_connection.cpp\ MLB_Interface.cpp\ odbc.cpp\ table.cpp\ get_connection.h\ MLB_Interface.h\ odbc.h\ otlv4.h\ table.h libdb_odbc_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/db/db_odbc/MLB_Interface.h0000744000175000017500000000736512737416155022556 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_odbc // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2004 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__db_odbc_H #define HEADER_INCLUDED__db_odbc_H //--------------------------------------------------------- #include "odbc.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__db_odbc_H saga-2.3.1/src/modules/db/db_odbc/MLB_Interface.cpp0000744000175000017500000001312412737416155023077 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // db_odbc // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2004 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("ODBC/OTL") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("O.Conrad (c) 2010") ); case MLB_INFO_Description: return( _TW( "Database access via Open Data Base Connection (ODBC) interface. " "Based on the OTL (Oracle, Odbc and DB2-CLI Template Library), Version 4.0: " "http://otl.sourceforge.net/" )); case MLB_INFO_Version: return( _TL("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Database|ODBC") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "get_connection.h" #include "table.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 9: return( new CGet_Servers ); case 0: return( new CGet_Connection ); case 1: return( new CDel_Connection ); case 11: return( new CDel_Connections ); case 2: return( new CTransaction ); case 3: return( new CExecute_SQL ); case 10: return( new CTable_List ); case 4: return( new CTable_Info ); case 5: return( new CTable_Load ); case 6: return( new CTable_Save ); case 7: return( new CTable_Drop ); case 8: return( new CTable_Query ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- extern "C" _SAGA_DLL_EXPORT bool MLB_Finalize (void) { return( SG_ODBC_Get_Connection_Manager().Destroy() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE_CORE MLB_INTERFACE_INITIALIZE //}}AFX_SAGA saga-2.3.1/src/modules/projection/0000775000175000017500000000000012737740006020207 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/projection/Makefile.in0000664000175000017500000004655612737447617022310 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/projection ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = pj_georeference pj_proj4 all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/projection/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/projection/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/projection/pj_proj4/0000775000175000017500000000000012737740006021736 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/projection/pj_proj4/crs_transform_grid.h0000744000175000017500000001215612737416202026000 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_grid.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_transform_grid_H #define HEADER_INCLUDED__crs_transform_grid_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Transform_Grid : public CCRS_Transform { public: CCRS_Transform_Grid(bool bList); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute_Transformation (void); private: bool m_bList; TSG_Grid_Resampling m_Resampling; CSG_Parameters_Grid_Target m_Grid_Target; CSG_Grid m_Target_Area; bool Transform (CSG_Grid *pGrid ); bool Transform (CSG_Parameter_Grid_List *pGrids); bool Transform (CSG_Grid *pGrid , CSG_Grid *pTarget ); bool Transform (CSG_Parameter_Grid_List *pGrids, CSG_Parameter_Grid_List *pTargets, const CSG_Grid_System &Target_System); bool Transform (CSG_Grid *pGrid , CSG_Shapes *pPoints); bool Transform (CSG_Parameter_Grid_List *pGrids, CSG_Shapes *pPoints); void Get_MinMax (TSG_Rect &r, double x, double y); bool Get_Target_System (const CSG_Grid_System &System, bool bEdge); bool Set_Target_Area (const CSG_Grid_System &Source, const CSG_Grid_System &Target); bool is_In_Target_Area (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_transform_grid_H saga-2.3.1/src/modules/projection/pj_proj4/crs_grid_geogcoords.cpp0000744000175000017500000001320312737416202026445 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_grid_geogcoords.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_grid_geogcoords.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Grid_GeogCoords::CCRS_Grid_GeogCoords(void) { //----------------------------------------------------- Set_Name (_TL("Geographic Coordinate Grids")); Set_Author ("O. Conrad (c) 2014"); Set_Description (_TW( "Creates for a given grid geographic coordinate information, " "i.e. two grids specifying the longitude and latitude for each cell. " "The coodinate system of the input grid has to be defined. " )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "LON" , _TL("Longitude"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "LAT" , _TL("Latitude"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Grid_GeogCoords::On_Execute(void) { CSG_CRSProjector Projector; if( !Projector.Set_Source(Parameters("GRID")->asGrid()->Get_Projection()) ) { Error_Set(_TL("Could not initialize grid projection.")); return( false ); } Projector.Set_Target(CSG_Projection("+proj=longlat +ellps=WGS84 +datum=WGS84", SG_PROJ_FMT_Proj4)); //----------------------------------------------------- CSG_Grid *pLon = Parameters("LON")->asGrid(); CSG_Grid *pLat = Parameters("LAT")->asGrid(); for(int y=0; ySet_Value(x, y, p.Get_X()); pLat->Set_Value(x, y, p.Get_Y()); } else { pLon->Set_NoData(x, y); pLat->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/gcs_graticule.h0000744000175000017500000001110712737416202024717 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // gcs_graticule.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gcs_graticule_H #define HEADER_INCLUDED__gcs_graticule_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGCS_Graticule : public CCRS_Base { public: CGCS_Graticule(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_CRSProjector m_Projector; bool Get_Graticule (const CSG_Rect &Extent); bool Get_Extent (const CSG_Rect &Extent, CSG_Rect &rGCS); bool Get_Coordinate (const CSG_Rect &Extent, CSG_Shapes *pCoordinates, CSG_Shape *pLine, int Axis); double Get_Interval (const CSG_Rect &Extent); CSG_String Get_Degree (double Value, int Precision); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gcs_graticule_H saga-2.3.1/src/modules/projection/pj_proj4/crs_assign.h0000744000175000017500000001005012737416201024232 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_assign.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_assign_H #define HEADER_INCLUDED__crs_assign_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Assign : public CCRS_Base { public: CCRS_Assign(void); protected: virtual bool On_Execute (void); private: int Set_Projections (const CSG_Projection &Projection, CSG_Parameter_List *pList); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_assign_H saga-2.3.1/src/modules/projection/pj_proj4/crs_transform_shapes.cpp0000744000175000017500000001667412737416202026702 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_shapes.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_transform_shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Transform_Shapes::CCRS_Transform_Shapes(bool bList) { m_bList = bList; //----------------------------------------------------- Set_Name (m_bList ? _TL("Coordinate Transformation (Shapes List)") : _TL("Coordinate Transformation (Shapes)") ); Set_Author (SG_T("O. Conrad (c) 2010")); Set_Description (_TW( "Coordinate transformation for shapes.\n" )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- if( m_bList ) { Parameters.Add_Shapes_List( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes_List( NULL , "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } //----------------------------------------------------- else { Parameters.Add_Shapes( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Shapes::On_Execute_Transformation(void) { if( m_bList ) { CSG_Parameter_Shapes_List *pSources, *pTargets; pSources = Parameters("SOURCE")->asShapesList(); pTargets = Parameters("TARGET")->asShapesList(); pTargets->Del_Items(); for(int i=0; iGet_Count() && Process_Get_Okay(false); i++) { CSG_Shapes *pSource = pSources->asShapes(i); CSG_Shapes *pTarget = SG_Create_Shapes(pSource); if( Transform(pSource, pTarget) ) { pTargets->Add_Item(pTarget); } else { delete(pTarget); } } return( pTargets->Get_Count() > 0 ); } else { CSG_Shapes *pSource = Parameters("SOURCE")->asShapes(); CSG_Shapes *pTarget = Parameters("TARGET")->asShapes(); if( pSource == pTarget ) { pTarget = SG_Create_Shapes(pSource); if( Transform(pSource, pTarget) ) { pSource->Assign(pTarget); return( true ); } else { delete(pTarget); return( false ); } } else { pTarget->Create(pSource->Get_Type(), pSource->Get_Name(), pSource, pSource->Get_Vertex_Type()); } return( Transform(pSource, pTarget) ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Shapes::Transform(CSG_Shapes *pSource, CSG_Shapes *pTarget) { if( !pTarget || !pSource || !pSource->is_Valid() ) { return( false ); } if( !m_Projector.Set_Source(pSource->Get_Projection()) ) { return( false ); } int nDropped = 0; Process_Set_Text(CSG_String::Format(SG_T("%s: %s"), _TL("Processing"), pSource->Get_Name())); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pSource->Get_Count()); iShape++) { CSG_Shape *pShape_Source = pSource->Get_Shape(iShape); CSG_Shape *pShape_Target = pTarget->Add_Shape(pShape_Source, SHAPE_COPY_ATTR); for(int iPart=0; iPartGet_Part_Count() && pShape_Target; iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart) && pShape_Target; iPoint++) { TSG_Point Point = pShape_Source->Get_Point(iPoint, iPart); if( m_Projector.Get_Projection(Point.x, Point.y) ) { pShape_Target->Add_Point(Point.x, Point.y, iPart); } else { nDropped++; pTarget->Del_Shape(pShape_Target); pShape_Target = NULL; } } } } if( nDropped > 0 ) { Message_Add(CSG_String::Format(SG_T("%s: %d %s"), pTarget->Get_Name(), nDropped, _TL("shapes have been dropped"))); } pTarget->Get_Projection() = m_Projector.Get_Target(); return( pTarget->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/crs_transform.h0000744000175000017500000001216012737416202024766 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_transform_H #define HEADER_INCLUDED__crs_transform_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CSG_CRSProjector { public: CSG_CRSProjector(void); virtual ~CSG_CRSProjector(void); bool Destroy (void); static CSG_String Get_Version (void); static CSG_String Get_Description (void); bool Set_Source (const CSG_Projection &Projection); const CSG_Projection & Get_Source (void) const { return( m_Source ); } bool Set_Target (const CSG_Projection &Projection); const CSG_Projection & Get_Target (void) const { return( m_Target ); } bool Set_Inverse (bool bOn = true); bool Get_Inverse (void) const { return( m_bInverse ); } bool Set_Precise_Mode (bool bOn = true); bool Get_Precise_Mode (void) const { return( m_pGCS != NULL ); } bool Get_Projection (double &x, double &y) const; bool Get_Projection (TSG_Point &Point) const; bool Get_Projection (CSG_Point &Point) const; bool Get_Projection (double &x, double &y, double &z) const; bool Get_Projection (TSG_Point_Z &Point) const; bool Get_Projection (CSG_Point_Z &Point) const; private: bool m_bInverse; void *m_pSource, *m_pTarget, *m_pGCS; CSG_Projection m_Source, m_Target; bool _Set_Projection (const CSG_Projection &Projection, void **ppProjection, bool bInverse); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_transform_H saga-2.3.1/src/modules/projection/pj_proj4/crs_assign.cpp0000744000175000017500000001430212737416201024571 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_assign.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_assign.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Assign::CCRS_Assign(void) { //----------------------------------------------------- Set_Name (_TL("Set Coordinate Reference System")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "The module allows one to define the Coordinate Reference System (CRS) " "of the supplied data sets. The module applies no transformation to " "the data sets, it just updates their CRS metadata.\n" "A complete and correct description of the CRS of a dataset is necessary " "in order to be able to actually apply a projection with one of the " "'Coordinate Transformation' modules later.\n\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT_OPTIONAL ); // Parameters.Add_TIN_List( // NULL , "TINS" , _TL("TINs"), // _TL(""), // PARAMETER_INPUT_OPTIONAL // ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Assign::On_Execute(void) { int nTotal = Parameters("GRIDS" )->asList()->Get_Count() + Parameters("SHAPES")->asList()->Get_Count(); // + Parameters("TINS" )->asList()->Get_Count(); if( nTotal <= 0 ) { Message_Dlg(_TL("nothing to do: no data in selection")); return( false ); } //----------------------------------------------------- CSG_Projection Projection; if( !Get_Projection(Projection) ) { return( false ); } //----------------------------------------------------- int nProjected = 0; nProjected += Set_Projections(Projection, Parameters("GRIDS" )->asList()); nProjected += Set_Projections(Projection, Parameters("SHAPES")->asList()); // nProjected += Set_Projections(Projection, Parameters("TINS") ->asList()); //----------------------------------------------------- return( nProjected > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CCRS_Assign::Set_Projections(const CSG_Projection &Projection, CSG_Parameter_List *pList) { int nProjected = 0; for(int i=0; iGet_Count(); i++) { if( pList->asDataObject(i)->Get_Projection().Create(Projection) ) { pList->asDataObject(i)->Set_Modified(); DataObject_Update(pList->asDataObject(i)); nProjected++; } } return( nProjected ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/gcs_graticule.cpp0000744000175000017500000004321012737416202025252 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // gcs_graticule.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gcs_graticule.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define AXIS_LEFT 1 #define AXIS_RIGHT 2 #define AXIS_BOTTOM 3 #define AXIS_TOP 4 //--------------------------------------------------------- enum { DEG_PREC_AUTO, DEG_PREC_FULL, DEG_PREC_SEC, DEG_PREC_MIN, DEG_PREC_DEG }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGCS_Graticule::CGCS_Graticule(void) { CSG_Parameter *pNode_0, *pNode_1; //----------------------------------------------------- Set_Name (_TL("Latitude/Longitude Graticule")); Set_Author (SG_T("O. Conrad (c) 2014")); Set_Description (_TW( "Creates a longitude/latitude graticule for the extent and projection of the input shapes layer. " )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "GRATICULE" , _TL("Graticule"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "COORDS" , _TL("Frame Coordinates"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); pNode_0 = Parameters.Add_Node( NULL , "NODE_GRID" , _TL("Graticule"), _TL("") ); pNode_1 = Parameters.Add_Node(pNode_0, "NODE_X" , _TL("X Range"), _TL("")); Parameters.Add_Value(pNode_1, "XMIN", _TL("Minimum"), _TL(""), PARAMETER_TYPE_Double); Parameters.Add_Value(pNode_1, "XMAX", _TL("Maximum"), _TL(""), PARAMETER_TYPE_Double); pNode_1 = Parameters.Add_Node(pNode_0, "NODE_Y" , _TL("Y Range"), _TL("")); Parameters.Add_Value(pNode_1, "YMIN", _TL("Minimum"), _TL(""), PARAMETER_TYPE_Double); Parameters.Add_Value(pNode_1, "YMAX", _TL("Maximum"), _TL(""), PARAMETER_TYPE_Double); Parameters.Add_Choice( pNode_0 , "INTERVAL" , _TL("Interval"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("fixed interval"), _TL("fitted interval") ), 0 ); Parameters.Add_Value( pNode_0 , "FIXED" , _TL("Fixed Interval (Degree)"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true, 20.0 ); Parameters.Add_Value( pNode_0 , "FITTED" , _TL("Number of Intervals"), _TL(""), PARAMETER_TYPE_Int, 10, 1, true ); Parameters.Add_Value( pNode_0 , "RESOLUTION" , _TL("Minimum Resolution (Degree)"), _TL(""), PARAMETER_TYPE_Double, 0.5, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGCS_Graticule::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CRS_GRID" )) || !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CRS_SHAPES")) ) { CSG_Rect r(!SG_STR_CMP(pParameter->Get_Identifier(), SG_T("CRS_GRID")) ? pParameter->asParameters()->Get_Parameter("PICK")->asGrid ()->Get_Extent() : pParameter->asParameters()->Get_Parameter("PICK")->asShapes()->Get_Extent() ); if( r.Get_XRange() > 0.0 && r.Get_YRange() > 0.0 ) { pParameters->Get_Parameter("XMIN")->Set_Value(r.Get_XMin()); pParameters->Get_Parameter("XMAX")->Set_Value(r.Get_XMax()); pParameters->Get_Parameter("YMIN")->Set_Value(r.Get_YMin()); pParameters->Get_Parameter("YMAX")->Set_Value(r.Get_YMax()); } } return( CCRS_Base::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CGCS_Graticule::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("INTERVAL")) ) { pParameters->Get_Parameter("FIXED" )->Set_Enabled(pParameter->asInt() == 0); pParameters->Get_Parameter("FITTED")->Set_Enabled(pParameter->asInt() == 1); } return( CCRS_Base::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGCS_Graticule::On_Execute(void) { //----------------------------------------------------- CSG_Projection Projection; if( !Get_Projection(Projection) ) { return( false ); } //----------------------------------------------------- m_Projector.Set_Source(CSG_Projection("+proj=longlat +ellps=WGS84 +datum=WGS84", SG_PROJ_FMT_Proj4)); if( !m_Projector.Set_Target(Projection) ) { m_Projector.Destroy(); return( false ); } //----------------------------------------------------- CSG_Rect Extent( Parameters("XMIN")->asDouble(), Parameters("YMIN")->asDouble(), Parameters("XMAX")->asDouble(), Parameters("YMAX")->asDouble() ); if( !Get_Graticule(Extent) ) { m_Projector.Destroy(); return( false ); } //----------------------------------------------------- m_Projector.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGCS_Graticule::Get_Graticule(const CSG_Rect &Extent) { double x, y, Interval; CSG_Rect r; if( !Get_Extent(Extent, r) || (Interval = Get_Interval(r)) <= 0.0 ) { return( false ); } //----------------------------------------------------- r.m_rect.xMin = Interval * floor(r.Get_XMin() / Interval); r.m_rect.xMax = Interval * ceil (r.Get_XMax() / Interval); r.m_rect.yMin = Interval * floor(r.Get_YMin() / Interval); r.m_rect.yMax = Interval * ceil (r.Get_YMax() / Interval); r.Inflate(Interval, false); if( r.Get_XMin() < -180.0 ) r.m_rect.xMin = -180.0; if( r.Get_XMax() > 180.0 ) r.m_rect.xMax = 180.0; if( r.Get_YMin() < -90.0 ) r.m_rect.yMin = -90.0; if( r.Get_YMax() > 90.0 ) r.m_rect.yMax = 90.0; //----------------------------------------------------- double Resolution = Parameters("RESOLUTION")->asDouble(); if( Resolution <= 0.0 ) Resolution = Interval; if( Interval > Resolution ) { Resolution = Interval / ceil(Interval / Resolution); } //----------------------------------------------------- CSG_Shapes *pGraticule = Parameters("GRATICULE")->asShapes(); pGraticule->Create(SHAPE_TYPE_Line); pGraticule->Set_Name(_TL("Graticule")); pGraticule->Add_Field("TYPE" , SG_DATATYPE_String); pGraticule->Add_Field("LABEL" , SG_DATATYPE_String); pGraticule->Add_Field("DEGREE", SG_DATATYPE_Double); //----------------------------------------------------- CSG_Shapes *pCoordinates = Parameters("COORDS")->asShapes(); if( pCoordinates ) { pCoordinates->Create(SHAPE_TYPE_Point); pCoordinates->Set_Name(_TL("Coordinates")); pCoordinates->Add_Field("TYPE" , SG_DATATYPE_String); pCoordinates->Add_Field("LABEL", SG_DATATYPE_String); } //----------------------------------------------------- CSG_Shapes Clip(SHAPE_TYPE_Polygon); CSG_Shape *pClip = Clip.Add_Shape(); pClip->Add_Point(Extent.Get_XMin(), Extent.Get_YMin()); pClip->Add_Point(Extent.Get_XMin(), Extent.Get_YMax()); pClip->Add_Point(Extent.Get_XMax(), Extent.Get_YMax()); pClip->Add_Point(Extent.Get_XMax(), Extent.Get_YMin()); pClip->Add_Point(Extent.Get_XMin(), Extent.Get_YMin()); //----------------------------------------------------- for(y=r.Get_YMin(); y<=r.Get_YMax(); y+=Interval) { CSG_Shape *pLine = pGraticule->Add_Shape(); pLine->Set_Value(0, "LAT"); pLine->Set_Value(1, Get_Degree(y, DEG_PREC_DEG)); pLine->Set_Value(2, y); for(x=r.Get_XMin(); x<=r.Get_XMax(); x+=Interval) { CSG_Point p(x, y); m_Projector.Get_Projection(p); pLine->Add_Point(p); if( Resolution < Interval && x < r.Get_XMax() ) { for(double i=x+Resolution; iAdd_Point(p); } } } Get_Coordinate(Extent, pCoordinates, pLine, AXIS_LEFT); Get_Coordinate(Extent, pCoordinates, pLine, AXIS_RIGHT); if( !SG_Polygon_Intersection(pLine, pClip) ) { pGraticule->Del_Shape(pLine); } } //----------------------------------------------------- for(x=r.Get_XMin(); x<=r.Get_XMax(); x+=Interval) { CSG_Shape *pLine = pGraticule->Add_Shape(); pLine->Set_Value(0, "LON"); pLine->Set_Value(1, Get_Degree(x, DEG_PREC_DEG)); pLine->Set_Value(2, x); for(y=r.Get_YMin(); y<=r.Get_YMax(); y+=Interval) { CSG_Point p(x, y); m_Projector.Get_Projection(p); pLine->Add_Point(p); if( Resolution < Interval && y < r.Get_YMax() ) { for(double i=y+Resolution; iAdd_Point(p); } } } Get_Coordinate(Extent, pCoordinates, pLine, AXIS_BOTTOM); Get_Coordinate(Extent, pCoordinates, pLine, AXIS_TOP); if( !SG_Polygon_Intersection(pLine, pClip) ) { pGraticule->Del_Shape(pLine); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGCS_Graticule::Get_Coordinate(const CSG_Rect &Extent, CSG_Shapes *pCoordinates, CSG_Shape *pLine, int Axis) { if( !pCoordinates || !Extent.Intersects(pLine->Get_Extent()) || pLine->Get_Point_Count(0) < 2 ) { return( false ); } TSG_Point A[2], B[2], C; switch( Axis ) { case AXIS_LEFT : A[0].x = A[1].x = Extent.Get_XMin(); A[0].y = Extent.Get_YMin(); A[1].y = Extent.Get_YMax(); break; case AXIS_RIGHT : A[0].x = A[1].x = Extent.Get_XMax(); A[0].y = Extent.Get_YMin(); A[1].y = Extent.Get_YMax(); break; case AXIS_BOTTOM: A[0].y = A[1].y = Extent.Get_YMin(); A[0].x = Extent.Get_XMin(); A[1].x = Extent.Get_XMax(); break; case AXIS_TOP : A[0].y = A[1].y = Extent.Get_YMax(); A[0].x = Extent.Get_XMin(); A[1].x = Extent.Get_XMax(); break; default: return( false ); } //----------------------------------------------------- B[1] = pLine->Get_Point(0); for(int i=1; iGet_Point_Count(); i++) { B[0] = B[1]; B[1] = pLine->Get_Point(i); if( SG_Get_Crossing(C, A[0], A[1], B[0], B[1], true) ) { CSG_Shape *pPoint = pCoordinates->Add_Shape(); pPoint->Add_Point(C); pPoint->Set_Value(0, CSG_String(pLine->asString(0)) + (Axis == AXIS_LEFT || Axis == AXIS_BOTTOM ? "_MIN" : "_MAX")); pPoint->Set_Value(1, pLine->asString(1)); return( true ); } } //----------------------------------------------------- switch( Axis ) { case AXIS_LEFT : C = pLine->Get_Point(0, 0, true ); break; case AXIS_RIGHT : C = pLine->Get_Point(0, 0, false); break; case AXIS_BOTTOM: C = pLine->Get_Point(0, 0, true ); break; case AXIS_TOP : C = pLine->Get_Point(0, 0, false); break; } if( Extent.Contains(C) ) { CSG_Shape *pPoint = pCoordinates->Add_Shape(); pPoint->Add_Point(C); pPoint->Set_Value(0, CSG_String(pLine->asString(0)) + (Axis == AXIS_LEFT || Axis == AXIS_BOTTOM ? "_MIN" : "_MAX")); pPoint->Set_Value(1, pLine->asString(1)); return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CGCS_Graticule::Get_Interval(const CSG_Rect &Extent) { if( Parameters("INTERVAL")->asInt() == 0 ) { return( Parameters("FIXED")->asDouble() ); } double Interval = Extent.Get_XRange() > Extent.Get_YRange() ? Extent.Get_XRange() : Extent.Get_YRange(); if( Interval > 360 ) { Interval = 360; } Interval = Interval / Parameters("FITTED")->asInt(); double d = pow(10.0, (int)(log10(Interval)) - (Interval < 1.0 ? 1.0 : 0.0)); Interval = (int)(Interval / d) * d; return( Interval ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGCS_Graticule::Get_Extent(const CSG_Rect &Extent, CSG_Rect &r) { if( m_Projector.Set_Inverse() ) { double x, y, d; CSG_Point p(Extent.Get_XMin(), Extent.Get_YMin()); m_Projector.Get_Projection(p); r.Assign(p, p); d = Extent.Get_XRange() / 10.0; for(y=Extent.Get_YMin(), x=Extent.Get_XMin(); x<=Extent.Get_XMax(); x+=d) { p.Assign(x, y); m_Projector.Get_Projection(p); r.Union(p); } for(y=Extent.Get_YMax(), x=Extent.Get_XMin(); x<=Extent.Get_XMax(); x+=d) { p.Assign(x, y); m_Projector.Get_Projection(p); r.Union(p); } d = Extent.Get_YRange() / 10.0; for(x=Extent.Get_XMin(), y=Extent.Get_YMin(); y<=Extent.Get_YMax(); y+=d) { p.Assign(x, y); m_Projector.Get_Projection(p); r.Union(p); } for(x=Extent.Get_XMax(), y=Extent.Get_YMin(); y<=Extent.Get_YMax(); y+=d) { p.Assign(x, y); m_Projector.Get_Projection(p); r.Union(p); } m_Projector.Set_Inverse(false); if( r.Get_XMin() < -180 ) r.m_rect.xMin = -180; else if( r.Get_XMax() > 180 ) r.m_rect.xMax = 180; if( r.Get_YMin() < -90 ) r.m_rect.yMin = -90; else if( r.Get_YMax() > 90 ) r.m_rect.yMax = 90; return( r.Get_XRange() > 0.0 && r.Get_YRange() > 0.0 ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CGCS_Graticule::Get_Degree(double Value, int Precision) { if( Precision == DEG_PREC_DEG ) { return( SG_Get_String(Value, -12) + "\xb0" ); } SG_Char c; int d, h; double s; CSG_String String; if( Value < 0.0 ) { Value = -Value; c = SG_T('-'); } else { c = SG_T('+'); } Value = fmod(Value, 360.0); d = (int)Value; Value = 60.0 * (Value - d); h = (int)Value; Value = 60.0 * (Value - h); s = Value; if( s > 0.0 || Precision == DEG_PREC_FULL ) { String.Printf(SG_T("%c%d\xb0%02d'%02.*f''"), c, d, h, SG_Get_Significant_Decimals(s), s); } else if( h > 0 || Precision == DEG_PREC_MIN ) { String.Printf(SG_T("%c%d\xb0%02d'" ), c, d, h); } else { String.Printf(SG_T("%c%d\xb0" ), c, d); } return( String ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/crs_indicatrix.cpp0000744000175000017500000002200012737416202025436 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_indicatrix.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_indicatrix.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Indicatrix::CCRS_Indicatrix(void) { //----------------------------------------------------- Set_Name (_TL("Tissot's Indicatrix")); Set_Author ("O. Conrad (c) 2014"); Set_Description (_TW( "Creates a shapes layer with Tissot's indicatrices for chosen projection." )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "TARGET" , _TL("Indicatrix"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "NY" , _TL("Number in Latitudinal Direction"), _TL(""), PARAMETER_TYPE_Int, 5, 1, true ); Parameters.Add_Value( NULL , "NX" , _TL("Number in Meridional Direction"), _TL(""), PARAMETER_TYPE_Int, 11, 1, true ); Parameters.Add_Value( NULL , "SCALE" , _TL("Size"), _TL(""), PARAMETER_TYPE_Double, 25.0, 1.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { FIELD_LON = 0, FIELD_LAT, FIELD_h, FIELD_k, FIELD_a, FIELD_b, FIELD_w, FIELD_PHI }; //--------------------------------------------------------- bool CCRS_Indicatrix::On_Execute_Transformation(void) { //----------------------------------------------------- double yStep = 180.0 / Parameters("NY")->asDouble(); double xStep = 360.0 / Parameters("NX")->asDouble(); m_Size = 1.0; m_Scale = (40000000.0 / 360.0) * (yStep < xStep ? yStep : xStep) * 0.005 * Parameters("SCALE")->asDouble() / m_Size; //----------------------------------------------------- m_Circle.Add(0.0, 0.0); m_Circle.Add(sin(M_PI_090), cos(M_PI_090)); m_Circle.Add(0.0, 0.0); for(double a=0.0; aasShapes(); pTarget->Create(SHAPE_TYPE_Polygon, CSG_String::Format(SG_T("%s [%s]"), _TL("Indicatrix"), m_Projector.Get_Target().Get_Name().c_str())); pTarget->Get_Projection() = m_Projector.Get_Target(); pTarget->Add_Field("LON", SG_DATATYPE_Double); pTarget->Add_Field("LAT", SG_DATATYPE_Double); pTarget->Add_Field("h" , SG_DATATYPE_Double); pTarget->Add_Field("k" , SG_DATATYPE_Double); pTarget->Add_Field("a" , SG_DATATYPE_Double); pTarget->Add_Field("b" , SG_DATATYPE_Double); pTarget->Add_Field("w" , SG_DATATYPE_Double); pTarget->Add_Field("PHI", SG_DATATYPE_Double); //----------------------------------------------------- int nDropped = 0; for(double lat=-90.0+yStep/2.0; lat<90.0; lat+=yStep) { for(double lon=-180.0+xStep/2.0; lon<180.0; lon+=xStep) { CSG_Shape *pIndicatrix = pTarget->Add_Shape(); if( !Get_Indicatrix(lon, lat, pIndicatrix) ) { nDropped++; pTarget->Del_Shape(pIndicatrix); } } } //----------------------------------------------------- if( nDropped > 0 ) { Message_Add(CSG_String::Format(SG_T("%s: %d %s"), pTarget->Get_Name(), nDropped, _TL("shapes have been dropped"))); } m_Circle.Clear(); return( pTarget->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Indicatrix::Get_Indicatrix(double lon, double lat, CSG_Shape *pIndicatrix) { m_Projector.Set_Source( CSG_Projection(CSG_String::Format(SG_T("+proj=ortho +lon_0=%f +lat_0=%f +datum=WGS84"), lon, lat), SG_PROJ_FMT_Proj4) ); TSG_Point Center, Point; Center.x = 0.0; Center.y = 0.0; if( !m_Projector.Get_Projection(Center) ) { return( false ); } //----------------------------------------------------- Point.x = m_Size; Point.y = 0.0; if( !m_Projector.Get_Projection(Point) ) { return( false ); } double h = SG_Get_Distance(Center, Point) / m_Size; //----------------------------------------------------- Point.x = 0.0; Point.y = m_Size; if( !m_Projector.Get_Projection(Point) ) { return( false ); } double k = SG_Get_Distance(Center, Point) / m_Size; //----------------------------------------------------- double a = h > k ? h : k; // major semi-axis double b = h > k ? k : h; // minor semi-axis for(int iPoint=0; iPoint= 3 ) { double d = SG_Get_Distance(Center, Point) / m_Size; if( a < d ) { a = d; } else if( b > d ) { b = d; } } Point.x = Center.x + m_Scale * (Point.x - Center.x); Point.y = Center.y + m_Scale * (Point.y - Center.y); pIndicatrix->Add_Point(Point); } //----------------------------------------------------- double w = 2.0 * M_RAD_TO_DEG * asin((a - b) / (a + b)); double phi = a * b; pIndicatrix->Set_Value(FIELD_LON, SG_Get_Rounded(lon, 2)); pIndicatrix->Set_Value(FIELD_LAT, SG_Get_Rounded(lat, 2)); pIndicatrix->Set_Value(FIELD_h , SG_Get_Rounded(h , 2)); pIndicatrix->Set_Value(FIELD_k , SG_Get_Rounded(k , 2)); pIndicatrix->Set_Value(FIELD_a , SG_Get_Rounded(a , 2)); pIndicatrix->Set_Value(FIELD_b , SG_Get_Rounded(b , 2)); pIndicatrix->Set_Value(FIELD_w , SG_Get_Rounded(w , 1)); pIndicatrix->Set_Value(FIELD_PHI, SG_Get_Rounded(phi, 1)); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/crs_transform.cpp0000744000175000017500000002424412737416202025327 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_transform.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PROJ4_FREE(p) if( p ) { pj_free((PJ *)p); p = NULL; } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_CRSProjector::CSG_CRSProjector(void) { m_bInverse = false; m_pSource = NULL; m_pTarget = NULL; m_pGCS = NULL; } //--------------------------------------------------------- CSG_CRSProjector::~CSG_CRSProjector(void) { Destroy(); } //--------------------------------------------------------- bool CSG_CRSProjector::Destroy(void) { m_bInverse = false; PROJ4_FREE(m_pSource); PROJ4_FREE(m_pTarget); PROJ4_FREE(m_pGCS); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CSG_CRSProjector::Get_Version(void) { return( pj_release ); } //--------------------------------------------------------- CSG_String CSG_CRSProjector::Get_Description(void) { CSG_String s; s += _TL("Projection routines make use of the Proj.4 Cartographic Projections library."); s += "\n"; s += _TW("Proj.4 was originally developed by Gerald Evenden and later continued by the " "United States Department of the Interior, Geological Survey (USGS)."); s += "\n"; s += _TL("Proj.4 Version is ") + Get_Version(); s += "\n"; s += "Proj.4 Homepage"; return( s ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_CRSProjector::_Set_Projection(const CSG_Projection &Projection, void **ppProjection, bool bInverse) { PROJ4_FREE(*ppProjection); //------------------------------------------------- if( (*ppProjection = pj_init_plus(Projection.Get_Proj4())) == NULL ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("Proj4 [%s]: %s"), _TL("initialization"), SG_STR_MBTOSG(pj_strerrno(pj_errno)))); return( false ); } //------------------------------------------------- if( bInverse && ((PJ *)(*ppProjection))->inv == NULL ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("Proj4 [%s]: %s"), _TL("initialization"), _TL("inverse transformation not available"))); return( false ); } return( true ); } //--------------------------------------------------------- bool CSG_CRSProjector::Set_Source(const CSG_Projection &Projection) { SG_UI_Msg_Add_Execution(CSG_String::Format(SG_T("\n%s: %s"), _TL("source"), Projection.Get_Proj4().c_str()), false); return( _Set_Projection(Projection, &m_pSource, true) && m_Source.Create(Projection) ); } //--------------------------------------------------------- bool CSG_CRSProjector::Set_Target(const CSG_Projection &Projection) { SG_UI_Msg_Add_Execution(CSG_String::Format(SG_T("\n%s: %s"), _TL("target"), Projection.Get_Proj4().c_str()), false); return( _Set_Projection(Projection, &m_pTarget, false) && m_Target.Create(Projection) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_CRSProjector::Set_Inverse(bool bOn) { if( m_bInverse == bOn ) { return( true ); } if( m_pTarget && ((PJ *)m_pTarget)->inv ) { m_bInverse = bOn; void *pTMP = m_pSource; m_pSource = m_pTarget; m_pTarget = pTMP; return( true ); } SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("Proj4 [%s]: %s"), _TL("initialization"), _TL("inverse transformation not available"))); return( false ); } //--------------------------------------------------------- bool CSG_CRSProjector::Set_Precise_Mode(bool bOn) { if( bOn ) { if( m_pGCS == NULL ) { return( (m_pGCS = pj_init_plus("+proj=longlat +datum=WGS84")) != NULL ); } } else { PROJ4_FREE(m_pGCS); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(double &x, double &y) const { if( !m_pSource || !m_pTarget ) { return( false ); } if( pj_is_latlong((PJ *)m_pSource) ) { x *= DEG_TO_RAD; y *= DEG_TO_RAD; } if( m_pGCS ) // precise datum conversion { if( pj_transform((PJ *)m_pSource, (PJ *)m_pGCS , 1, 0, &x, &y, NULL) != 0 || pj_transform((PJ *)m_pGCS , (PJ *)m_pTarget, 1, 0, &x, &y, NULL) != 0 ) { return( false ); } } else // direct projection { if( pj_transform((PJ *)m_pSource, (PJ *)m_pTarget, 1, 0, &x, &y, NULL) != 0 ) { return( false ); } } if( pj_is_latlong((PJ *)m_pTarget) ) { x *= RAD_TO_DEG; y *= RAD_TO_DEG; } return( true ); } //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(TSG_Point &Point) const { return( Get_Projection(Point.x, Point.y) ); } //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(CSG_Point &Point) const { double x = Point.Get_X(); double y = Point.Get_Y(); if( Get_Projection(x, y) ) { Point.Assign(x, y); return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(double &x, double &y, double &z) const { if( !m_pSource || !m_pTarget ) { return( false ); } if( pj_is_latlong((PJ *)m_pSource) ) { x *= DEG_TO_RAD; y *= DEG_TO_RAD; } if( m_pGCS ) // precise datum conversion { if( pj_transform((PJ *)m_pSource, (PJ *)m_pGCS , 1, 0, &x, &y, &z) != 0 || pj_transform((PJ *)m_pGCS , (PJ *)m_pTarget, 1, 0, &x, &y, &z) != 0 ) { return( false ); } } else // direct projection { if( pj_transform((PJ *)m_pSource, (PJ *)m_pTarget, 1, 0, &x, &y, &z) != 0 ) { return( false ); } } if( pj_is_latlong((PJ *)m_pTarget) ) { x *= RAD_TO_DEG; y *= RAD_TO_DEG; } return( true ); } //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(TSG_Point_Z &Point) const { return( Get_Projection(Point.x, Point.y, Point.z) ); } //--------------------------------------------------------- bool CSG_CRSProjector::Get_Projection(CSG_Point_Z &Point) const { double x = Point.Get_X(); double y = Point.Get_Y(); double z = Point.Get_Z(); if( Get_Projection(x, y, z) ) { Point.Assign(x, y, z); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/PROJ4_Shapes.h0000744000175000017500000001041612737416201024246 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Shapes.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PROJ4_Shapes_H #define HEADER_INCLUDED__PROJ4_Shapes_H //--------------------------------------------------------- #include "PROJ4_Base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CPROJ4_Shapes : public CPROJ4_Base { public: CPROJ4_Shapes(int Interface, bool bInputList); virtual CSG_String Get_MenuPath (void) { return( _TL("Alternatives") ); } protected: virtual bool On_Execute_Conversion (void); private: bool _Get_Conversion (CSG_Shapes *pSource, CSG_Shapes *pTarget); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PROJ4_Shapes_H saga-2.3.1/src/modules/projection/pj_proj4/crs_indicatrix.h0000744000175000017500000001026112737416202025111 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_indicatrix.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_indicatrix_H #define HEADER_INCLUDED__crs_indicatrix_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Indicatrix : public CCRS_Transform { public: CCRS_Indicatrix(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute_Transformation (void); private: double m_Scale, m_Size; CSG_Points m_Circle; bool Get_Indicatrix (double lon, double lat, CSG_Shape *pIndicatrix); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_indicatrix_H saga-2.3.1/src/modules/projection/pj_proj4/crs_transform_shapes.h0000744000175000017500000001015612737416202026334 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_shapes.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_transform_shapes_H #define HEADER_INCLUDED__crs_transform_shapes_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Transform_Shapes : public CCRS_Transform { public: CCRS_Transform_Shapes(bool bList); protected: virtual bool On_Execute_Transformation (void); bool Transform (CSG_Shapes *pSource, CSG_Shapes *pTarget); private: bool m_bList; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_transform_shapes_H saga-2.3.1/src/modules/projection/pj_proj4/gcs_lon_range.h0000744000175000017500000001003612737416202024704 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // gcs_lon_range.h // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gcs_lon_range_H #define HEADER_INCLUDED__gcs_lon_range_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGCS_Grid_Longitude_Range : public CSG_Module_Grid { public: CGCS_Grid_Longitude_Range(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gcs_lon_range_H saga-2.3.1/src/modules/projection/pj_proj4/PROJ4_Shapes.cpp0000744000175000017500000002001612737416201024576 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Shapes.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "PROJ4_Shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPROJ4_Shapes::CPROJ4_Shapes(int Interface, bool bInputList) : CPROJ4_Base(Interface, bInputList) { //----------------------------------------------------- // 1. Info... Set_Name (CSG_String::Format(SG_T("[deprecated] %s (%s, %s)"), _TL("Proj.4"), Interface == PROJ4_INTERFACE_DIALOG ? _TL("Dialog") : _TL("Command Line Arguments"), m_bInputList ? _TL("List of Shapes Layers") : _TL("Shapes") )); Set_Author (SG_T("O. Conrad (c) 2004-8")); Set_Description (_TW( "Coordinate Transformation for Shapes.\n" "Based on the PROJ.4 Cartographic Projections library originally written by Gerald Evenden " "and later continued by the United States Department of the Interior, Geological Survey (USGS).\n" "Proj.4 Homepage\n" )); //----------------------------------------------------- // 2. In-/Output... if( m_bInputList ) { Parameters.Add_Shapes_List( Parameters("SOURCE_NODE") , "SOURCE", _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes_List( NULL , "TARGET", _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } else { Parameters.Add_Shapes( Parameters("SOURCE_NODE") , "SOURCE", _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( Parameters("TARGET_NODE") , "TARGET", _TL("Target"), _TL(""), PARAMETER_OUTPUT ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Shapes::On_Execute_Conversion(void) { bool bResult = false; CSG_Shapes *pSource, *pTarget; //----------------------------------------------------- if( m_bInputList ) { CSG_Parameter_Shapes_List *pSources, *pTargets; pSources = Parameters("SOURCE")->asShapesList(); pTargets = Parameters("TARGET")->asShapesList(); pTargets->Del_Items(); for(int i=0; iGet_Count() && Process_Get_Okay(false); i++) { pSource = pSources->asShapes(i); pTarget = SG_Create_Shapes(); if( _Get_Conversion(pSource, pTarget) ) { bResult = true; pTargets->Add_Item(pTarget); } else { delete( pTarget ); } } } else { bool bCopy; pSource = Parameters("SOURCE")->asShapes(); pTarget = Parameters("TARGET")->asShapes(); if( (bCopy = pSource == pTarget) == true ) { pTarget = SG_Create_Shapes(); } //------------------------------------------------- bResult = _Get_Conversion(pSource, pTarget); //------------------------------------------------- if( bCopy ) { pSource->Assign(pTarget); delete( pTarget ); } } return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Shapes::_Get_Conversion(CSG_Shapes *pSource, CSG_Shapes *pTarget) { if( pSource && pSource->is_Valid() && pTarget ) { int nDropped = 0; Process_Set_Text(CSG_String::Format(SG_T("%s: %s"), _TL("Processing"), pSource->Get_Name())); pTarget->Create(pSource->Get_Type(), CSG_String::Format(SG_T("%s [%s]"), pSource->Get_Name(), Get_Proj_Name().c_str()), pSource); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pSource->Get_Count()); iShape++) { CSG_Shape *pShape_Source = pSource->Get_Shape(iShape); CSG_Shape *pShape_Target = pTarget->Add_Shape(pShape_Source, SHAPE_COPY_ATTR); bool bDropped = false; for(int iPart=0; iPartGet_Part_Count() && !bDropped; iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart) && !bDropped; iPoint++) { TSG_Point Point = pShape_Source->Get_Point(iPoint, iPart); if( Get_Converted(Point.x, Point.y) ) { pShape_Target->Add_Point(Point.x, Point.y, iPart); } else { bDropped = true; } } } if( bDropped ) { nDropped++; pTarget->Del_Shape(pShape_Target); } } if( nDropped > 0 ) { Message_Add(CSG_String::Format(SG_T("%d %s"), nDropped, _TL("shapes have been dropped"))); } return( pTarget->Get_Count() > 0 ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/Makefile.in0000664000175000017500000006050112737447617024021 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/projection/pj_proj4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libpj_proj4_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libpj_proj4_la_OBJECTS = MLB_Interface.lo crs_assign.lo crs_base.lo \ crs_distance.lo crs_grid_geogcoords.lo crs_indicatrix.lo \ crs_transform.lo crs_transform_grid.lo \ crs_transform_pointcloud.lo crs_transform_shapes.lo \ gcs_graticule.lo gcs_lon_range.lo PROJ4_Base.lo PROJ4_Grid.lo \ PROJ4_Shapes.lo libpj_proj4_la_OBJECTS = $(am_libpj_proj4_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libpj_proj4_la_SOURCES) DIST_SOURCES = $(libpj_proj4_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id$ # DEP_LIBS = -lproj @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core $(LOCAL_INCS) AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) $(LOCAL_LIBS) pkglib_LTLIBRARIES = libpj_proj4.la libpj_proj4_la_SOURCES = \ MLB_Interface.cpp\ crs_assign.cpp\ crs_base.cpp\ crs_distance.cpp\ crs_grid_geogcoords.cpp\ crs_indicatrix.cpp\ crs_transform.cpp\ crs_transform_grid.cpp\ crs_transform_pointcloud.cpp\ crs_transform_shapes.cpp\ gcs_graticule.cpp\ gcs_lon_range.cpp\ PROJ4_Base.cpp\ PROJ4_Grid.cpp\ PROJ4_Shapes.cpp\ MLB_Interface.h\ crs_assign.h\ crs_base.h\ crs_distance.h\ crs_grid_geogcoords.h\ crs_indicatrix.h\ crs_transform.h\ crs_transform_grid.h\ crs_transform_pointcloud.h\ crs_transform_shapes.h\ gcs_graticule.h\ gcs_lon_range.h\ PROJ4_Base.h\ PROJ4_Grid.h\ PROJ4_Shapes.h libpj_proj4_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/projection/pj_proj4/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/projection/pj_proj4/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libpj_proj4.la: $(libpj_proj4_la_OBJECTS) $(libpj_proj4_la_DEPENDENCIES) $(EXTRA_libpj_proj4_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libpj_proj4_la_OBJECTS) $(libpj_proj4_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PROJ4_Base.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PROJ4_Grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PROJ4_Shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_assign.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_base.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_distance.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_grid_geogcoords.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_indicatrix.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_transform.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_transform_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_transform_pointcloud.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crs_transform_shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gcs_graticule.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gcs_lon_range.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/projection/pj_proj4/gcs_lon_range.cpp0000744000175000017500000001625412737416202025247 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // gcs_lon_range.cpp // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gcs_lon_range.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGCS_Grid_Longitude_Range::CGCS_Grid_Longitude_Range(void) { //----------------------------------------------------- Set_Name (_TL("Change Longitudinal Range for Grids")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Change the longitudinal range of grids using geographic coordinates, " "i.e. from 0 - 360 to -180 - 180 and vice versa." )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, false ); Parameters.Add_Choice( NULL , "DIRECTION" , _TL("Direction"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), SG_T("0 - 360 >> -180 - 180"), SG_T("-180 - 180 >> 0 - 360") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGCS_Grid_Longitude_Range::On_Execute(void) { CSG_Parameter_Grid_List *pInput = Parameters("INPUT" )->asGridList(); CSG_Parameter_Grid_List *pOutput = Parameters("OUTPUT")->asGridList(); if( pInput->Get_Count() <= 0 ) { Message_Dlg(_TL("nothing to do: no data in selection")); return( false ); } pOutput->Del_Items(); //----------------------------------------------------- int xZero; CSG_Grid_System Target; //----------------------------------------------------- if( Parameters("DIRECTION")->asInt() == 0 ) // 0 - 360 >> -180 - 180 { if( Get_XMax() <= 180.0 ) { Message_Add(_TL("Nothing to do. Raster is already within target range.")); return( true ); } else if( Get_XMin() >= 180.0 ) { xZero = 0; Target.Assign(Get_Cellsize(), Get_XMin() - 360.0, Get_YMin(), Get_NX(), Get_NY()); } else if( Get_XMax() - 360.0 < Get_XMin() - Get_Cellsize() ) { Error_Set(_TL("Nothing to do be done. Raster splitting is not supported.")); return( false ); } else { xZero = (int)(0.5 + 180.0 / Get_Cellsize()); Target.Assign(Get_Cellsize(), Get_XMin() - 180.0, Get_YMin(), Get_NX(), Get_NY()); } } //----------------------------------------------------- else // -180 - 180 >> 0 - 360 { if( Get_XMin() >= 0.0 ) { Message_Add(_TL("Nothing to do. Raster is already within target range.")); return( true ); } else if( Get_XMax() <= 0.0 ) { xZero = 0; Target.Assign(Get_Cellsize(), Get_XMin() + 360.0, Get_YMin(), Get_NX(), Get_NY()); } else if( Get_XMin() + 360.0 > Get_XMax() + Get_Cellsize() ) { Error_Set(_TL("Nothing to do be done. Raster splitting is not supported.")); return( false ); } else { xZero = (int)(0.5 + 180.0 / Get_Cellsize()); Target.Assign(Get_Cellsize(), Get_XMin() - 180.0, Get_YMin(), Get_NX(), Get_NY()); } } //----------------------------------------------------- for(int i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Grid *pIn = pInput->asGrid(i); CSG_Grid *pOut = SG_Create_Grid(Target, pIn->Get_Type()); pOut->Set_Name(pIn->Get_Name()); pOut->Set_NoData_Value_Range(pIn->Get_NoData_Value(), pIn->Get_NoData_hiValue()); pOut->Set_Scaling(pIn->Get_Scaling(), pIn->Get_Offset()); pOutput->Add_Item(pOut); for(int y=0; y= Get_NX() ) { xx = 0; } pOut->Set_Value(xx, y, pIn->asDouble(x, y)); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/crs_transform_grid.cpp0000744000175000017500000005233612737416202026337 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_grid.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_transform_grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Transform_Grid::CCRS_Transform_Grid(bool bList) { CSG_Parameter *pNode; m_bList = bList; //----------------------------------------------------- Set_Name (m_bList ? _TL("Coordinate Transformation (Grid List)") : _TL("Coordinate Transformation (Grid)") ); Set_Author ("O. Conrad (c) 2010"); Set_Description (_TW( "Coordinate transformation for grids.\n" )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- m_Grid_Target.Create(Add_Parameters("TARGET", _TL("Target Grid System"), _TL("")), false); if( m_bList ) { pNode = Parameters.Add_Grid_List( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } //----------------------------------------------------- else { pNode = Parameters.Add_Grid( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); m_Grid_Target.Add_Grid("GRID", _TL("Target"), false); } m_Grid_Target.Add_Grid("OUT_X", _TL("X Coordinates"), true); m_Grid_Target.Add_Grid("OUT_Y", _TL("Y Coordinates"), true); //----------------------------------------------------- Parameters.Add_Choice( NULL , "RESAMPLING" , _TL("Resampling"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 3 ); Parameters.Add_Value( pNode , "KEEP_TYPE" , _TL("Preserve Data Type"), _TL(""), PARAMETER_TYPE_Bool, true ); //----------------------------------------------------- Parameters.Add_Value( pNode , "TARGET_AREA" , _TL("Use Target Area Polygon"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CCRS_Transform_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CCRS_Transform::On_Parameter_Changed(pParameters, pParameter); return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CCRS_Transform_Grid::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CCRS_Transform::On_Parameters_Enable(pParameters, pParameter); return( m_Grid_Target.On_Parameters_Enable(pParameters, pParameter) ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Grid::On_Execute_Transformation(void) { switch( Parameters("RESAMPLING")->asInt() ) { default: m_Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: m_Resampling = GRID_RESAMPLING_Bilinear; break; case 2: m_Resampling = GRID_RESAMPLING_BicubicSpline; break; case 3: m_Resampling = GRID_RESAMPLING_BSpline; break; } //----------------------------------------------------- if( m_bList ) { int i; CSG_Parameters Grids; CSG_Parameter_Grid_List *pSources, *pTargets, *pGrids; pSources = Parameters("SOURCE")->asGridList(); pTargets = Parameters("GRIDS" )->asGridList(); pTargets->Del_Items(); pGrids = Grids.Add_Grid_List(NULL, "GRD", SG_T(""), SG_T(""), PARAMETER_INPUT, false)->asGridList(); for(i=0; iGet_Count(); i++) { if( pSources->asGrid(i)->Get_Projection().is_Okay() ) { pGrids->Add_Item(pSources->asGrid(i)); } else { Error_Set(CSG_String::Format(SG_T("%s: %s\n"), _TL("unknown projection"), pSources->asGrid(i)->Get_Name())); } } pSources = Grids.Add_Grid_List(NULL, "SRC", SG_T(""), SG_T(""), PARAMETER_INPUT, false)->asGridList(); while( pGrids->Get_Count() > 0 ) { pSources->Add_Item(pGrids->asGrid(pGrids->Get_Count() - 1)); pGrids ->Del_Item(pGrids->Get_Count() - 1); for(i=pGrids->Get_Count()-1; i>=0; i--) { if( pGrids->asGrid(i)->Get_Projection() == pSources->asGrid(0)->Get_Projection() ) { pSources->Add_Item(pGrids->asGrid(i)); pGrids ->Del_Item(i); } } m_Projector.Set_Inverse(false); Transform(pSources); pSources->Del_Items(); } return( pTargets->Get_Count() > 0 ); } //----------------------------------------------------- else { return( Transform(Parameters("SOURCE")->asGrid()) ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Grid *pGrid) { if( pGrid->Get_Projection().is_Okay() && m_Projector.Set_Source(pGrid->Get_Projection()) && Get_Target_System(pGrid->Get_System(), true) ) { TSG_Data_Type Type = m_Resampling == GRID_RESAMPLING_NearestNeighbour || Parameters("KEEP_TYPE")->asBool() ? pGrid->Get_Type() : SG_DATATYPE_Float; return( Transform(pGrid, m_Grid_Target.Get_Grid("GRID", Type)) ); } return( false ); } //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Parameter_Grid_List *pGrids) { if( pGrids->Get_Count() > 0 && m_Projector.Set_Source(pGrids->asGrid(0)->Get_Projection()) && Get_Target_System(pGrids->asGrid(0)->Get_System(), true) ) { CSG_Grid_System System(m_Grid_Target.Get_System()); return( Transform(pGrids, Parameters("GRIDS")->asGridList(), System) ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Grid *pGrid, CSG_Grid *pTarget) { if( !m_Projector.Set_Inverse(true) || !pTarget || !pGrid ) { return( false ); } //----------------------------------------------------- CSG_Grid *pX, *pY; if( (pX = m_Grid_Target.Get_Grid("OUT_X")) != NULL ) { pX->Assign_NoData(); pX->Set_Name(_TL("X Coordinates")); pX->Get_Projection().Create(m_Projector.Get_Target()); } if( (pY = m_Grid_Target.Get_Grid("OUT_Y")) != NULL ) { pY->Assign_NoData(); pY->Set_Name(_TL("Y Coordinates")); pY->Get_Projection().Create(m_Projector.Get_Target()); } //----------------------------------------------------- Set_Target_Area(pGrid->Get_System(), pTarget->Get_System()); bool bGeogCS_Adjust = m_Projector.Get_Source().Get_Type() == SG_PROJ_TYPE_CS_Geographic && pGrid->Get_XMax() > 180.0; //------------------------------------------------- pTarget->Set_NoData_Value_Range (pGrid->Get_NoData_Value(), pGrid->Get_NoData_hiValue()); pTarget->Set_Scaling (pGrid->Get_Scaling(), pGrid->Get_Offset()); pTarget->Set_Name (CSG_String::Format(SG_T("%s"), pGrid->Get_Name())); pTarget->Set_Unit (pGrid->Get_Unit()); pTarget->Assign_NoData(); pTarget->Get_Projection().Create(m_Projector.Get_Target()); //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, pTarget->Get_NY()); y++) { double yTarget = pTarget->Get_YMin() + y * pTarget->Get_Cellsize(); // #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double z, ySource, xSource = pTarget->Get_XMin() + x * pTarget->Get_Cellsize(); if( is_In_Target_Area(x, y) && m_Projector.Get_Projection(xSource, ySource = yTarget) ) { if( pX ) pX->Set_Value(x, y, xSource); if( pY ) pY->Set_Value(x, y, ySource); if( bGeogCS_Adjust && xSource < 0.0 ) { xSource += 360.0; } if( pGrid->Get_Value(xSource, ySource, z, m_Resampling) ) { pTarget->Set_Value(x, y, z); } } } } //----------------------------------------------------- m_Target_Area.Destroy(); return( true ); } //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Parameter_Grid_List *pSources, CSG_Parameter_Grid_List *pTargets, const CSG_Grid_System &Target_System) { if( !m_Projector.Set_Inverse(true) || !pTargets || !pSources || pSources->Get_Count() < 1 ) { return( false ); } //----------------------------------------------------- CSG_Grid *pX, *pY; if( (pX = m_Grid_Target.Get_Grid("OUT_X")) != NULL ) { pX->Assign_NoData(); pX->Set_Name(_TL("X Coordinates")); pX->Get_Projection().Create(m_Projector.Get_Target()); } if( (pY = m_Grid_Target.Get_Grid("OUT_Y")) != NULL ) { pY->Assign_NoData(); pY->Set_Name(_TL("Y Coordinates")); pY->Get_Projection().Create(m_Projector.Get_Target()); } //----------------------------------------------------- bool bGeogCS_Adjust = m_Projector.Get_Source().Get_Type() == SG_PROJ_TYPE_CS_Geographic && pSources->asGrid(0)->Get_System().Get_XMax() > 180.0; Set_Target_Area(pSources->asGrid(0)->Get_System(), Target_System); //----------------------------------------------------- int i, n = pTargets->Get_Count(); for(i=0; iGet_Count(); i++) { CSG_Grid *pSource = pSources->asGrid(i); CSG_Grid *pTarget = SG_Create_Grid(Target_System, m_Resampling == GRID_RESAMPLING_NearestNeighbour ? pSource->Get_Type() : SG_DATATYPE_Float); if( pTarget ) { pTarget->Set_NoData_Value_Range (pSource->Get_NoData_Value(), pSource->Get_NoData_hiValue()); pTarget->Set_Scaling (pSource->Get_Scaling(), pSource->Get_Offset()); pTarget->Set_Name (CSG_String::Format(SG_T("%s"), pSource->Get_Name())); pTarget->Set_Unit (pSource->Get_Unit()); pTarget->Assign_NoData(); pTarget->Get_Projection().Create(m_Projector.Get_Target()); pTargets->Add_Item(pTarget); } } //------------------------------------------------- for(int y=0; ySet_Value(x, y, xSource); if( pY ) pY->Set_Value(x, y, ySource); if( bGeogCS_Adjust && xSource < 0.0 ) { xSource += 360.0; } for(i=0; iGet_Count(); i++) { if( pSources->asGrid(i)->Get_Value(xSource, ySource, z, m_Resampling) ) { pTargets->asGrid(n + i)->Set_Value(x, y, z); } } } } } //----------------------------------------------------- m_Target_Area.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Grid *pGrid, CSG_Shapes *pPoints) { if( !pPoints || !pGrid ) { return( false ); } if( !m_Projector.Set_Source(pGrid->Get_Projection()) ) { return( false ); } int x, y; TSG_Point Point; pPoints->Create(SHAPE_TYPE_Point, _TL("Points")); pPoints->Get_Projection() = m_Projector.Get_Target(); pPoints->Add_Field(pGrid->Get_Name(), pGrid->Get_Type()); for(y=0, Point.y=pGrid->Get_YMin(); yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++, Point.y+=pGrid->Get_Cellsize()) { for(x=0, Point.x=pGrid->Get_XMin(); xGet_NX(); x++, Point.x+=pGrid->Get_Cellsize()) { TSG_Point Point_Transformed = Point; if( !pGrid->is_NoData(x, y) && m_Projector.Get_Projection(Point_Transformed) ) { CSG_Shape *pPoint = pPoints->Add_Shape(); pPoint->Add_Point(Point_Transformed); pPoint->Set_Value(0, pGrid->asDouble(x, y)); } } } return( true ); } //--------------------------------------------------------- bool CCRS_Transform_Grid::Transform(CSG_Parameter_Grid_List *pGrids, CSG_Shapes *pPoints) { if( !pPoints || !pGrids || pGrids->Get_Count() < 1 ) { return( false ); } CSG_Grid *pGrid = pGrids->asGrid(0); if( !m_Projector.Set_Source(pGrid->Get_Projection()) ) { return( false ); } int x, y, i; TSG_Point Point; pPoints->Create(SHAPE_TYPE_Point, _TL("Points")); pPoints->Get_Projection() = m_Projector.Get_Target(); for(i=0; iGet_Count(); i++) { pPoints->Add_Field(pGrids->asGrid(i)->Get_Name(), pGrids->asGrid(i)->Get_Type()); } for(y=0, Point.y=pGrid->Get_YMin(); yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++, Point.y+=pGrid->Get_Cellsize()) { for(x=0, Point.x=pGrid->Get_XMin(); xGet_NX(); x++, Point.x+=pGrid->Get_Cellsize()) { TSG_Point Point_Transformed = Point; if( m_Projector.Get_Projection(Point_Transformed) ) { CSG_Shape *pPoint = pPoints->Add_Shape(); pPoint->Add_Point(Point_Transformed); for(i=0; iGet_Count(); i++) { if( !pGrids->asGrid(i)->is_NoData(x, y) ) { pPoint->Set_Value(i, pGrids->asGrid(i)->asDouble(x, y)); } else { pPoint->Set_NoData(i); } } } } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CCRS_Transform_Grid::Get_MinMax(TSG_Rect &r, double x, double y) { if( m_Projector.Get_Projection(x, y) ) { if( r.xMin > r.xMax ) { r.xMin = r.xMax = x; } else if( r.xMin > x ) { r.xMin = x; } else if( r.xMax < x ) { r.xMax = x; } if( r.yMin > r.yMax ) { r.yMin = r.yMax = y; } else if( r.yMin > y ) { r.yMin = y; } else if( r.yMax < y ) { r.yMax = y; } } } //--------------------------------------------------------- bool CCRS_Transform_Grid::Get_Target_System(const CSG_Grid_System &System, bool bEdge) { int x, y, Resolution; TSG_Rect Extent; Extent.xMin = Extent.yMin = 1.0; Extent.xMax = Extent.yMax = 0.0; Get_MinMax(Extent, System.Get_XMin(), System.Get_YMin()); Get_MinMax(Extent, System.Get_XMax(), System.Get_YMin()); Get_MinMax(Extent, System.Get_XMin(), System.Get_YMax()); Get_MinMax(Extent, System.Get_XMax(), System.Get_YMax()); Resolution = 256; switch( 1 ) { case 1: // edges { double d; int yStep = 1 + System.Get_NY() / Resolution; for(y=0, d=System.Get_YMin(); yasBool() == false ) { m_Target_Area.Destroy(); return( true ); } //----------------------------------------------------- CSG_Rect r(Source.Get_Extent()); if( m_Projector.Get_Source().Get_Type() == SG_PROJ_TYPE_CS_Geographic ) { if( r.Get_XMax() > 180.0 ) r.Move(-180.0, 0.0); if( r.Get_YMin() < -90.0 ) r.m_rect.yMin = -90.0; if( r.Get_YMax() < 90.0 ) r.m_rect.yMax = 90.0; } //----------------------------------------------------- CSG_Shapes Area(SHAPE_TYPE_Polygon); CSG_Shape_Polygon *pArea = (CSG_Shape_Polygon *)Area.Add_Shape(); TSG_Point p, q; double dx = Source.Get_XRange() / 100.0; double dy = Source.Get_YRange() / 100.0; m_Projector.Set_Inverse(false); for(p.x=r.Get_XMin(), p.y=r.Get_YMin(); p.yAdd_Point(q); } for(p.x=r.Get_XMin(), p.y=r.Get_YMax(); p.xAdd_Point(q); } for(p.x=r.Get_XMax(), p.y=r.Get_YMax(); p.y>r.Get_YMin(); p.y-=dy) { m_Projector.Get_Projection(q = p); pArea->Add_Point(q); } for(p.x=r.Get_XMax(), p.y=r.Get_YMin(); p.x>r.Get_XMin(); p.x-=dx) { m_Projector.Get_Projection(q = p); pArea->Add_Point(q); } m_Projector.Set_Inverse(true); //----------------------------------------------------- m_Target_Area.Create(Target, SG_DATATYPE_Char); m_Target_Area.Set_NoData_Value(0); for(int y=0; yContains(Target.Get_xGrid_to_World(x), yWorld) ? 1 : 0); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- inline bool CCRS_Transform_Grid::is_In_Target_Area(int x, int y) { return( !m_Target_Area.is_Valid() || m_Target_Area.is_InGrid(x, y) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/PROJ4_Grid.h0000744000175000017500000001206212737416201023707 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Grid.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PROJ4_Grid_H #define HEADER_INCLUDED__PROJ4_Grid_H //--------------------------------------------------------- #include "PROJ4_Base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CPROJ4_Grid : public CPROJ4_Base { public: CPROJ4_Grid(int Interface, bool bInputList); virtual CSG_String Get_MenuPath (void) { return( _TL("Alternatives") ); } protected: virtual bool On_Execute_Conversion (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: TSG_Grid_Resampling m_Resampling; CSG_Parameters_Grid_Target m_Grid_Target; bool Set_Grids (CSG_Parameter_Grid_List *pSources, CSG_Parameter_Grid_List *pTargets); bool Set_Shapes (CSG_Parameter_Grid_List *pSources, CSG_Shapes *pTarget ); bool Set_Grid (CSG_Grid *pSource, CSG_Grid *pTarget); bool Set_Shapes (CSG_Grid *pSource, CSG_Shapes *pTarget); bool Init_XY (const CSG_Grid_System &System, CSG_Grid **ppX, CSG_Grid **ppY); bool Init_Target (CSG_Grid *pSource, CSG_Grid *pTarget); void Get_MinMax (TSG_Rect &r, double x, double y); bool Get_Target_Extent (CSG_Grid *pSource, TSG_Rect &Extent); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PROJ4_Grid_H saga-2.3.1/src/modules/projection/pj_proj4/crs_transform_pointcloud.h0000744000175000017500000001040212737416202027223 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_pointcloud.h // // // // Copyright (C) 2014 by // // Volker Wichmann // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_transform_pointcloud_H #define HEADER_INCLUDED__crs_transform_pointcloud_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Transform_PointCloud : public CCRS_Transform { public: CCRS_Transform_PointCloud(bool bList); protected: virtual bool On_Execute_Transformation (void); bool Transform (CSG_PointCloud *pSource, CSG_PointCloud *pTarget); private: bool m_bList; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_transform_pointcloud_H saga-2.3.1/src/modules/projection/pj_proj4/crs_base.cpp0000744000175000017500000011340712737416201024225 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_base.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_base.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Base::CCRS_Base(void) { m_Projection.Create(4326); CSG_Parameter *pNode_0, *pNode_1; //----------------------------------------------------- if( SG_UI_Get_Window_Main() == NULL ) { Parameters.Add_Choice( NULL , "CRS_METHOD" , _TL("Get CRS Definition from..."), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Proj4 Parameters"), _TL("EPSG Code"), _TL("Well Known Text File") ), 0 ); } //----------------------------------------------------- pNode_0 = Parameters.Add_String( NULL , "CRS_PROJ4" , _TL("Proj4 Parameters"), _TL(""), m_Projection.Get_Proj4(), true ); if( SG_UI_Get_Window_Main() ) { Parameters.Add_Parameters( pNode_0 , "CRS_DIALOG" , _TL("User Defined"), _TL("") ); Set_User_Parameters(Parameters("CRS_DIALOG")->asParameters()); } //----------------------------------------------------- if( SG_UI_Get_Window_Main() ) { pNode_1 = Parameters.Add_Parameters(pNode_0, "CRS_GRID" , _TL("Loaded Grid") , _TL("")); pNode_1->asParameters()->Add_Grid( NULL , "PICK" , _TL("Grid"), _TL(""), PARAMETER_INPUT_OPTIONAL, false ); pNode_1 = Parameters.Add_Parameters(pNode_0, "CRS_SHAPES", _TL("Loaded Shapes"), _TL("")); pNode_1->asParameters()->Add_Shapes( NULL , "PICK" , _TL("Shapes"), _TL(""), PARAMETER_INPUT_OPTIONAL ); } //----------------------------------------------------- Parameters.Add_FilePath( pNode_0 , "CRS_FILE" , _TL("Well Known Text File"), _TL(""), CSG_String::Format( SG_T("%s|*.prj;*.wkt;*.txt|%s|*.prj|%s|*.wkt|%s|*.txt|%s|*.*"), _TL("All Recognized Files"), _TL("ESRI WKT Files (*.prj)"), _TL("WKT Files (*.wkt)"), _TL("Text Files (*.txt)"), _TL("All Files") ) ); //----------------------------------------------------- pNode_1 = Parameters.Add_Value( pNode_0 , "CRS_EPSG" , _TL("EPSG Code"), _TL(""), PARAMETER_TYPE_Int, m_Projection.Get_EPSG(), -1, true ); if( SG_UI_Get_Window_Main() ) { Parameters.Add_Choice( pNode_1 , "CRS_EPSG_GEOGCS" , _TL("Geographic Coordinate Systems"), _TL(""), SG_Get_Projections().Get_Names_List(SG_PROJ_TYPE_CS_Geographic) ); Parameters.Add_Choice( pNode_1 , "CRS_EPSG_PROJCS" , _TL("Projected Coordinate Systems"), _TL(""), SG_Get_Projections().Get_Names_List(SG_PROJ_TYPE_CS_Projected) ); } //----------------------------------------------------- Parameters.Add_Value( NULL , "PRECISE" , _TL("Precise Datum Conversion"), _TL("avoids precision problems when source and target crs use different geodedtic datums."), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Base::On_Before_Execution(void) { m_Projection.Create(Parameters("CRS_PROJ4")->asString(), SG_PROJ_FMT_Proj4); if( m_Projection.is_Okay() && Parameters("CRS_DIALOG") ) { Set_User_Definition(*Parameters("CRS_DIALOG")->asParameters(), Parameters("CRS_PROJ4")->asString()); } return( true ); } //--------------------------------------------------------- int CCRS_Base::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { //----------------------------------------------------- if( !SG_STR_CMP(pParameters->Get_Identifier(), "CRS_DIALOG") ) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "PROJ_TYPE") ) { pParameters->Get_Parameter("OPTIONS")->asParameters()->Assign(Get_Parameters(SG_STR_MBTOSG(pj_list[pParameter->asInt()].id))); } return( 1 ); } //----------------------------------------------------- CSG_Projection Projection; //----------------------------------------------------- // if( pParameters->Get_Parameter("CRS_PROJ4") ) // { // Projection.Create(pParameters->Get_Parameter("CRS_PROJ4")->asString(), SG_PROJ_FMT_Proj4); // } if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_PROJ4") ) { Projection.Create(pParameter->asString(), SG_PROJ_FMT_Proj4); } //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_DIALOG") ) { Projection.Create(Get_User_Definition(*pParameter->asParameters()), SG_PROJ_FMT_Proj4); } //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_FILE") ) { Projection.Load(pParameter->asString()); pParameter->Set_Value(CSG_String("")); // clear } //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_EPSG") ) { if (!Projection.Create(pParameter->asInt())) { SG_UI_Dlg_Message(_TL("Unknown EPSG Code"), _TL("WARNING")); } } //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_EPSG_GEOGCS") || !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_EPSG_PROJCS") ) { int EPSG; if( pParameter->asChoice()->Get_Data(EPSG) ) { Projection.Create(EPSG); } } //----------------------------------------------------- if( !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_GRID") || !SG_STR_CMP(pParameter->Get_Identifier(), "CRS_SHAPES") ) { CSG_Data_Object *pPick = pParameter->asParameters()->Get_Parameter("PICK")->asDataObject(); if( pPick && pPick->Get_Projection().is_Okay() ) { Projection.Create(pPick->Get_Projection()); } } //----------------------------------------------------- if( Projection.is_Okay() ) { m_Projection = Projection; pParameters->Get_Parameter("CRS_PROJ4")->Set_Value(m_Projection.Get_Proj4()); pParameters->Get_Parameter("CRS_EPSG" )->Set_Value(m_Projection.Get_EPSG ()); if( pParameters->Get_Parameter("CRS_DIALOG") ) { Set_User_Definition(*pParameters->Get_Parameter("CRS_DIALOG")->asParameters(), m_Projection.Get_Proj4()); } } //----------------------------------------------------- return( 1 ); } //--------------------------------------------------------- int CCRS_Base::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameters->Get_Identifier(), "CRS_DIALOG") ) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "PROJ_TYPE") ) { // pParameters->Get_Parameter("OPTIONS")->asParameters()->Assign(Get_Parameters(SG_STR_MBTOSG(pj_list[pParameter->asInt()].id))); pParameters->Get_Parameter("OPTIONS")->Set_Enabled(pParameters->Get_Parameter("OPTIONS")->asParameters()->Get_Count() > 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DATUM_DEF") ) { int Value = pParameter->asInt(); pParameters->Get_Parameter("DATUM" )->Set_Enabled(Value == 0); pParameters->Get_Parameter("ELLIPSOID")->Set_Enabled(Value == 1); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "ELLIPSOID") ) { int Value = pParameter->asInt(); pParameters->Get_Parameter("ELLPS_DEF")->Set_Enabled(Value == 0); pParameters->Get_Parameter("ELLPS_A" )->Set_Enabled(Value != 0); pParameters->Get_Parameter("ELLPS_B" )->Set_Enabled(Value == 1); pParameters->Get_Parameter("ELLPS_F" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("ELLPS_RF" )->Set_Enabled(Value == 3); pParameters->Get_Parameter("ELLPS_E" )->Set_Enabled(Value == 4); pParameters->Get_Parameter("ELLPS_ES" )->Set_Enabled(Value == 5); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DATUM_SHIFT") ) { int Value = pParameter->asInt(); pParameters->Get_Parameter("DS_DX" )->Set_Enabled(Value == 1 || Value == 2); pParameters->Get_Parameter("DS_DY" )->Set_Enabled(Value == 1 || Value == 2); pParameters->Get_Parameter("DS_DZ" )->Set_Enabled(Value == 1 || Value == 2); pParameters->Get_Parameter("DS_RX" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("DS_RY" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("DS_RZ" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("DS_SC" )->Set_Enabled(Value == 2); pParameters->Get_Parameter("DATUM_GRID")->Set_Enabled(Value == 3); } } //----------------------------------------------------- return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Base::Get_Projection(CSG_Projection &Projection) { if( !Parameters("CRS_METHOD") ) { Projection = m_Projection; } else switch( Parameters("CRS_METHOD")->asInt() ) { default: // Proj4 Parameters if( !Projection.Create(Parameters("CRS_PROJ4")->asString(), SG_PROJ_FMT_Proj4) ) { Error_Set(_TL("Proj4 definition string error")); } break; case 1: // EPSG Code if( !Projection.Create(Parameters("CRS_EPSG" )->asInt()) ) { Error_Set(_TL("EPSG code error")); } break; case 2: // Well Known Text File if( !Projection.Load (Parameters("CRS_FILE" )->asString()) ) { Error_Set(_TL("Well Known Text file error")); } break; } return( Projection.is_Okay() ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define WGS84_ELLPS_A 6378137.000 #define WGS84_ELLPS_B 6356752.314 //--------------------------------------------------------- bool CCRS_Base::Set_User_Parameters(CSG_Parameters *pParameters) { CSG_Parameter *pNode_0 = NULL, *pNode_1, *pNode_2; CSG_String sProjections, sName, sDescription, sArguments, sDatums, sEllipsoids, sUnits; /////////////////////////////////////////////////////// // Projection ----------------------------------------- sDescription = _TL("Available Projections:"); for(struct PJ_LIST *pProjection=pj_list; pProjection->id; ++pProjection) { sArguments = *pProjection->descr; sName = sArguments.BeforeFirst('\n'); sArguments = sArguments.AfterFirst ('\n').AfterFirst('\n').AfterFirst('\t'); sProjections += CSG_String::Format(SG_T("{%s}%s|") , SG_STR_MBTOSG(pProjection->id), sName.c_str()); sDescription += CSG_String::Format(SG_T("\n[%s] %s (%s)"), SG_STR_MBTOSG(pProjection->id), sName.c_str(), sArguments.c_str()); Add_User_Projection(pProjection->id, sName, sArguments); } // Datums --------------------------------------------- for(struct PJ_DATUMS *pDatum=pj_datums; pDatum->id; ++pDatum) { CSG_String id (pDatum->id); CSG_String comments(pDatum->comments); sDatums += CSG_String::Format(SG_T("{%s}%s|"), id.c_str(), comments.Length() ? comments.c_str() : id.c_str()); } // Ellipsoids ----------------------------------------- for(struct PJ_ELLPS *pEllipse=pj_ellps; pEllipse->id; ++pEllipse) { sEllipsoids += CSG_String::Format(SG_T("{%s}%s (%s, %s)|"), SG_STR_MBTOSG(pEllipse->id), SG_STR_MBTOSG(pEllipse->name), SG_STR_MBTOSG(pEllipse->major), SG_STR_MBTOSG(pEllipse->ell)); } // Units ---------------------------------------------- for(struct PJ_UNITS *pUnit=pj_units; pUnit->id; ++pUnit) { sUnits += CSG_String::Format(SG_T("{%s}%s (%s)|"), SG_STR_MBTOSG(pUnit->id), SG_STR_MBTOSG(pUnit->name), SG_STR_MBTOSG(pUnit->to_meter)); } /////////////////////////////////////////////////////// //----------------------------------------------------- // Projection... if( sProjections.Length() == 0 ) { return( false ); } pParameters->Add_Choice (pNode_0, "PROJ_TYPE" , _TL("Projection Type") , sDescription, sProjections); //----------------------------------------------------- // Datum... pNode_1 = pParameters->Add_Choice( pNode_0, "DATUM_DEF" , _TL("Datum Definition"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Predefined Datum"), _TL("User Defined Datum") ) ); //----------------------------------------------------- // Predefined Datum... pParameters->Add_Choice (pNode_1, "DATUM" , _TL("Predefined Datum") , _TL(""), sDatums); //----------------------------------------------------- // Ellipsoid... pNode_2 = pParameters->Add_Choice( pNode_1, "ELLIPSOID" , _TL("Ellipsoid Definition"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("Predefined Ellipsoids"), _TL("Semimajor Axis and Semiminor Axis"), _TL("Semimajor Axis and Flattening"), _TL("Semimajor Axis and Reciprocal Flattening"), _TL("Semimajor Axis and Eccentricity"), _TL("Semimajor Axis and Eccentricity Squared") ) ); pParameters->Add_Choice (pNode_2, "ELLPS_DEF" , _TL("Predefined Ellipsoids") , _TL(""), sEllipsoids); pParameters->Add_Value (pNode_2, "ELLPS_A" , _TL("Semimajor Axis (a)") , _TL(""), PARAMETER_TYPE_Double, WGS84_ELLPS_A); pParameters->Add_Value (pNode_2, "ELLPS_B" , _TL("Semiminor Axis (b)") , _TL(""), PARAMETER_TYPE_Double, WGS84_ELLPS_B); pParameters->Add_Value (pNode_2, "ELLPS_F" , _TL("Flattening (f)") , _TL(""), PARAMETER_TYPE_Double, (WGS84_ELLPS_A - WGS84_ELLPS_B) / WGS84_ELLPS_A); pParameters->Add_Value (pNode_2, "ELLPS_RF" , _TL("Reciprocal Flattening (rf)") , _TL(""), PARAMETER_TYPE_Double, WGS84_ELLPS_A / (WGS84_ELLPS_A - WGS84_ELLPS_B)); pParameters->Add_Value (pNode_2, "ELLPS_E" , _TL("Eccentricity (e)") , _TL(""), PARAMETER_TYPE_Double, sqrt(WGS84_ELLPS_A*WGS84_ELLPS_A + WGS84_ELLPS_B*WGS84_ELLPS_B)); pParameters->Add_Value (pNode_2, "ELLPS_ES" , _TL("Squared Eccentricity (es)") , _TL(""), PARAMETER_TYPE_Double, WGS84_ELLPS_A*WGS84_ELLPS_A + WGS84_ELLPS_B*WGS84_ELLPS_B); //----------------------------------------------------- // Datum Shift... pNode_2 = pParameters->Add_Choice( pNode_1, "DATUM_SHIFT" , _TL("Datum Shift"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("none"), _TL("3 parameters (translation only)"), _TL("7 parameters"), _TL("Datum Shift Grid") ) ); pParameters->Add_Value (pNode_2, "DS_DX" , _TL("Translation X") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_DY" , _TL("Translation Y") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_DZ" , _TL("Translation Z") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_RX" , _TL("Rotation X") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_RY" , _TL("Rotation Y") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_RZ" , _TL("Rotation Z") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_2, "DS_SC" , _TL("Scaling") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_FilePath( pNode_2, "DATUM_GRID" , _TL("Datum Shift Grid File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("NTv2 Grid Shift Binary (*.gsb)") , SG_T("*.gsb"), _TL("All Files") , SG_T("*.*") ), NULL, false, false, false ); //----------------------------------------------------- // General Settings... pNode_1 = pParameters->Add_Node(pNode_0, "NODE_GENERAL" , _TL("General Settings"), _TL("")); pParameters->Add_Value (pNode_1, "LON_0" , _TL("Central Meridian") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_1, "LAT_0" , _TL("Central Parallel") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_1, "X_0" , _TL("False Easting") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_1, "Y_0" , _TL("False Northing") , _TL(""), PARAMETER_TYPE_Double, 0.0); pParameters->Add_Value (pNode_1, "K_0" , _TL("Scale Factor") , _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true); pParameters->Add_Choice (pNode_1, "UNIT" , _TL("Unit") , _TL(""), sUnits, 1); pParameters->Add_Value (pNode_1, "NO_DEFS" , _TL("Ignore Defaults") , _TL(""), PARAMETER_TYPE_Bool, false); pParameters->Add_Value (pNode_1, "OVER" , _TL("Allow longitudes outside -180 to 180 Range") , _TL(""), PARAMETER_TYPE_Bool, false); //----------------------------------------------------- pParameters->Add_Parameters( pNode_0, "OPTIONS" , _TL("Projection Settings"), _TL("") ); pParameters->Get_Parameter("OPTIONS")->asParameters()->Assign(Get_Parameters(SG_STR_MBTOSG(pj_list[0].id))); //----------------------------------------------------- return( true ); } //--------------------------------------------------------- #define PRM_ADD_BOL(key, name, val) pParms->Add_Value (NULL, key, name, _TL(""), PARAMETER_TYPE_Bool , val); #define PRM_ADD_INT(key, name, val) pParms->Add_Value (NULL, key, name, _TL(""), PARAMETER_TYPE_Int , val); #define PRM_ADD_FLT(key, name, val) pParms->Add_Value (NULL, key, name, _TL(""), PARAMETER_TYPE_Double, val); #define PRM_ADD_STR(key, name, val) pParms->Add_String(NULL, key, name, _TL(""), val); #define PRM_ADD_CHO(key, name, val) pParms->Add_Choice(NULL, key, name, _TL(""), val); //--------------------------------------------------------- bool CCRS_Base::Add_User_Projection(const CSG_String &sID, const CSG_String &sName, const CSG_String &sArgs) { if( sArgs.Length() == 0 ) { return( false ); } CSG_Parameters *pParms = Add_Parameters(sID, sName, sArgs); // pParms->Add_Info_String(NULL, "DESC", _TL("Description"), _TL(""), sArgs.c_str(), true); //----------------------------------------------------- // Cylindrical Projections... if( !sID.CmpNoCase(SG_T("cea")) // Equal Area Cylindrical || !sID.CmpNoCase(SG_T("eqc")) // Equidistant Cylindrical (Plate Caree) || !sID.CmpNoCase(SG_T("merc")) ) // Mercator { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 0.0); } if( !sID.CmpNoCase(SG_T("utm")) ) // Universal Transverse Mercator (UTM) { PRM_ADD_INT("zone" , _TL("Zone") , 32); PRM_ADD_BOL("south" , _TL("South") , false); } if( !sID.CmpNoCase(SG_T("omerc")) ) // Oblique Mercator { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1" ) ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 50.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2" ) , 20.0); } //----------------------------------------------------- // Pseudocylindrical Projections... if( !sID.CmpNoCase(SG_T("gn_sinu")) ) // General Sinusoidal Series { PRM_ADD_FLT("m" , SG_T("m") , 0.5); PRM_ADD_FLT("n" , SG_T("n") , 1.0 + M_PI_045); } if( !sID.CmpNoCase(SG_T("loxim")) ) // Loximuthal { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } if( !sID.CmpNoCase(SG_T("urmfps")) ) // Urmaev Flat-Polar Sinusoidal { PRM_ADD_FLT("n" , SG_T("n") , 1.0); } if( !sID.CmpNoCase(SG_T("urm5")) ) // Urmaev V { PRM_ADD_FLT("n" , SG_T("n") , 1.0); PRM_ADD_FLT("q" , SG_T("q") , 1.0); PRM_ADD_FLT("alphi" , SG_T("alphi") , 45.0); } if( !sID.CmpNoCase(SG_T("wink1")) // Winkel I || !sID.CmpNoCase(SG_T("wag3")) ) // Wagner III { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("wink2")) ) // Winkel II { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } //----------------------------------------------------- // Conic Projections... if( !sID.CmpNoCase(SG_T("aea")) // Albers Equal Area || !sID.CmpNoCase(SG_T("eqdc")) // Equidistant Conic || !sID.CmpNoCase(SG_T("euler")) // Euler || !sID.CmpNoCase(SG_T("imw_p")) // International Map of the World Polyconic || !sID.CmpNoCase(SG_T("murd1")) // Murdoch I || !sID.CmpNoCase(SG_T("murd2")) // Murdoch II || !sID.CmpNoCase(SG_T("murd3")) // Murdoch III || !sID.CmpNoCase(SG_T("pconic")) // Perspective Conic || !sID.CmpNoCase(SG_T("tissot")) // Tissot || !sID.CmpNoCase(SG_T("vitk1")) ) // Vitkovsky I { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); } if( !sID.CmpNoCase(SG_T("lcc")) ) // Lambert Conformal Conic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); } if( !sID.CmpNoCase(SG_T("leac")) ) // Lambert Equal Area Conic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 45.0); PRM_ADD_BOL("south" , _TL("South") , false); } if( !sID.CmpNoCase(SG_T("rpoly")) ) // Rectangular Polyconic { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("mpoly")) ) // Modified Polyconic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); PRM_ADD_BOL("lotsa" , _TL("Lotsa") , true); } if( !sID.CmpNoCase(SG_T("bonne")) ) // Bonne { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 45.0); } //----------------------------------------------------- // Azimuthal Projections... if( !sID.CmpNoCase(SG_T("stere")) ) // Stereographic { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("ups")) ) // Universal Polar Stereographic { PRM_ADD_BOL("south" , _TL("South") , true); } if( !sID.CmpNoCase(SG_T("airy")) ) // Airy { PRM_ADD_FLT("lat_b" , _TL("Latitude B") , 45.0); PRM_ADD_BOL("no_cut" , _TL("No Cut") , true); } if( !sID.CmpNoCase(SG_T("nsper")) ) // Near-sided perspective { PRM_ADD_FLT("h" , _TL("Height of view point") , 1.0); } if( !sID.CmpNoCase(SG_T("aeqd")) ) // Azimuthal Equidistant { PRM_ADD_BOL("guam" , _TL("guam") , true); } if( !sID.CmpNoCase(SG_T("hammer")) ) // Hammer & Eckert-Greifendorff { PRM_ADD_FLT("W" , _TL("W") , 0.5); PRM_ADD_FLT("M" , _TL("M") , 1.0); } if( !sID.CmpNoCase(SG_T("wintri")) ) // Winkel Tripel { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } //----------------------------------------------------- // Miscellaneous Projections... if( !sID.CmpNoCase(SG_T("ocea")) // Oblique Cylindrical Equal Area || !sID.CmpNoCase(SG_T("tpeqd")) ) // Two Point Equidistant { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1") ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 50.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2" ) , 20.0); } if( !sID.CmpNoCase(SG_T("geos")) ) // Geostationary Satellite View { PRM_ADD_FLT("h" , _TL("Satellite Height [m]") , 35785831.0); PRM_ADD_CHO("sweep" , _TL("Sweep Angle") , "x|y|"); } if( !sID.CmpNoCase(SG_T("lsat")) ) // Space oblique for LANDSAT { PRM_ADD_INT("lsat" , _TL("Landsat Satellite (1-5)"), 1.0); PRM_ADD_INT("path" , _TL("Path (1-255/233 1-3/4-5"), 1.0); } if( !sID.CmpNoCase(SG_T("labrd")) ) // Laborde { PRM_ADD_FLT("azi" , _TL("Azimuth" ) , 19.0); } if( !sID.CmpNoCase(SG_T("lagrng")) ) // Lagrange { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 0.0); PRM_ADD_FLT("W" , _TL("W") , 2.0); } if( !sID.CmpNoCase(SG_T("chamb")) ) // Chamberlin Trimetric { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 30.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1" ) ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 40.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2") , 00.0); PRM_ADD_FLT("lat_3" , _TL("Latitude 3") , 50.0); PRM_ADD_FLT("lon_3" , _TL("Longitude 3" ) , 20.0); } if( !sID.CmpNoCase(SG_T("oea")) ) // Oblated Equal Area { PRM_ADD_FLT("m" , _TL("m") , 1.0); PRM_ADD_FLT("n" , _TL("n") , 1.0); PRM_ADD_FLT("theta" , _TL("theta") , 45.0); } if( !sID.CmpNoCase(SG_T("tpers")) ) // Tilted perspective { PRM_ADD_FLT("tilt" , _TL("Tilt") , 45.0); PRM_ADD_FLT("azi" , _TL("Azimuth") , 45.0); PRM_ADD_FLT("h" , _TL("h") , 1000.0); } if( !sID.CmpNoCase(SG_T("ob_tran")) ) // General Oblique Transformation { PRM_ADD_FLT("o_lat_p" , _TL("Latitude Pole") , 40.0); PRM_ADD_FLT("o_lon_p" , _TL("Longitude Pole") , 40.0); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PROJ4_ADD_BOL(key, val) if( val ) Proj4 += CSG_String::Format(SG_T("+%s "), CSG_String(key).c_str()); #define PROJ4_ADD_INT(key, val) Proj4 += CSG_String::Format(SG_T("+%s=%d "), CSG_String(key).c_str(), val); #define PROJ4_ADD_FLT(key, val) Proj4 += CSG_String::Format(SG_T("+%s=%s "), CSG_String(key).c_str(), SG_Get_String(val, -32).c_str()); #define PROJ4_ADD_STR(key, val) Proj4 += CSG_String::Format(SG_T("+%s=%s "), CSG_String(key).c_str(), CSG_String(val).c_str()); //--------------------------------------------------------- CSG_String CCRS_Base::Get_User_Definition(CSG_Parameters &P) { CSG_String Proj4; //----------------------------------------------------- PROJ4_ADD_STR("proj" , pj_list[P("PROJ_TYPE")->asInt()].id); if( P("LON_0")->asDouble() ) PROJ4_ADD_FLT("lon_0", P("LON_0")->asDouble()); if( P("LAT_0")->asDouble() ) PROJ4_ADD_FLT("lat_0", P("LAT_0")->asDouble()); if( P("X_0" )->asDouble() ) PROJ4_ADD_FLT("x_0" , P("X_0" )->asDouble()); if( P("Y_0" )->asDouble() ) PROJ4_ADD_FLT("y_0" , P("Y_0" )->asDouble()); if( P("K_0")->asDouble() != 1.0 && P("K_0")->asDouble() > 0.0 ) { PROJ4_ADD_FLT("k_0", P("K_0")->asDouble()); } PROJ4_ADD_STR("units", pj_units[P("UNIT")->asInt()].id); //----------------------------------------------------- switch( P("DATUM_DEF")->asInt() ) { case 0: // predefined datum PROJ4_ADD_STR("datum", pj_datums[P("DATUM")->asInt()].id); break; //----------------------------------------------------- case 1: // user defined datum switch( P("ELLIPSOID")->asInt() ) { case 0: // Predefined Ellipsoid PROJ4_ADD_STR("ellps", pj_ellps[P("ELLPS_DEF")->asInt()].id); break; case 1: // Semiminor axis PROJ4_ADD_FLT("a" , P("ELLPS_A" )->asDouble()); PROJ4_ADD_FLT("b" , P("ELLPS_B" )->asDouble()); break; case 2: // Flattening PROJ4_ADD_FLT("a" , P("ELLPS_A" )->asDouble()); PROJ4_ADD_FLT("f" , P("ELLPS_F" )->asDouble()); break; case 3: // Reciprocal Flattening PROJ4_ADD_FLT("a" , P("ELLPS_A" )->asDouble()); PROJ4_ADD_FLT("rf" , P("ELLPS_RF")->asDouble()); break; case 4: // Eccentricity PROJ4_ADD_FLT("a" , P("ELLPS_A" )->asDouble()); PROJ4_ADD_FLT("e" , P("ELLPS_E" )->asDouble()); break; case 5: // Eccentricity Squared PROJ4_ADD_FLT("a" , P("ELLPS_A" )->asDouble()); PROJ4_ADD_FLT("es" , P("ELLPS_ES")->asDouble()); break; } switch( P("DATUM_SHIFT")->asInt() ) { case 1: // 3 parameters PROJ4_ADD_STR("towgs84", CSG_String::Format(SG_T("%s,%s,%s"), SG_Get_String(P("DS_DX")->asDouble(), -32).c_str(), SG_Get_String(P("DS_DY")->asDouble(), -32).c_str(), SG_Get_String(P("DS_DZ")->asDouble(), -32).c_str()) ); break; case 2: // 7 parameters PROJ4_ADD_STR("towgs84", CSG_String::Format(SG_T("%s,%s,%s,%s,%s,%s,%s"), SG_Get_String(P("DS_DX")->asDouble(), -32).c_str(), SG_Get_String(P("DS_DY")->asDouble(), -32).c_str(), SG_Get_String(P("DS_DZ")->asDouble(), -32).c_str(), SG_Get_String(P("DS_RX")->asDouble(), -32).c_str(), SG_Get_String(P("DS_RY")->asDouble(), -32).c_str(), SG_Get_String(P("DS_RZ")->asDouble(), -32).c_str(), SG_Get_String(P("DS_SC")->asDouble(), -32).c_str()) ); break; case 3: // datum shift grid... if( SG_File_Exists(P("DATUM_GRID")->asString()) ) { PROJ4_ADD_STR("nadgrids", P("DATUM_GRID")->asString()); } break; } break; } //----------------------------------------------------- for(int i=0; iasParameters()->Get_Count(); i++) { CSG_Parameter *p = P("OPTIONS")->asParameters()->Get_Parameter(i); switch( p->Get_Type() ) { case PARAMETER_TYPE_Choice: case PARAMETER_TYPE_String: PROJ4_ADD_STR(p->Get_Identifier(), p->asString()); break; case PARAMETER_TYPE_Bool: PROJ4_ADD_BOL(p->Get_Identifier(), p->asBool ()); break; case PARAMETER_TYPE_Int: PROJ4_ADD_INT(p->Get_Identifier(), p->asInt ()); break; case PARAMETER_TYPE_Double: PROJ4_ADD_FLT(p->Get_Identifier(), p->asDouble()); break; } } //----------------------------------------------------- PROJ4_ADD_BOL("no_defs", P("NO_DEFS")->asBool()); PROJ4_ADD_BOL("over" , P("OVER" )->asBool()); return( Proj4 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define _K(key) (CSG_String("+") + key) #define PROJ4_HAS_KEY(key) (Proj4.Find(_K(key)) >= 0) #define PROJ4_HAS_VAL(key) (Proj4.Find(_K(key)) >= 0 && !Proj4.Right(Proj4.Length() - Proj4.Find(_K(key))).BeforeFirst('=').Cmp(_K(key))) #define PROJ4_GET_VAL(key) (Proj4.Right(PROJ4_HAS_VAL(key) ? Proj4.Length() - Proj4.Find(_K(key)) : 0).AfterFirst('=').BeforeFirst(' ')) #define PROJ4_SET_BOL(key, id) { if( P(id) ) P(id)->Set_Value(PROJ4_HAS_KEY(key) ? 1 : 0); } #define PROJ4_SET_INT(key, id) { int val; if( P(id) && PROJ4_GET_VAL(key).asInt (val) ) P(id)->Set_Value(val); } #define PROJ4_SET_FLT(key, id) { double val; if( P(id) && PROJ4_GET_VAL(key).asDouble(val) ) P(id)->Set_Value(val); } #define PROJ4_SET_STR(key, id) { if( P(id) && PROJ4_HAS_VAL(key) ) P(id)->Set_Value(PROJ4_GET_VAL(key)); } #define PROJ4_SET_CHC(key, id) if( P(id) ) { CSG_Parameter_Choice *pList = P(id)->asChoice(); CSG_String s(PROJ4_GET_VAL(key));\ for(int i=0; iGet_Count(); i++)\ {\ if( !pList->Get_Item_Data(i).Cmp(s) )\ {\ P(id)->Set_Value(i); break;\ }\ }\ } //--------------------------------------------------------- bool CCRS_Base::Set_User_Definition(CSG_Parameters &P, const CSG_String &Proj4) { P.Restore_Defaults(); PROJ4_SET_CHC("proj" , "PROJ_TYPE"); PROJ4_SET_CHC("datum", "DATUM" ); PROJ4_SET_CHC("ellps", "ELLPS_DEF"); PROJ4_SET_CHC("units", "UNIT" ); PROJ4_SET_FLT("lon_0", "LON_0" ); PROJ4_SET_FLT("lat_0", "LAT_0" ); PROJ4_SET_FLT("x_0" , "X_0" ); PROJ4_SET_FLT("y_0" , "Y_0" ); PROJ4_SET_FLT("k_0" , "K_0" ); PROJ4_SET_FLT("a" , "ELLPS_A" ); PROJ4_SET_FLT("b" , "ELLPS_B" ); PROJ4_SET_FLT("f" , "ELLPS_F" ); PROJ4_SET_FLT("rf" , "ELLPS_RF" ); PROJ4_SET_FLT("e" , "ELLPS_E" ); PROJ4_SET_FLT("es" , "ELLPS_ES" ); PROJ4_SET_BOL("no_defs", "NO_DEFS"); PROJ4_SET_BOL("over" , "OVER" ); //----------------------------------------------------- // switch( P("DATUM_DEF")->asInt() ) if( PROJ4_HAS_VAL("datum") ) P("DATUM_DEF")->Set_Value(0); // case 0: // predefined datum else P("DATUM_DEF")->Set_Value(1); // case 1: // user defined datum // switch( P("ELLIPSOID")->asInt() ) if( PROJ4_HAS_VAL("ellps") ) P("ELLIPSOID")->Set_Value(0); // case 0: // Predefined Ellipsoid if( PROJ4_HAS_VAL("b" ) ) P("ELLIPSOID")->Set_Value(1); // case 1: // Semiminor axis if( PROJ4_HAS_VAL("f" ) ) P("ELLIPSOID")->Set_Value(2); // case 2: // Flattening if( PROJ4_HAS_VAL("rf" ) ) P("ELLIPSOID")->Set_Value(3); // case 3: // Reciprocal Flattening if( PROJ4_HAS_VAL("e" ) ) P("ELLIPSOID")->Set_Value(4); // case 4: // Eccentricity if( PROJ4_HAS_VAL("es" ) ) P("ELLIPSOID")->Set_Value(5); // case 5: // Eccentricity Squared // switch( P("DATUM_SHIFT")->asInt() ) CSG_String_Tokenizer params(PROJ4_GET_VAL("towgs84"), ", "); if( params.Get_Tokens_Count() == 3 || params.Get_Tokens_Count() == 7 ) { P("DATUM_SHIFT")->Set_Value(1); // case 1: // 3 parameters P("DS_DX")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_DY")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_DZ")->Set_Value(params.Get_Next_Token().asDouble()); } else if( params.Get_Tokens_Count() == 7 ) { P("DATUM_SHIFT")->Set_Value(2); // case 2: // 7 parameters P("DS_DX")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_DY")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_DZ")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_RX")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_RY")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_RZ")->Set_Value(params.Get_Next_Token().asDouble()); P("DS_SC")->Set_Value(params.Get_Next_Token().asDouble()); } else if( PROJ4_HAS_VAL("nadgrids") && SG_File_Exists(PROJ4_GET_VAL("nadgrids")) ) { P("DATUM_SHIFT")->Set_Value(3); // case 3: // datum shift grid... PROJ4_SET_STR("nadgrids", "DATUM_GRID"); } else { P("DATUM_SHIFT")->Set_Value(0); // case 0: // none } //----------------------------------------------------- P("OPTIONS")->asParameters()->Assign(Get_Parameters(SG_STR_MBTOSG(pj_list[P("PROJ_TYPE")->asInt()].id))); for(int i=0; iasParameters()->Get_Count(); i++) { CSG_Parameter *p = P("OPTIONS")->asParameters()->Get_Parameter(i); switch( p->Get_Type() ) { case PARAMETER_TYPE_Choice: case PARAMETER_TYPE_String: p->Set_Value(PROJ4_GET_VAL(p->Get_Identifier()) ); break; case PARAMETER_TYPE_Bool: p->Set_Value(PROJ4_HAS_KEY(p->Get_Identifier()) ? 1 : 0 ); break; case PARAMETER_TYPE_Int: p->Set_Value(PROJ4_GET_VAL(p->Get_Identifier()).asInt ()); break; case PARAMETER_TYPE_Double: p->Set_Value(PROJ4_GET_VAL(p->Get_Identifier()).asDouble()); break; } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Picker::CCRS_Picker(void) { //----------------------------------------------------- Set_Name (_TL("Coordinate Reference System Picker")); Set_Author (SG_T("O.Conrad (c) 2014")); Set_Description (_TW( "Define or pick a Coordinate Reference System (CRS). " "It is intended to call this tool only from other tools." )); } //--------------------------------------------------------- bool CCRS_Picker::On_Execute(void) { CSG_Projection Target; if( !Get_Projection(Target) ) { return( false ); } Message_Add(CSG_String::Format(SG_T("\n%s: %s"), _TL("target"), Target.Get_Proj4().c_str()), false); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform::On_Execute(void) { //----------------------------------------------------- CSG_Projection Target; if( !Get_Projection(Target) || !m_Projector.Set_Target(Target) ) { return( false ); } Message_Add(CSG_String::Format(SG_T("\n%s: %s"), _TL("target"), Target.Get_Proj4().c_str()), false); //----------------------------------------------------- m_Projector.Set_Precise_Mode(Parameters("PRECISE") && Parameters("PRECISE")->asBool()); bool bResult = On_Execute_Transformation(); m_Projector.Destroy(); return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/Makefile.am0000744000175000017500000000206112737416201023765 0ustar00oconradoconrad00000000000000# # $Id$ # DEP_LIBS = -lproj if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core $(LOCAL_INCS) AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) $(LOCAL_LIBS) pkglib_LTLIBRARIES = libpj_proj4.la libpj_proj4_la_SOURCES =\ MLB_Interface.cpp\ crs_assign.cpp\ crs_base.cpp\ crs_distance.cpp\ crs_grid_geogcoords.cpp\ crs_indicatrix.cpp\ crs_transform.cpp\ crs_transform_grid.cpp\ crs_transform_pointcloud.cpp\ crs_transform_shapes.cpp\ gcs_graticule.cpp\ gcs_lon_range.cpp\ PROJ4_Base.cpp\ PROJ4_Grid.cpp\ PROJ4_Shapes.cpp\ MLB_Interface.h\ crs_assign.h\ crs_base.h\ crs_distance.h\ crs_grid_geogcoords.h\ crs_indicatrix.h\ crs_transform.h\ crs_transform_grid.h\ crs_transform_pointcloud.h\ crs_transform_shapes.h\ gcs_graticule.h\ gcs_lon_range.h\ PROJ4_Base.h\ PROJ4_Grid.h\ PROJ4_Shapes.h libpj_proj4_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/projection/pj_proj4/PROJ4_Grid.cpp0000744000175000017500000004147212737416201024251 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Grid.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "PROJ4_Grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPROJ4_Grid::CPROJ4_Grid(int Interface, bool bInputList) : CPROJ4_Base(Interface, bInputList) { //----------------------------------------------------- Set_Name (CSG_String::Format(SG_T("[deprecated] %s (%s, %s)"), _TL("Proj.4"), Interface == PROJ4_INTERFACE_DIALOG ? _TL("Dialog") : _TL("Command Line Arguments"), m_bInputList ? _TL("List of Grids") : _TL("Grid") )); Set_Author ("O. Conrad (c) 2004-8"); Set_Description (_TW( "Coordinate Transformation for Grids.\n" "Based on the PROJ.4 Cartographic Projections library originally written by Gerald Evenden " "and later continued by the United States Department of the Interior, Geological Survey (USGS).\n" "Proj.4 Homepage\n" )); //----------------------------------------------------- m_Grid_Target.Create(Add_Parameters("TARGET", _TL("Target Grid System"), _TL("")), false); if( m_bInputList ) { Parameters.Add_Grid_List( Parameters("SOURCE_NODE"), "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT, false ); Parameters.Add_Grid_List( NULL, "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } else { Parameters.Add_Grid( Parameters("SOURCE_NODE"), "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); m_Grid_Target.Add_Grid("TARGET", _TL("Target"), false); } m_Grid_Target.Add_Grid("OUT_X", _TL("X Coordinates"), true); m_Grid_Target.Add_Grid("OUT_Y", _TL("Y Coordinates"), true); //----------------------------------------------------- Parameters.Add_Choice( Parameters("TARGET_NODE"), "RESAMPLING", _TL("Resampling"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 3 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPROJ4_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CPROJ4_Base::On_Parameter_Changed(pParameters, pParameter); return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CPROJ4_Grid::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CPROJ4_Base::On_Parameters_Enable(pParameters, pParameter); return( m_Grid_Target.On_Parameters_Enable(pParameters, pParameter) ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Grid::On_Execute_Conversion(void) { TSG_Rect Extent; switch( Parameters("RESAMPLING")->asInt() ) { default: m_Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: m_Resampling = GRID_RESAMPLING_Bilinear; break; case 2: m_Resampling = GRID_RESAMPLING_BicubicSpline; break; case 3: m_Resampling = GRID_RESAMPLING_BSpline; break; } //----------------------------------------------------- if( m_bInputList ) { CSG_Parameter_Grid_List *pSources = Parameters("SOURCE")->asGridList(); CSG_Parameter_Grid_List *pTargets = Parameters("TARGET")->asGridList(); if( pSources->Get_Count() < 1 ) { return( false ); } if( Get_Target_Extent(pSources->asGrid(0), Extent) ) { m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), Extent, pSources->asGrid(0)->Get_NY()); } if( !Dlg_Parameters("TARGET") ) { return( false ); } CSG_Grid_System System(m_Grid_Target.Get_System()); //------------------------------------------------- if( System.is_Valid() ) { pTargets->Del_Items(); for(int i=0; iGet_Count(); i++) { pTargets->Add_Item(SG_Create_Grid(System, m_Resampling == 0 ? pSources->asGrid(i)->Get_Type() : SG_DATATYPE_Float)); Init_Target(pSources->asGrid(i), pTargets->asGrid(i)); } return( Set_Grids(pSources, pTargets) ); } } //----------------------------------------------------- else { CSG_Grid *pSource = Parameters("SOURCE")->asGrid(); if( Get_Target_Extent(pSource, Extent) ) { m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), Extent, pSource->Get_NY()); } if( !Dlg_Parameters("TARGET") ) { return( false ); } CSG_Grid *pTarget = m_Grid_Target.Get_Grid(m_Resampling == 0 ? pSource->Get_Type() : SG_DATATYPE_Float); //------------------------------------------------- if( pTarget ) { return( Set_Grid(pSource, pTarget) ); } } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Grid::Set_Grids(CSG_Parameter_Grid_List *pSources, CSG_Parameter_Grid_List *pTargets) { if( !pSources || pSources->Get_Count() < 1 || !pTargets || pTargets->Get_Count() != pSources->Get_Count() || !Set_Inverse() ) { return( false ); } //------------------------------------------------- int x, y, i; double z; TSG_Point Pt_Source, Pt_Target; CSG_Grid_System System; CSG_Grid *pX, *pY; System = pTargets->asGrid(0)->Get_System(); Init_XY(System, &pX, &pY); //------------------------------------------------- for(y=0, Pt_Target.y=System.Get_YMin(); ySet_Value(x, y, Pt_Source.x); if( pY ) pY->Set_Value(x, y, Pt_Source.y); for(i=0; iGet_Count(); i++) { if( pSources->asGrid(i)->Get_Value(Pt_Source, z, m_Resampling) ) { pTargets->asGrid(i)->Set_Value(x, y, z); } } } } } return( true ); } //--------------------------------------------------------- bool CPROJ4_Grid::Set_Shapes(CSG_Parameter_Grid_List *pSources, CSG_Shapes *pTarget) { int x, y, i; double z; TSG_Point Pt_Source, Pt_Target; CSG_Grid *pSource; CSG_Shape *pShape; if( pSources && pSources->Get_Count() > 0 && pTarget ) { pSource = pSources->asGrid(0); pTarget->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pSource->Get_Name(), Get_Proj_Name().c_str())); for(i=0; iGet_Count(); i++) { pTarget->Add_Field(pSources->asGrid(i)->Get_Name(), pSources->asGrid(i)->Get_Type()); } for(y=0, Pt_Source.y=pSource->Get_YMin(); yGet_NY() && Set_Progress(y, pSource->Get_NY()); y++, Pt_Source.y+=pSource->Get_Cellsize()) { for(x=0, Pt_Source.x=pSource->Get_XMin(); xGet_NX(); x++, Pt_Source.x+=pSource->Get_Cellsize()) { if( !pSource->is_NoData(x, y) ) { Pt_Target = Pt_Source; if( Get_Converted(Pt_Target) ) { pShape = pTarget->Add_Shape(); pShape->Add_Point(Pt_Target); for(i=0; iGet_Count(); i++) { if( pSources->asGrid(i)->Get_Value(Pt_Source, z, m_Resampling) ) { pShape->Set_Value(i, z); } else { pShape->Set_NoData(i); } } } } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Grid::Set_Grid(CSG_Grid *pSource, CSG_Grid *pTarget) { if( pSource && pTarget && Set_Inverse() ) { int x, y; double z; TSG_Point Pt_Source, Pt_Target; CSG_Grid *pX, *pY; Init_XY(pTarget->Get_System(), &pX, &pY); Init_Target(pSource, pTarget); //------------------------------------------------- for(y=0, Pt_Target.y=pTarget->Get_YMin(); yGet_NY() && Set_Progress(y, pTarget->Get_NY()); y++, Pt_Target.y+=pTarget->Get_Cellsize()) { for(x=0, Pt_Target.x=pTarget->Get_XMin(); xGet_NX(); x++, Pt_Target.x+=pTarget->Get_Cellsize()) { Pt_Source = Pt_Target; if( Get_Converted(Pt_Source) ) { if( pX ) pX->Set_Value(x, y, Pt_Source.x); if( pY ) pY->Set_Value(x, y, Pt_Source.y); if( pSource->Get_Value(Pt_Source, z, m_Resampling) ) { pTarget->Set_Value(x, y, z); } } } } return( true ); } return( false ); } //--------------------------------------------------------- bool CPROJ4_Grid::Set_Shapes(CSG_Grid *pSource, CSG_Shapes *pTarget) { int x, y; TSG_Point Pt_Source, Pt_Target; CSG_Shape *pShape; if( pSource && pTarget ) { pTarget->Create(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), pSource->Get_Name(), Get_Proj_Name().c_str())); pTarget->Add_Field("Z", SG_DATATYPE_Double); for(y=0, Pt_Source.y=pSource->Get_YMin(); yGet_NY() && Set_Progress(y, pSource->Get_NY()); y++, Pt_Source.y+=pSource->Get_Cellsize()) { for(x=0, Pt_Source.x=pSource->Get_XMin(); xGet_NX(); x++, Pt_Source.x+=pSource->Get_Cellsize()) { if( !pSource->is_NoData(x, y) ) { Pt_Target = Pt_Source; if( Get_Converted(Pt_Target) ) { pShape = pTarget->Add_Shape(); pShape->Add_Point(Pt_Target); pShape->Set_Value(0, pSource->asDouble(x, y)); } } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Grid::Init_XY(const CSG_Grid_System &System, CSG_Grid **ppX, CSG_Grid **ppY) { *ppX = *ppY = NULL; if( (*ppX = m_Grid_Target.Get_Grid("OUT_X", SG_DATATYPE_Float)) != NULL ) { (*ppX)->Assign_NoData(); (*ppX)->Set_Name(_TL("X Coordinates")); } if( (*ppY = m_Grid_Target.Get_Grid("OUT_Y", SG_DATATYPE_Float)) != NULL ) { (*ppY)->Assign_NoData(); (*ppY)->Set_Name(_TL("Y Coordinates")); } return( true ); } //--------------------------------------------------------- bool CPROJ4_Grid::Init_Target(CSG_Grid *pSource, CSG_Grid *pTarget) { if( pSource && pTarget ) { pTarget->Set_NoData_Value_Range(pSource->Get_NoData_Value(), pSource->Get_NoData_hiValue()); pTarget->Set_Scaling(pSource->Get_Scaling(), pSource->Get_Offset()); pTarget->Set_Name (CSG_String::Format(SG_T("%s [%s]"), pSource->Get_Name(), Get_Proj_Name(false).c_str())); pTarget->Set_Unit (pSource->Get_Unit()); pTarget->Assign_NoData(); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CPROJ4_Grid::Get_MinMax(TSG_Rect &r, double x, double y) { if( Get_Converted(x, y) ) { if( r.xMin > r.xMax ) { r.xMin = r.xMax = x; } else if( r.xMin > x ) { r.xMin = x; } else if( r.xMax < x ) { r.xMax = x; } if( r.yMin > r.yMax ) { r.yMin = r.yMax = y; } else if( r.yMin > y ) { r.yMin = y; } else if( r.yMax < y ) { r.yMax = y; } } } //--------------------------------------------------------- bool CPROJ4_Grid::Get_Target_Extent(CSG_Grid *pSource, TSG_Rect &Extent) { if( !pSource ) { return( false ); } int x, y, Resolution; Resolution = 256; Extent.xMin = Extent.yMin = 1.0; Extent.xMax = Extent.yMax = 0.0; switch( 1 ) { case 0: // corners { Get_MinMax(Extent, pSource->Get_XMin(), pSource->Get_YMin()); Get_MinMax(Extent, pSource->Get_XMax(), pSource->Get_YMin()); Get_MinMax(Extent, pSource->Get_XMin(), pSource->Get_YMax()); Get_MinMax(Extent, pSource->Get_XMax(), pSource->Get_YMax()); } break; case 1: // edges { double d; int yStep = 1 + pSource->Get_NY() / Resolution; for(y=0, d=pSource->Get_YMin(); yGet_NY(); y+=yStep, d+=yStep*pSource->Get_Cellsize()) { Get_MinMax(Extent, pSource->Get_XMin(), d); Get_MinMax(Extent, pSource->Get_XMax(), d); } int xStep = 1 + pSource->Get_NX() / Resolution; for(x=0, d=pSource->Get_XMin(); xGet_NX(); x+=xStep, d+=xStep*pSource->Get_Cellsize()) { Get_MinMax(Extent, d, pSource->Get_YMin()); Get_MinMax(Extent, d, pSource->Get_YMax()); } } break; case 2: // all cells { TSG_Point p; int xStep = 1 + pSource->Get_NX() / Resolution; int yStep = 1 + pSource->Get_NY() / Resolution; for(y=0, p.y=pSource->Get_YMin(); yGet_NY() && Set_Progress(y, pSource->Get_NY()); y+=yStep, p.y+=yStep*pSource->Get_Cellsize()) { for(x=0, p.x=pSource->Get_XMin(); xGet_NX(); x+=xStep, p.x+=xStep*pSource->Get_Cellsize()) { if( !pSource->is_NoData(x, y) ) { Get_MinMax(Extent, p.x, p.y); } } } } break; } return( is_Progress() && Extent.xMin < Extent.xMax && Extent.yMin < Extent.yMax ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/PROJ4_Base.h0000744000175000017500000001233212737416201023674 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Base.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__PROJ4_Base_H #define HEADER_INCLUDED__PROJ4_Base_H //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { PROJ4_INTERFACE_SIMPLE = 0, PROJ4_INTERFACE_DIALOG }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CPROJ4_Base : public CSG_Module { public: CPROJ4_Base(int Interface, bool bInputList); virtual bool do_Sync_Projections (void) { return( false ); } protected: bool m_bInputList; virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); virtual bool On_Execute_Conversion (void) = 0; bool Set_Inverse (bool bOn = true); CSG_String Get_Proj_Name (bool bDestination = true); bool Get_Converted (double &x, double &y); bool Get_Converted (TSG_Point &Point); private: bool m_bInverse; int m_Interface; PJ *m_pPrjSrc, *m_pPrjDst; bool _Get_Projections (CSG_String &sPrjSrc, CSG_String &sPrjDst); bool _Get_Projection (CSG_String &sPrj, CSG_Parameters &P); bool _Init_Projection (CSG_Parameters &P); bool _Init_Projection (const CSG_String &sID, const CSG_String &sName, const CSG_String &sArgs); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__PROJ4_Base_H saga-2.3.1/src/modules/projection/pj_proj4/crs_grid_geogcoords.h0000744000175000017500000001006612737416202026116 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_grid_geogcoords.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_grid_geogcoords_H #define HEADER_INCLUDED__crs_grid_geogcoords_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Grid_GeogCoords : public CSG_Module_Grid { public: CCRS_Grid_GeogCoords(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_grid_geogcoords_H saga-2.3.1/src/modules/projection/pj_proj4/crs_base.h0000744000175000017500000001270712737416201023673 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_base.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_base_H #define HEADER_INCLUDED__crs_base_H //--------------------------------------------------------- #include "crs_transform.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Base : public CSG_Module { public: CCRS_Base(void); virtual bool do_Sync_Projections (void) { return( false ); } protected: virtual bool On_Before_Execution (void); virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); bool Get_Projection (CSG_Projection &Projection); private: CSG_Projection m_Projection; bool Set_User_Parameters (CSG_Parameters *pParameters); bool Add_User_Projection (const CSG_String &sID, const CSG_String &sName, const CSG_String &sArgs); CSG_String Get_User_Definition (CSG_Parameters &pParameters); bool Set_User_Definition (CSG_Parameters &pParameters, const CSG_String &Proj4); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Picker : public CCRS_Base { public: CCRS_Picker(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class pj_proj4_EXPORT CCRS_Transform : public CCRS_Base { public: CCRS_Transform(void) {} protected: CSG_CRSProjector m_Projector; virtual bool On_Execute (void); virtual bool On_Execute_Transformation (void) = 0; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_base_H saga-2.3.1/src/modules/projection/pj_proj4/crs_distance.cpp0000744000175000017500000004067512737416201025113 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_distance.cpp 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_distance.cpp // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_distance.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Distance_Calculator::CCRS_Distance_Calculator(void) {} //--------------------------------------------------------- CCRS_Distance_Calculator::CCRS_Distance_Calculator(const CSG_Projection &Projection, double Epsilon) { Create(Projection, Epsilon); } //--------------------------------------------------------- CCRS_Distance_Calculator::~CCRS_Distance_Calculator(void) {} //--------------------------------------------------------- bool CCRS_Distance_Calculator::Create(const CSG_Projection &Projection, double Epsilon) { if( !m_ProjToGCS.Set_Source(Projection) || !m_ProjToGCS.Set_Target(CSG_Projection("+proj=longlat +datum=WGS84", SG_PROJ_FMT_Proj4)) || !m_Projector.Set_Target(Projection) ) { return( false ); } m_Epsilon = Epsilon; return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CCRS_Distance_Calculator::Get_Orthodrome(const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine) { static const TSG_Point P0 = { 0.0, 0.0 }; TSG_Point P = A; if( m_ProjToGCS.Get_Projection(P) ) { m_Projector.Set_Source(CSG_Projection( CSG_String::Format("+proj=aeqd +R=6371000 +lon_0=%f +lat_0=%f", P.x, P.y), SG_PROJ_FMT_Proj4) ); m_Projector.Set_Inverse(); if( m_Projector.Get_Projection(P = B) ) { m_Projector.Set_Inverse(false); Add_Segment(P0, P, pLine); return( SG_Get_Distance(P0, P) ); } } return( Get_Distance(A, B) ); } //--------------------------------------------------------- double CCRS_Distance_Calculator::Get_Loxodrome(const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine) { TSG_Point AA, BB; m_Projector.Set_Source(CSG_Projection("+proj=merc +datum=WGS84", SG_PROJ_FMT_Proj4)); m_Projector.Set_Inverse(); if( m_Projector.Get_Projection(AA = A) && m_Projector.Get_Projection(BB = B) ) { double Length = 0.0; m_Projector.Set_Inverse(false); Add_Segment(AA, BB, pLine, &Length); return( Length ); } return( Get_Distance(A, B) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CCRS_Distance_Calculator::Get_Distance(TSG_Point A, TSG_Point B) { if( m_ProjToGCS.Get_Projection(A) && m_ProjToGCS.Get_Projection(B) ) { return( SG_Get_Distance_Polar(A, B) ); } return( 0.0 ); } //--------------------------------------------------------- void CCRS_Distance_Calculator::Add_Segment(const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine, double *Length) { if( SG_Get_Distance(A, B) >= m_Epsilon ) { TSG_Point C, CC; C.x = CC.x = A.x + 0.5 * (B.x - A.x); C.y = CC.y = A.y + 0.5 * (B.y - A.y); if( m_Projector.Get_Projection(CC) ) { Add_Segment(A, C, pLine); pLine->Add_Point(CC); Add_Segment(C, B, pLine); } } else if( Length != NULL ) { TSG_Point AA, BB; if( m_Projector.Get_Projection(AA = A) && m_Projector.Get_Projection(BB = B) ) { *Length += Get_Distance(AA, BB); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Distance_Lines::CCRS_Distance_Lines(void) { //----------------------------------------------------- Set_Name (_TL("Geographic Distances")); Set_Author ("O. Conrad (c) 2015"); Set_Description (_TW( "Calculates for all segments of the input lines the planar, great elliptic, " "and loxodrome distance and re-projects the latter two to the projection " "of the input lines. " )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "PLANAR" , _TL("Segments"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "ORTHODROME" , _TL("Great Elliptic"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "LOXODROME" , _TL("Loxodrome"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Epsilon"), _TL("defines the maximum resolution [km] for the re-projected distance segments"), PARAMETER_TYPE_Double, 100.0, 1.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Distance_Lines::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPlanars = Parameters("PLANAR" )->asShapes(); CSG_Shapes *pOrthodromes = Parameters("ORTHODROME")->asShapes(); CSG_Shapes *pLoxodromes = Parameters("LOXODROME" )->asShapes(); //----------------------------------------------------- CCRS_Distance_Calculator Distance; if( !Distance.Create(pPlanars->Get_Projection(), Parameters("EPSILON")->asDouble() * 1000.0) ) { Error_Set(_TL("projection initialization failed")); return( false ); } //----------------------------------------------------- pOrthodromes->Create(pPlanars->Get_Type(), CSG_String::Format("%s [%s]", pPlanars->Get_Name(), _TL("Orthodromes")), pPlanars); pOrthodromes->Add_Field("LENGTH_PLAN", SG_DATATYPE_Double); pOrthodromes->Add_Field("LENGTH" , SG_DATATYPE_Double); pLoxodromes ->Create(pPlanars->Get_Type(), CSG_String::Format("%s [%s]", pPlanars->Get_Name(), _TL("Loxodromes" )), pPlanars); pLoxodromes ->Add_Field("LENGTH_PLAN", SG_DATATYPE_Double); pLoxodromes ->Add_Field("LENGTH" , SG_DATATYPE_Double); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pPlanars->Get_Count()); iShape++) { CSG_Shape_Line *pProj = (CSG_Shape_Line *)pPlanars->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pProj->Get_Point_Count(iPart) > 1 ) { TSG_Point A, B = pProj->Get_Point(0, iPart); CSG_Shape_Line *pOrthodrome = (CSG_Shape_Line *)pOrthodromes->Add_Shape(pProj, SHAPE_COPY_ATTR); CSG_Shape_Line *pLoxodrome = (CSG_Shape_Line *)pLoxodromes->Add_Shape(pProj, SHAPE_COPY_ATTR); pOrthodrome->Set_Value(pPlanars->Get_Field_Count() + 0, pProj->Get_Length(iPart)); pLoxodrome ->Set_Value(pPlanars->Get_Field_Count() + 0, pProj->Get_Length(iPart)); pOrthodrome->Add_Point(B); pLoxodrome ->Add_Point(B); double dOrthodrome = 0.0; double dLoxodrome = 0.0; for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { A = B; B = pProj->Get_Point(iPoint, iPart); dOrthodrome += Distance.Get_Orthodrome(A, B, pOrthodrome); dLoxodrome += Distance.Get_Loxodrome (A, B, pLoxodrome ); pOrthodrome->Add_Point(B); pLoxodrome ->Add_Point(B); } pOrthodrome->Set_Value(pPlanars->Get_Field_Count() + 1, dOrthodrome); pLoxodrome ->Set_Value(pPlanars->Get_Field_Count() + 1, dLoxodrome ); } } } //----------------------------------------------------- return( pOrthodromes->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Distance_Points::CCRS_Distance_Points(void) { Set_Name (_TL("Geographic Distances (Pair of Coordinates)")); Set_Author ("O. Conrad (c) 2015"); Set_Description (_TW( "Calculates for all segments of the input lines the planar, great elliptic, " "and loxodrome distance and re-projects the latter two to the projection " "of the input lines. " )); Parameters.Add_Shapes( NULL , "DISTANCES" , _TL("Geographic Distances"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); CSG_Parameter *pNode; pNode = Parameters.Add_Node(NULL, "NODE_A", _TL("From"), _TL("")); Parameters.Add_Value(pNode, "COORD_X1", _TL("X"), _TL(""), PARAMETER_TYPE_Double, 10.0); Parameters.Add_Value(pNode, "COORD_Y1", _TL("Y"), _TL(""), PARAMETER_TYPE_Double, 53.5); pNode = Parameters.Add_Node(NULL, "NODE_B", _TL("To" ), _TL("")); Parameters.Add_Value(pNode, "COORD_X2", _TL("X"), _TL(""), PARAMETER_TYPE_Double, 116.5); Parameters.Add_Value(pNode, "COORD_Y2", _TL("Y"), _TL(""), PARAMETER_TYPE_Double, 6.4); Parameters.Add_Value( NULL , "EPSILON" , _TL("Epsilon"), _TL("defines the maximum resolution [km] for the re-projected distance segments"), PARAMETER_TYPE_Double, 100.0, 1.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Distance_Points::On_Execute(void) { //----------------------------------------------------- CSG_Projection Projection; if( !Get_Projection(Projection) ) { return( false ); } //----------------------------------------------------- CCRS_Distance_Calculator Distance; if( !Distance.Create(Projection, Parameters("EPSILON")->asDouble() * 1000.0) ) { Error_Set(_TL("projection initialization failed")); return( false ); } //----------------------------------------------------- TSG_Point A, B; A.x = Parameters("COORD_X1")->asDouble(); A.y = Parameters("COORD_Y1")->asDouble(); B.x = Parameters("COORD_X2")->asDouble(); B.y = Parameters("COORD_Y2")->asDouble(); //----------------------------------------------------- CSG_Shapes *pDistances = Parameters("DISTANCES")->asShapes(); pDistances ->Create(SHAPE_TYPE_Line, CSG_String::Format("%s", _TL("Geographic Distances"))); pDistances ->Add_Field("TYPE" , SG_DATATYPE_String); pDistances ->Add_Field("LENGTH", SG_DATATYPE_Double); pDistances ->Get_Projection().Create(Projection); //----------------------------------------------------- CSG_Shape *pPlanar = pDistances->Add_Shape(); pPlanar ->Set_Value(0, "Planar" ); CSG_Shape *pOrthodrome = pDistances->Add_Shape(); pOrthodrome->Set_Value(0, "Orthodrome"); CSG_Shape *pLoxodrome = pDistances->Add_Shape(); pLoxodrome ->Set_Value(0, "Loxodrome" ); pPlanar ->Add_Point(A); pOrthodrome->Add_Point(A); pLoxodrome ->Add_Point(A); pPlanar ->Set_Value(1, SG_Get_Distance (A, B )); pOrthodrome->Set_Value(1, Distance.Get_Orthodrome(A, B, pOrthodrome)); pLoxodrome ->Set_Value(1, Distance.Get_Loxodrome (A, B, pLoxodrome )); pPlanar ->Add_Point(B); pOrthodrome->Add_Point(B); pLoxodrome ->Add_Point(B); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Distance_Interactive::CCRS_Distance_Interactive(void) { Set_Name (_TL("Geographic Distances")); Set_Author ("O. Conrad (c) 2015"); Set_Description (_TW( "Calculates for all segments of the input lines the planar, great elliptic, " "and loxodrome distance and re-projects the latter two to the projection " "of the input lines. " )); Parameters.Add_Shapes( NULL , "DISTANCES" , _TL("Geographic Distances"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Value( NULL , "EPSILON" , _TL("Epsilon"), _TL("defines the maximum resolution [km] for the re-projected distance segments"), PARAMETER_TYPE_Double, 100.0, 1.0, true ); Set_Drag_Mode(MODULE_INTERACTIVE_DRAG_LINE); } //--------------------------------------------------------- bool CCRS_Distance_Interactive::On_Execute(void) { CCRS_Picker CRS; if( !Dlg_Parameters(CRS.Get_Parameters(), CRS.Get_Name()) ) { m_Projection.Destroy(); return( false ); } return( m_Projection.Create(CRS.Get_Parameters()->Get_Parameter("CRS_PROJ4")->asString(), SG_PROJ_FMT_Proj4) ); } //--------------------------------------------------------- bool CCRS_Distance_Interactive::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { if( Mode == MODULE_INTERACTIVE_LDOWN ) { m_Down = ptWorld; } else if( Mode == MODULE_INTERACTIVE_LUP ) { if( m_Down != ptWorld ) { CCRS_Distance_Points Distance; Distance.Set_Parameter("DISTANCES", Parameters("DISTANCES")->asShapes()); Distance.Set_Parameter("EPSILON" , Parameters("EPSILON" )->asDouble()); Distance.Set_Parameter("CRS_PROJ4", m_Projection.Get_Proj4()); Distance.Set_Parameter("COORD_X1" , m_Down .Get_X()); Distance.Set_Parameter("COORD_Y1" , m_Down .Get_Y()); Distance.Set_Parameter("COORD_X2" , ptWorld.Get_X()); Distance.Set_Parameter("COORD_Y2" , ptWorld.Get_Y()); Distance.Execute(); DataObject_Update(Parameters("DISTANCES")->asShapes()); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/MLB_Interface.h0000744000175000017500000000760712737416201024507 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pj_proj4_H #define HEADER_INCLUDED__pj_proj4_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef pj_proj4_EXPORTS #define pj_proj4_EXPORT _SAGA_DLL_EXPORT #else #define pj_proj4_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pj_proj4_H saga-2.3.1/src/modules/projection/pj_proj4/crs_distance.h0000744000175000017500000001370212737416201024547 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: crs_distance.h 2148 2014-06-10 12:59:52Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_distance.h // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__crs_distance_H #define HEADER_INCLUDED__crs_distance_H //--------------------------------------------------------- #include "crs_base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Distance_Calculator { public: CCRS_Distance_Calculator(void); CCRS_Distance_Calculator(const CSG_Projection &Projection, double Epsilon); virtual ~CCRS_Distance_Calculator(void); bool Create (const CSG_Projection &Projection, double Epsilon); double Get_Orthodrome (const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine); double Get_Loxodrome (const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine); private: double m_Epsilon; CSG_CRSProjector m_Projector, m_ProjToGCS; double Get_Distance (TSG_Point A, TSG_Point B); void Add_Segment (const TSG_Point &A, const TSG_Point &B, CSG_Shape *pLine, double *Length = NULL); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Distance_Lines : public CSG_Module { public: CCRS_Distance_Lines(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Distance_Points : public CCRS_Base { public: CCRS_Distance_Points(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCRS_Distance_Interactive : public CSG_Module_Interactive { public: CCRS_Distance_Interactive(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CSG_Point m_Down; CSG_Projection m_Projection; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__crs_distance_H saga-2.3.1/src/modules/projection/pj_proj4/PROJ4_Base.cpp0000744000175000017500000006674712737416201024252 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // PROJ4_Base.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "PROJ4_Base.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define PRM_ADD_BOL(key, name, val) pParms->Add_Value(NULL, key, name, _TL(""), PARAMETER_TYPE_Bool , val); #define PRM_ADD_INT(key, name, val) pParms->Add_Value(NULL, key, name, _TL(""), PARAMETER_TYPE_Int , val); #define PRM_ADD_FLT(key, name, val) pParms->Add_Value(NULL, key, name, _TL(""), PARAMETER_TYPE_Double, val); //--------------------------------------------------------- #define STR_ADD_BOL(key, val) (val ? CSG_String::Format(SG_T("+%s "), key) : SG_T("")) #define STR_ADD_INT(key, val) CSG_String::Format(SG_T("+%s=%d "), key, val) #define STR_ADD_FLT(key, val) CSG_String::Format(SG_T("+%s=%f "), key, val) #define STR_ADD_STR(key, val) CSG_String::Format(SG_T("+%s=%s "), key, val) //--------------------------------------------------------- #define BESSEL_A 6377397.16 #define BESSEL_B 6356078.76 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPROJ4_Base::CPROJ4_Base(int Interface, bool bInputList) { CSG_Parameter *pNode; m_Interface = Interface; m_bInputList = bInputList; //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "SOURCE_NODE" , _TL("Source Parameters"), _TL("") ); pNode = Parameters.Add_Node( NULL , "TARGET_NODE" , _TL("Target Parameters"), _TL("") ); pNode = Parameters.Add_Node( NULL , "GENERAL_NODE", _TL("General Settings"), _TL("") ); //----------------------------------------------------- switch( m_Interface ) { //----------------------------------------------------- case PROJ4_INTERFACE_SIMPLE: default: Parameters.Add_String( Parameters("SOURCE_NODE") , "SOURCE_PROJ" , _TL("Source Projection Parameters"), _TL(""), SG_T("+proj=tmerc +datum=potsdam +lon_0=9 +x_0=3500000") ); Parameters.Add_String( Parameters("TARGET_NODE") , "TARGET_PROJ" , _TL("Target Projection Parameters"), _TL(""), SG_T("+proj=tmerc +datum=potsdam +lon_0=12 +x_0=4500000") ); break; //----------------------------------------------------- case PROJ4_INTERFACE_DIALOG: pNode = Parameters.Add_Parameters( Parameters("SOURCE_NODE") , "SOURCE_PROJ" , _TL("Source Projection Parameters"), _TL("") ); _Init_Projection(*pNode->asParameters()); pNode = Parameters.Add_Parameters( Parameters("TARGET_NODE") , "TARGET_PROJ" , _TL("Target Projection Parameters"), _TL("") ); _Init_Projection(*pNode->asParameters()); break; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPROJ4_Base::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !m_bInputList && m_Interface == PROJ4_INTERFACE_SIMPLE && !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("SOURCE")) && pParameter->asDataObject() && pParameter->asDataObject()->Get_Projection().Get_Proj4().Length() > 0 ) { pParameters->Get_Parameter("SOURCE_PROJ")->Set_Value(pParameter->asDataObject()->Get_Projection().Get_Proj4()); } return( 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Base::On_Execute(void) { bool bResult = false; CSG_String sSrc, sDst; //----------------------------------------------------- if( _Get_Projections(sSrc, sDst) ) { if( (m_pPrjSrc = pj_init_plus(sSrc.b_str())) == NULL ) { Error_Set(CSG_String::Format(SG_T("%s:\n%s"), _TL("projection initialization failure"), SG_STR_MBTOSG(pj_strerrno(pj_errno)))); } if( (m_pPrjDst = pj_init_plus(sDst.b_str())) == NULL ) { Error_Set(CSG_String::Format(SG_T("%s:\n%s"), _TL("projection initialization failure"), SG_STR_MBTOSG(pj_strerrno(pj_errno)))); } Message_Add(CSG_String::Format(SG_T("\n%s: %s\n"), _TL("Source"), sSrc.c_str()), false); Message_Add(CSG_String::Format(SG_T("\n%s: %s\n"), _TL("Target"), sDst.c_str()), false); //------------------------------------------------- if( m_pPrjSrc && m_pPrjDst ) { if( m_pPrjSrc->inv == NULL ) { Error_Set(_TL("Inverse transformation not available for selected projection type.")); } else { m_bInverse = false; bResult = On_Execute_Conversion(); } } //------------------------------------------------- if( m_pPrjSrc ) { pj_free(m_pPrjSrc); } if( m_pPrjDst ) { pj_free(m_pPrjDst); } } //----------------------------------------------------- return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Base::Set_Inverse(bool bOn) { if( m_bInverse == bOn ) { return( true ); } if( m_pPrjDst && m_pPrjDst->inv ) { m_bInverse = bOn; PJ *tmp = m_pPrjSrc; m_pPrjSrc = m_pPrjDst; m_pPrjDst = tmp; return( true ); } Error_Set(_TL("Inverse transformation not available for selected projection type.")); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CPROJ4_Base::Get_Proj_Name(bool bDestination) { PJ *pProjection = bDestination ? m_pPrjDst : m_pPrjSrc; if( pProjection ) { return( CSG_String(pProjection->descr).BeforeFirst('\n') ); } return( _TL("") ); } //--------------------------------------------------------- bool CPROJ4_Base::Get_Converted(TSG_Point &Point) { return( Get_Converted(Point.x, Point.y) ); } bool CPROJ4_Base::Get_Converted(double &x, double &y) { if( m_pPrjSrc && m_pPrjDst ) { double z = 0.0; if( pj_is_latlong(m_pPrjSrc) ) { x *= DEG_TO_RAD; y *= DEG_TO_RAD; } if( pj_transform(m_pPrjSrc, m_pPrjDst, 1, 0, &x, &y, &z) == 0 ) { if( pj_is_latlong(m_pPrjDst) ) { x *= RAD_TO_DEG; y *= RAD_TO_DEG; } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Base::_Get_Projections(CSG_String &sPrjSrc, CSG_String &sPrjDst) { switch( m_Interface ) { //----------------------------------------------------- case PROJ4_INTERFACE_SIMPLE: default: sPrjSrc = Parameters("SOURCE_PROJ")->asString(); sPrjDst = Parameters("TARGET_PROJ")->asString(); return( true ); //----------------------------------------------------- case PROJ4_INTERFACE_DIALOG: return( _Get_Projection(sPrjSrc, *Parameters("SOURCE_PROJ")->asParameters()), _Get_Projection(sPrjDst, *Parameters("TARGET_PROJ")->asParameters()) ); } } //--------------------------------------------------------- bool CPROJ4_Base::_Get_Projection(CSG_String &sPrj, CSG_Parameters &P) { //----------------------------------------------------- sPrj .Clear(); sPrj += STR_ADD_STR(SG_T("proj") , SG_STR_MBTOSG(pj_list[P("PROJ_TYPE")->asInt()].id)); if( P("LON_0")->asDouble() ) sPrj += STR_ADD_FLT(SG_T("lon_0") , P("LON_0")->asDouble()); if( P("LAT_0")->asDouble() ) sPrj += STR_ADD_FLT(SG_T("lat_0") , P("LAT_0")->asDouble()); if( P("X_0" )->asDouble() ) sPrj += STR_ADD_FLT(SG_T("x_0") , P("X_0" )->asDouble()); if( P("Y_0" )->asDouble() ) sPrj += STR_ADD_FLT(SG_T("y_0") , P("Y_0" )->asDouble()); if( P("K_0")->asDouble() != 1.0 && P("K_0")->asDouble() > 0.0 ) { sPrj += STR_ADD_FLT(SG_T("k_0") , P("K_0" )->asDouble()); } sPrj += STR_ADD_STR(SG_T("units") , SG_STR_MBTOSG(pj_units[P("UNIT")->asInt()].id)); //----------------------------------------------------- switch( P("DATUM_DEF")->asInt() ) { case 0: // predefined datum sPrj += STR_ADD_STR(SG_T("datum") , SG_STR_MBTOSG(pj_datums[P("DATUM")->asInt()].id)); break; //----------------------------------------------------- case 1: // user defined datum switch( P("ELLIPSOID")->asInt() ) { case 0: // Predefined Ellipsoid sPrj += STR_ADD_STR(SG_T("ellps") , SG_STR_MBTOSG(pj_ellps[P("ELLPS_PREDEF")->asInt()].id)); break; case 1: // Semiminor axis sPrj += STR_ADD_FLT(SG_T("a") , P("ELLPS_A" )->asDouble()); sPrj += STR_ADD_FLT(SG_T("b") , P("ELLPS_B" )->asDouble()); break; case 2: // Flattening sPrj += STR_ADD_FLT(SG_T("a") , P("ELLPS_A" )->asDouble()); sPrj += STR_ADD_FLT(SG_T("f") , P("ELLPS_F" )->asDouble()); break; case 3: // Reciprocal Flattening sPrj += STR_ADD_FLT(SG_T("a") , P("ELLPS_A" )->asDouble()); sPrj += STR_ADD_FLT(SG_T("rf") , P("ELLPS_RF")->asDouble()); break; case 4: // Eccentricity sPrj += STR_ADD_FLT(SG_T("a") , P("ELLPS_A" )->asDouble()); sPrj += STR_ADD_FLT(SG_T("e") , P("ELLPS_E" )->asDouble()); break; case 5: // Eccentricity Squared sPrj += STR_ADD_FLT(SG_T("a") , P("ELLPS_A" )->asDouble()); sPrj += STR_ADD_FLT(SG_T("es") , P("ELLPS_ES")->asDouble()); break; } switch( P("DATUM_SHIFT")->asInt() ) { case 1: // 3 parameters sPrj += CSG_String::Format(SG_T("+towgs84=%f,%f,%f "), P("DS_DX")->asDouble(), P("DS_DY")->asDouble(), P("DS_DZ")->asDouble() ); break; case 2: // 7 parameters sPrj += CSG_String::Format(SG_T("+towgs84=%f,%f,%f,%f,%f,%f,%f "), P("DS_DX")->asDouble(), P("DS_DY")->asDouble(), P("DS_DZ")->asDouble(), P("DS_RX")->asDouble(), P("DS_RY")->asDouble(), P("DS_RZ")->asDouble(), P("DS_SC")->asDouble() ); break; } break; } // datum shift grid... if( SG_File_Exists(P("DATUM_GRID")->asString()) ) { sPrj += STR_ADD_STR(SG_T("nadgrids"), P("DATUM_GRID")->asString()); } //----------------------------------------------------- CSG_Parameters *pParms = Get_Parameters(SG_STR_MBTOSG(pj_list[P("PROJ_TYPE")->asInt()].id)); if( pParms == NULL || pParms->Get_Count() <= 0 ) { return( true ); } if( Dlg_Parameters(SG_STR_MBTOSG(pj_list[P("PROJ_TYPE")->asInt()].id)) ) { for(int i=0; iGet_Count(); i++) { CSG_Parameter *p = pParms->Get_Parameter(i); switch( p->Get_Type() ) { case PARAMETER_TYPE_Bool: sPrj += STR_ADD_BOL(p->Get_Identifier(), p->asBool()); break; case PARAMETER_TYPE_Int: sPrj += STR_ADD_INT(p->Get_Identifier(), p->asInt()); break; case PARAMETER_TYPE_Double: sPrj += STR_ADD_FLT(p->Get_Identifier(), p->asDouble()); break; } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // Initializations // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Base::_Init_Projection(CSG_Parameters &P) { CSG_String sList, sName, sDesc, sArgs; CSG_Parameter *pNode_0, *pNode_1, *pNode_2, *pNode_3; pNode_0 = NULL; //----------------------------------------------------- // Projections... sDesc = _TL("Available Projections:"); sList.Clear(); for(struct PJ_LIST *pProjection=pj_list; pProjection->id; ++pProjection) { sArgs = *pProjection->descr; sName = sArgs.BeforeFirst('\n'); sArgs = sArgs.AfterFirst ('\n').AfterFirst('\n').AfterFirst('\t'); sList += CSG_String::Format(SG_T("%s|"), sName.c_str()); sDesc += CSG_String::Format(SG_T("\n[%s] %s (%s)"), SG_STR_MBTOSG(pProjection->id), sName.c_str(), sArgs.c_str()); _Init_Projection(pProjection->id, sName, sArgs); } if( sList.Length() > 0 ) { P.Add_Choice(NULL, "PROJ_TYPE", _TL("Projection Type"), sDesc, sList); } //----------------------------------------------------- // Datums... pNode_1 = P.Add_Choice( pNode_0, "DATUM_DEF" , _TL("Datum Definition"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Predefined Datum"), _TL("User Defined Datum") ) ); //----------------------------------------------------- // Predefined datum... sList.Clear(); for(struct PJ_DATUMS *pDatum=pj_datums; pDatum->id; ++pDatum) { sList += CSG_String::Format(SG_T("[%s]"), SG_STR_MBTOSG(pDatum->id)); if( SG_STR_MBTOSG(pDatum->comments) != NULL && SG_STR_MBTOSG(*pDatum->comments) != NULL ) { sList += CSG_String::Format(SG_T(" %s"), SG_STR_MBTOSG(pDatum->comments)); } sList += '|'; } if( sList.Length() > 0 ) { pNode_2 = P.Add_Choice(pNode_1, "DATUM", _TL("Predefined Datum"), _TL(""), sList); } //----------------------------------------------------- // Datum shift grid(s)... P.Add_FilePath( pNode_1, "DATUM_GRID" , _TL("Datum Shift Grid File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("NTv2 Grid Shift Binary (*.gsb)") , SG_T("*.gsb"), _TL("All Files") , SG_T("*.*") ), NULL, false, false, false ); //----------------------------------------------------- // User defined ellipsoid and datum shift... pNode_2 = P.Add_Node( pNode_1, "NODE_USER_DATUM" , _TL("User Defined Datum"), _TL("") ); //----------------------------------------------------- pNode_3 = P.Add_Choice( pNode_2, "ELLIPSOID" , _TL("Ellipsoid Definition"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("Predefined Standard Ellipsoids"), _TL("Semimajor Axis and Semiminor Axis"), _TL("Semimajor Axis and Flattening"), _TL("Semimajor Axis and Reciprocal Flattening"), _TL("Semimajor Axis and Eccentricity"), _TL("Semimajor Axis and Eccentricity Squared") ) ); //----------------------------------------------------- sList.Clear(); for(struct PJ_ELLPS *pEllipse=pj_ellps; pEllipse->id; ++pEllipse) { sList += CSG_String::Format(SG_T("[%s] %s (%s, %s)|"), SG_STR_MBTOSG(pEllipse->id), SG_STR_MBTOSG(pEllipse->name), SG_STR_MBTOSG(pEllipse->major), SG_STR_MBTOSG(pEllipse->ell)); } if( sList.Length() > 0 ) { P.Add_Choice(pNode_3, "ELLPS_PREDEF", _TL("Predefined Standard Ellipsoids"), _TL(""), sList); } //----------------------------------------------------- P.Add_Value( pNode_3, "ELLPS_A" , _TL("Semimajor Axis (a)"), _TL("Semimajor axis or equatorial radius."), PARAMETER_TYPE_Double , BESSEL_A ); P.Add_Value( pNode_3, "ELLPS_B" , _TL("Semiminor Axis (b)"), _TL("Semiminor axis or polar radius."), PARAMETER_TYPE_Double , BESSEL_B ); P.Add_Value( pNode_3, "ELLPS_F" , _TL("Flattening (f)"), _TL(""), PARAMETER_TYPE_Double , (BESSEL_A - BESSEL_B) / BESSEL_A ); P.Add_Value( pNode_3, "ELLPS_RF" , _TL("Reciprocal Flattening (rf)"), _TL(""), PARAMETER_TYPE_Double , BESSEL_A / (BESSEL_A - BESSEL_B) ); P.Add_Value( pNode_3, "ELLPS_E" , _TL("Eccentricity (e)"), _TL(""), PARAMETER_TYPE_Double , sqrt(BESSEL_A*BESSEL_A + BESSEL_B*BESSEL_B) ); P.Add_Value( pNode_3, "ELLPS_ES" , _TL("Squared Eccentricity (es)"), _TL(""), PARAMETER_TYPE_Double , BESSEL_A*BESSEL_A + BESSEL_B*BESSEL_B ); //----------------------------------------------------- pNode_3 = P.Add_Choice( pNode_2, "DATUM_SHIFT" , _TL("Datum Shift"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("none"), _TL("3 parameters (translation only)"), _TL("7 parameters"), _TL("Datum Shift Grid") ) ); P.Add_Value( pNode_3, "DS_DX" , _TL("Translation X"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_DY" , _TL("Translation Y"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_DZ" , _TL("Translation Z"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_RX" , _TL("Rotation X"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_RY" , _TL("Rotation Y"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_RZ" , _TL("Rotation Z"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); P.Add_Value( pNode_3, "DS_SC" , _TL("Scaling"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); //----------------------------------------------------- // General Settings... pNode_1 = P.Add_Node( pNode_0, "NODE_GENERAL" , _TL("General Settings"), _TL("") ); //----------------------------------------------------- P.Add_Value( pNode_1, "LON_0" , _TL("Central Meridian"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); P.Add_Value( pNode_1, "LAT_0" , _TL("Central Parallel"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); P.Add_Value( pNode_1, "X_0" , _TL("False Easting"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); P.Add_Value( pNode_1, "Y_0" , _TL("False Northing"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); P.Add_Value( pNode_1, "K_0" , _TL("Scale Factor"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); //----------------------------------------------------- sList.Clear(); for(struct PJ_UNITS *pUnit=pj_units; pUnit->id; ++pUnit) { sList += CSG_String::Format(SG_T("%s (%s)|"), SG_STR_MBTOSG(pUnit->name), SG_STR_MBTOSG(pUnit->to_meter)); } if( sList.Length() > 0 ) { P.Add_Choice(pNode_1, "UNIT", _TL("Unit"), _TL(""), sList, 1); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPROJ4_Base::_Init_Projection(const CSG_String &sID, const CSG_String &sName, const CSG_String &sArgs) { if( sArgs.Length() == 0 ) { return( false ); } CSG_Parameters *pParms = Add_Parameters(sID, sName, sArgs); //----------------------------------------------------- // Cylindrical Projections... if( !sID.CmpNoCase(SG_T("cea")) // Equal Area Cylindrical || !sID.CmpNoCase(SG_T("eqc")) // Equidistant Cylindrical (Plate Caree) || !sID.CmpNoCase(SG_T("merc")) ) // Mercator { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 0.0); } if( !sID.CmpNoCase(SG_T("utm")) ) // Universal Transverse Mercator (UTM) { PRM_ADD_INT("zone" , _TL("Zone") , 32); PRM_ADD_BOL("south" , _TL("South") , false); } if( !sID.CmpNoCase(SG_T("omerc")) ) // Oblique Mercator { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1" ) ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 50.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2" ) , 20.0); } //----------------------------------------------------- // Pseudocylindrical Projections... if( !sID.CmpNoCase(SG_T("gn_sinu")) ) // General Sinusoidal Series { PRM_ADD_FLT("m" , SG_T("m") , 0.5); PRM_ADD_FLT("n" , SG_T("n") , 1.0 + M_PI_045); } if( !sID.CmpNoCase(SG_T("loxim")) ) // Loximuthal { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } if( !sID.CmpNoCase(SG_T("urmfps")) ) // Urmaev Flat-Polar Sinusoidal { PRM_ADD_FLT("n" , SG_T("n") , 1.0); } if( !sID.CmpNoCase(SG_T("urm5")) ) // Urmaev V { PRM_ADD_FLT("n" , SG_T("n") , 1.0); PRM_ADD_FLT("q" , SG_T("q") , 1.0); PRM_ADD_FLT("alphi" , SG_T("alphi") , 45.0); } if( !sID.CmpNoCase(SG_T("wink1")) // Winkel I || !sID.CmpNoCase(SG_T("wag3")) ) // Wagner III { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("wink2")) ) // Winkel II { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } //----------------------------------------------------- // Conic Projections... if( !sID.CmpNoCase(SG_T("aea")) // Albers Equal Area || !sID.CmpNoCase(SG_T("eqdc")) // Equidistant Conic || !sID.CmpNoCase(SG_T("euler")) // Euler || !sID.CmpNoCase(SG_T("imw_p")) // International Map of the World Polyconic || !sID.CmpNoCase(SG_T("murd1")) // Murdoch I || !sID.CmpNoCase(SG_T("murd2")) // Murdoch II || !sID.CmpNoCase(SG_T("murd3")) // Murdoch III || !sID.CmpNoCase(SG_T("pconic")) // Perspective Conic || !sID.CmpNoCase(SG_T("tissot")) // Tissot || !sID.CmpNoCase(SG_T("vitk1")) ) // Vitkovsky I { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); } if( !sID.CmpNoCase(SG_T("lcc")) ) // Lambert Conformal Conic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); } if( !sID.CmpNoCase(SG_T("leac")) ) // Lambert Equal Area Conic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 45.0); PRM_ADD_BOL("south" , _TL("South") , false); } if( !sID.CmpNoCase(SG_T("rpoly")) ) // Rectangular Polyconic { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("mpoly")) ) // Modified Polyconic { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 33.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 45.0); PRM_ADD_BOL("lotsa" , _TL("Lotsa") , true); } if( !sID.CmpNoCase(SG_T("bonne")) ) // Bonne { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 45.0); } //----------------------------------------------------- // Azimuthal Projections... if( !sID.CmpNoCase(SG_T("stere")) ) // Stereographic { PRM_ADD_FLT("lat_ts" , _TL("True Scale Latitude") , 45.0); } if( !sID.CmpNoCase(SG_T("ups")) ) // Universal Polar Stereographic { PRM_ADD_BOL("south" , _TL("South") , true); } if( !sID.CmpNoCase(SG_T("airy")) ) // Airy { PRM_ADD_FLT("lat_b" , _TL("Latitude B") , 45.0); PRM_ADD_BOL("no_cut" , _TL("No Cut") , true); } if( !sID.CmpNoCase(SG_T("nsper")) ) // Near-sided perspective { PRM_ADD_FLT("h" , _TL("Height of view point") , 1.0); } if( !sID.CmpNoCase(SG_T("aeqd")) ) // Azimuthal Equidistant { PRM_ADD_BOL("guam" , _TL("guam") , true); } if( !sID.CmpNoCase(SG_T("hammer")) ) // Hammer & Eckert-Greifendorff { PRM_ADD_FLT("W" , _TL("W") , 0.5); PRM_ADD_FLT("M" , _TL("M") , 1.0); } if( !sID.CmpNoCase(SG_T("wintri")) ) // Winkel Tripel { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); } //----------------------------------------------------- // Miscellaneous Projections... if( !sID.CmpNoCase(SG_T("ocea")) // Oblique Cylindrical Equal Area || !sID.CmpNoCase(SG_T("tpeqd")) ) // Two Point Equidistant { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 40.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1") ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 50.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2" ) , 20.0); } if( !sID.CmpNoCase(SG_T("lsat")) ) // Space oblique for LANDSAT { PRM_ADD_INT("lsat" , _TL("Landsat") , 1.0); PRM_ADD_INT("path" , _TL("Path") , 1.0); } if( !sID.CmpNoCase(SG_T("labrd")) ) // Laborde { PRM_ADD_FLT("azi" , _TL("Azimuth" ) , 19.0); } if( !sID.CmpNoCase(SG_T("lagrng")) ) // Lagrange { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 0.0); PRM_ADD_FLT("W" , _TL("W") , 2.0); } if( !sID.CmpNoCase(SG_T("chamb")) ) // Chamberlin Trimetric { PRM_ADD_FLT("lat_1" , _TL("Latitude 1") , 30.0); PRM_ADD_FLT("lon_1" , _TL("Longitude 1" ) ,-20.0); PRM_ADD_FLT("lat_2" , _TL("Latitude 2") , 40.0); PRM_ADD_FLT("lon_2" , _TL("Longitude 2") , 00.0); PRM_ADD_FLT("lat_3" , _TL("Latitude 3") , 50.0); PRM_ADD_FLT("lon_3" , _TL("Longitude 3" ) , 20.0); } if( !sID.CmpNoCase(SG_T("oea")) ) // Oblated Equal Area { PRM_ADD_FLT("m" , _TL("m") , 1.0); PRM_ADD_FLT("n" , _TL("n") , 1.0); PRM_ADD_FLT("theta" , _TL("theta") , 45.0); } if( !sID.CmpNoCase(SG_T("tpers")) ) // Tilted perspective { PRM_ADD_FLT("tilt" , _TL("Tilt") , 45.0); PRM_ADD_FLT("azi" , _TL("Azimuth") , 45.0); PRM_ADD_FLT("h" , _TL("h") , 1000.0); } if( !sID.CmpNoCase(SG_T("ob_tran")) ) // General Oblique Transformation { PRM_ADD_FLT("o_lat_p" , _TL("Latitude Pole") , 40.0); PRM_ADD_FLT("o_lon_p" , _TL("Longitude Pole") , 40.0); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_proj4/MLB_Interface.cpp0000744000175000017500000001415212737416201025033 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "crs_transform.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Proj.4") ); case MLB_INFO_Category: return( _TL("Projection") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2004-14") ); case MLB_INFO_Description: return( CSG_CRSProjector::Get_Description() ); case MLB_INFO_Version: return( _TL("2.0") ); case MLB_INFO_Menu_Path: return( _TL("Projection") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "crs_assign.h" #include "crs_transform_shapes.h" #include "crs_transform_grid.h" #include "PROJ4_Shapes.h" #include "PROJ4_Grid.h" #include "gcs_lon_range.h" #include "gcs_graticule.h" #include "crs_indicatrix.h" #include "crs_grid_geogcoords.h" #include "crs_transform_pointcloud.h" #include "crs_distance.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CCRS_Assign() ); case 1: return( new CCRS_Transform_Shapes (true ) ); case 2: return( new CCRS_Transform_Shapes (false) ); case 3: return( new CCRS_Transform_Grid (true ) ); case 4: return( new CCRS_Transform_Grid (false) ); case 18: return( new CCRS_Transform_PointCloud(true ) ); case 19: return( new CCRS_Transform_PointCloud(false) ); case 15: return( new CCRS_Picker() ); case 13: return( new CGCS_Grid_Longitude_Range() ); case 14: return( new CGCS_Graticule() ); case 16: return( new CCRS_Indicatrix() ); case 17: return( new CCRS_Grid_GeogCoords() ); case 20: return( new CCRS_Distance_Lines() ); case 21: return( new CCRS_Distance_Points() ); case 22: return( new CCRS_Distance_Interactive() ); case 5: return( new CPROJ4_Shapes (PROJ4_INTERFACE_SIMPLE, false) ); case 6: return( new CPROJ4_Shapes (PROJ4_INTERFACE_DIALOG, false) ); case 7: return( new CPROJ4_Grid (PROJ4_INTERFACE_SIMPLE, false) ); case 8: return( new CPROJ4_Grid (PROJ4_INTERFACE_DIALOG, false) ); case 9: return( new CPROJ4_Shapes (PROJ4_INTERFACE_SIMPLE, true) ); case 10: return( new CPROJ4_Shapes (PROJ4_INTERFACE_DIALOG, true) ); case 11: return( new CPROJ4_Grid (PROJ4_INTERFACE_SIMPLE, true) ); case 12: return( new CPROJ4_Grid (PROJ4_INTERFACE_DIALOG, true) ); case 23: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/projection/pj_proj4/crs_transform_pointcloud.cpp0000744000175000017500000001722412737416202027567 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Projection_Proj4 // // // //-------------------------------------------------------// // // // crs_transform_pointcloud.cpp // // // // Copyright (C) 2014 by // // Volker Wichmann // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "crs_transform_pointcloud.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCRS_Transform_PointCloud::CCRS_Transform_PointCloud(bool bList) { m_bList = bList; //----------------------------------------------------- Set_Name (m_bList ? _TL("Coordinate Transformation (Point Cloud List)") : _TL("Coordinate Transformation (Point Cloud)") ); Set_Author (SG_T("V. Wichmann, O. Conrad (c) 2014")); Set_Description (_TW( "Coordinate transformation for point clouds.\n" )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- if( m_bList ) { Parameters.Add_PointCloud_List( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_PointCloud_List( NULL , "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } //----------------------------------------------------- else { Parameters.Add_PointCloud( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_PointCloud( NULL , "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_PointCloud::On_Execute_Transformation(void) { if( m_bList ) { CSG_Parameter_PointCloud_List *pSources, *pTargets; pSources = Parameters("SOURCE")->asPointCloudList(); pTargets = Parameters("TARGET")->asPointCloudList(); pTargets->Del_Items(); for(int i=0; iGet_Count() && Process_Get_Okay(false); i++) { CSG_PointCloud *pSource = pSources->asPointCloud(i); CSG_PointCloud *pTarget = SG_Create_PointCloud(pSource); pTarget->Set_Name(CSG_String::Format(SG_T("%s_transformed"), pSource->Get_Name())); if( Transform(pSource, pTarget) ) { pTargets->Add_Item(pTarget); } else { delete(pTarget); } } return( pTargets->Get_Count() > 0 ); } else { CSG_PointCloud *pSource = Parameters("SOURCE")->asPointCloud(); CSG_PointCloud *pTarget = Parameters("TARGET")->asPointCloud(); if( pSource == pTarget ) { CSG_String sName = pSource->Get_Name(); pTarget = SG_Create_PointCloud(pSource); if( Transform(pSource, pTarget) ) { pSource->Assign(pTarget); pSource->Set_Name(CSG_String::Format(SG_T("%s_transformed"), sName.c_str())); return( true ); } else { delete(pTarget); return( false ); } } else { pTarget->Create(pSource); pTarget->Set_Name(CSG_String::Format(SG_T("%s_transformed"), pSource->Get_Name())); } return( Transform(pSource, pTarget) ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCRS_Transform_PointCloud::Transform(CSG_PointCloud *pSource, CSG_PointCloud *pTarget) { if( !pTarget || !pSource || !pSource->is_Valid() ) { return( false ); } if( !m_Projector.Set_Source(pSource->Get_Projection()) ) { return( false ); } int nDropped = 0; Process_Set_Text(CSG_String::Format(SG_T("%s: %s"), _TL("Processing"), pSource->Get_Name())); for(int iPoint=0; iPointGet_Point_Count() && Set_Progress(iPoint, pSource->Get_Point_Count()); iPoint++) { TSG_Point_Z Point = pSource->Get_Point(iPoint); if( m_Projector.Get_Projection(Point.x, Point.y, Point.z) ) { pTarget->Add_Point(Point.x, Point.y, Point.z); for(int iField=0; iFieldGet_Attribute_Count(); iField++) { pTarget->Set_Attribute(iField, pSource->Get_Attribute(iPoint, iField)); } } else { nDropped++; } } if( nDropped > 0 ) { Message_Add(CSG_String::Format(SG_T("%s: %d %s"), pTarget->Get_Name(), nDropped, _TL("points have been dropped"))); } pTarget->Get_Projection() = m_Projector.Get_Target(); return( pTarget->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/Makefile.am0000744000175000017500000000004412737416176022250 0ustar00oconradoconrad00000000000000SUBDIRS = pj_georeference pj_proj4 saga-2.3.1/src/modules/projection/pj_georeference/0000775000175000017500000000000012737740006023331 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/projection/pj_georeference/Georef_Shapes.h0000744000175000017500000001047412737416176026231 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Shapes.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Georef_Shapes.h // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Georef_Shapes_H #define HEADER_INCLUDED__Georef_Shapes_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGeoref_Shapes : public CSG_Module { public: CGeoref_Shapes(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Georef_Shapes_H saga-2.3.1/src/modules/projection/pj_georeference/Georef_Shapes.cpp0000744000175000017500000001731412737416176026564 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Shapes.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Georef_Shapes.cpp // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Georef_Shapes.h" #include "Georef_Engine.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGeoref_Shapes::CGeoref_Shapes(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Warping Shapes")); Set_Author (SG_T("O.Conrad (c) 2006")); Set_Description (_TW( "Georeferencing of shapes layers. Either choose the attribute fields (x/y) " "with the projected coordinates for the reference points (origin) or supply a " "additional points layer with correspondend points in the target projection. " )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "REF_SOURCE" , _TL("Reference Points (Origin)"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "REF_TARGET" , _TL("Reference Points (Projection)"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Table_Field( pNode , "XFIELD" , _TL("x Position"), _TL("") ); Parameters.Add_Table_Field( pNode , "YFIELD" , _TL("y Position"), _TL("") ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), GEOREF_METHODS_CHOICE, 0 ); Parameters.Add_Value( NULL , "ORDER" ,_TL("Polynomial Order"), _TL(""), PARAMETER_TYPE_Int, 3, 1, true ); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL(""), PARAMETER_OUTPUT ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGeoref_Shapes::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "REF_TARGET") ) { pParameters->Get_Parameter("XFIELD")->Set_Enabled(pParameter->asShapes() == NULL); pParameters->Get_Parameter("YFIELD")->Set_Enabled(pParameter->asShapes() == NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Get_Parameter("ORDER")->Set_Enabled(pParameter->asInt() == GEOREF_Polynomial); // only show for polynomial, user defined order } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Shapes::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pShapes_A = Parameters("REF_SOURCE")->asShapes(); CSG_Shapes *pShapes_B = Parameters("REF_TARGET")->asShapes(); int xField = Parameters("XFIELD")->asInt(); int yField = Parameters("YFIELD")->asInt(); int Method = Parameters("METHOD")->asInt(); int Order = Parameters("ORDER" )->asInt(); //----------------------------------------------------- CGeoref_Engine Engine; if( (pShapes_B != NULL && Engine.Set_Reference(pShapes_A, pShapes_B ) == false) ) { return( false ); } if( (pShapes_B == NULL && Engine.Set_Reference(pShapes_A, xField, yField) == false) ) { return( false ); } if( !Engine.Evaluate(Method, Order) ) { return( false ); } //--------------------------------------------------------- pShapes_A = Parameters("INPUT" )->asShapes(); pShapes_B = Parameters("OUTPUT")->asShapes(); pShapes_B ->Create(pShapes_A->Get_Type(), pShapes_A->Get_Name(), pShapes_A); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes_A->Get_Count()); iShape++) { CSG_Shape *pShape_A = pShapes_A->Get_Shape(iShape); CSG_Shape *pShape_B = pShapes_B->Add_Shape(pShape_A, SHAPE_COPY_ATTR); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point Point = pShape_A->Get_Point(iPoint, iPart); if( Engine.Get_Converted(Point) ) { pShape_B->Add_Point(Point); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_georeference/georef_grid_move.cpp0000744000175000017500000001660212737416176027353 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: georef_grid_move.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Georeference // // // //-------------------------------------------------------// // // // Georef_Grid_Move.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "georef_grid_move.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGeoref_Grid_Move::CGeoref_Grid_Move(void) { //----------------------------------------------------- Set_Name (_TL("Move Grid")); Set_Author (SG_T("O.Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_Grid( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); //----------------------------------------------------- Set_Drag_Mode(MODULE_INTERACTIVE_DRAG_LINE); } //--------------------------------------------------------- CGeoref_Grid_Move::~CGeoref_Grid_Move(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid_Move::On_Execute(void) { m_pGrid = Parameters("SOURCE")->asGrid(); m_pSource = NULL; m_bModified = m_pGrid->is_Modified(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid_Move::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { if( Mode == MODULE_INTERACTIVE_LDOWN ) { m_Down = ptWorld; } else if( Mode == MODULE_INTERACTIVE_LUP ) { if( m_Down != ptWorld ) { if( m_pSource == NULL ) { m_pSource = new CSG_Grid(*m_pGrid); m_pSource ->Set_Name(m_pGrid->Get_Name()); m_Move = m_Down - ptWorld; } else { m_Move += m_Down - ptWorld; } //--------------------------------------------- int x, y, ix, iy, dx, dy; dx = (int)(0.5 + m_Move.Get_X() / m_pSource->Get_Cellsize()); dy = (int)(0.5 + m_Move.Get_Y() / m_pSource->Get_Cellsize()); for(y=0, iy=dy; yGet_NY() && Set_Progress(y, m_pGrid->Get_NY()); y++, iy++) { if( iy >= 0 && iy < m_pSource->Get_NY() ) { for(x=0, ix=dx; xGet_NX(); x++, ix++) { if( ix >= 0 && ix < m_pSource->Get_NX() ) { m_pGrid->Set_Value(x, y, m_pSource->asDouble(ix, iy)); } else { m_pGrid->Set_NoData(x, y); } } } else { for(x=0; xGet_NX(); x++) { m_pGrid->Set_NoData(x, y); } } } DataObject_Update(m_pGrid); } } return( true ); } //--------------------------------------------------------- bool CGeoref_Grid_Move::On_Execute_Finish(void) { if( m_pSource ) { m_pGrid->Assign(m_pSource); m_pGrid->Set_Modified(m_bModified); DataObject_Update(m_pGrid); if( m_Move.Get_X() == 0.0 && m_Move.Get_Y() == 0.0 ) { Message_Add(_TL("No translation set by user")); } else if( Message_Dlg_Confirm(_TL("Apply Move"), _TL("Move Grid")) ) { m_pGrid = new CSG_Grid(m_pSource->Get_Type(), m_pSource->Get_NX(), m_pSource->Get_NY(), m_pSource->Get_Cellsize(), m_pSource->Get_XMin() - m_Move.Get_X(), m_pSource->Get_YMin() - m_Move.Get_Y() ); m_pGrid->Set_Name (m_pSource->Get_Name()); m_pGrid->Set_Unit (m_pSource->Get_Unit()); m_pGrid->Set_Scaling(m_pSource->Get_Scaling(), m_pSource->Get_Offset()); for(int y=0; yGet_NY() && Set_Progress(y, m_pGrid->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { m_pGrid->Set_Value(x, y, m_pSource->asDouble(x, y)); } } Parameters("GRID")->Set_Value(m_pGrid); return( true ); } delete(m_pSource); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_georeference/set_grid_georeference.cpp0000744000175000017500000002320312737416176030355 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: set_grid_georeference.cpp 1834 2013-09-11 18:33:29Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // set_grid_georeference.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "set_grid_georeference.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSet_Grid_Georeference::CSet_Grid_Georeference(void) { //----------------------------------------------------- Set_Name (_TL("Define Georeference for Grids")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "This tool simply allows definition of grid's cellsize and position. " "It does not perform any kind of warping but might be helpful, if the " "grid has lost this information or is already aligned with the " "coordinate system. " )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "REFERENCED" , _TL("Referenced Grids"), _TL(""), PARAMETER_OUTPUT, false ); //----------------------------------------------------- CSG_Parameter *pNode; Parameters.Add_Choice( NULL , "DEFINITION" , _TL("Definition"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("cellsize and lower left cell coordinates"), _TL("cellsize and upper left cell coordinates"), _TL("lower left cell coordinates and left to right range"), _TL("lower left cell coordinates and lower to upper range") ), 0 ); pNode = Parameters.Add_Grid_System( NULL , "SYSTEM" , _TL("Grid System"), _TL("") ); Parameters.Add_Double(pNode, "SIZE", _TL("Cellsize"), _TL(""), 1.0, 0.0, true); Parameters.Add_Double(pNode, "XMIN", _TL("Left" ), _TL("")); Parameters.Add_Double(pNode, "XMAX", _TL("Right" ), _TL("")); Parameters.Add_Double(pNode, "YMIN", _TL("Lower" ), _TL("")); Parameters.Add_Double(pNode, "YMAX", _TL("Upper" ), _TL("")); Parameters.Add_Choice( pNode , "CELL_REF" , _TL("Cell Reference"), _TL(""), CSG_String::Format("%s|%s|", _TL("center"), _TL("corner") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSet_Grid_Georeference::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( CSG_Module_Grid::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CSet_Grid_Georeference::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CSG_Grid_System System = *pParameters->Get_Parameter("SYSTEM")->asGrid_System(); if( System.is_Valid() ) { pParameters->Set_Enabled("SIZE" , false); pParameters->Set_Enabled("XMIN" , false); pParameters->Set_Enabled("YMIN" , false); pParameters->Set_Enabled("XMAX" , false); pParameters->Set_Enabled("YMAX" , false); pParameters->Set_Enabled("CELL_REF", false); } else { int Definition = pParameters->Get_Parameter("DEFINITION")->asInt(); pParameters->Set_Enabled("SIZE" , Definition < 2); pParameters->Set_Enabled("XMIN" , true); pParameters->Set_Enabled("YMIN" , Definition == 0 || Definition >= 2); pParameters->Set_Enabled("XMAX" , Definition == 2); pParameters->Set_Enabled("YMAX" , Definition == 1 || Definition == 3); pParameters->Set_Enabled("CELL_REF", true); } return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSet_Grid_Georeference::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); if( pGrids->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- CSG_Grid_System System = *Parameters("SYSTEM")->asGrid_System(); double size = System.is_Valid() ? System.Get_Cellsize() : Parameters("SIZE")->asDouble(); double xMin = System.is_Valid() ? System.Get_XMin () : Parameters("XMIN")->asDouble(); double yMin = System.is_Valid() ? System.Get_YMin () : Parameters("YMIN")->asDouble(); double xMax = System.is_Valid() ? System.Get_XMax () : Parameters("XMAX")->asDouble(); double yMax = System.is_Valid() ? System.Get_YMax () : Parameters("YMAX")->asDouble(); if( !System.is_Valid() && Parameters("CELL_REF")->asInt() == 1 ) // corner to center coordinates { xMin += 0.5 * size; yMin += 0.5 * size; xMax -= 0.5 * size; yMax -= 0.5 * size; } //----------------------------------------------------- switch( Parameters("DEFINITION")->asInt() ) { case 0: // cellsize and lower left cell coordinates break; case 1: // cellsize and upper left cell coordinates yMin = yMax - size * Get_NY(); break; case 2: // lower left cell coordinates and left to right range size = (xMax - xMin) / Get_NX(); break; case 3: // lower left cell coordinates and lower to upper range size = (yMax - yMin) / Get_NY(); break; } //----------------------------------------------------- if( !System.Assign(size, xMin, yMin, Get_NX(), Get_NY()) ) { return( false ); } //----------------------------------------------------- Parameters("REFERENCED")->asGridList()->Del_Items(); for(int i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Grid *pGrid = pGrids->asGrid(i); CSG_Grid *pReferenced = SG_Create_Grid(System, pGrid->Get_Type()); pReferenced->Set_Name(pGrid->Get_Name()); pReferenced->Set_Unit(pGrid->Get_Unit()); pReferenced->Set_Scaling(pGrid->Get_Scaling(), pGrid->Get_Offset()); pReferenced->Set_NoData_Value_Range(pGrid->Get_NoData_Value(), pGrid->Get_NoData_hiValue()); pReferenced->Get_MetaData () = pGrid->Get_MetaData (); pReferenced->Get_Projection() = pGrid->Get_Projection(); for(int y=0; ySet_Value(x, y, pGrid->asDouble(x, y)); } } Parameters("REFERENCED")->asGridList()->Add_Item(pReferenced); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_georeference/Collect_Points.h0000744000175000017500000001062312737416176026434 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Collect_Points.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Collect_Points.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Collect_Points_H #define HEADER_INCLUDED__Collect_Points_H //--------------------------------------------------------- #include "Georef_Engine.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCollect_Points : public CSG_Module_Interactive { public: CCollect_Points(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); virtual bool On_Execute_Finish (void); private: CSG_Shapes *m_pPoints; CGeoref_Engine m_Engine; bool is_Compatible (CSG_Shapes *pPoints); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Collect_Points_H saga-2.3.1/src/modules/projection/pj_georeference/georef_grid_move.h0000744000175000017500000001120612737416176027013 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: georef_grid_move.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_Georeference // // // //-------------------------------------------------------// // // // Georef_Grid_Move.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@geowiss.uni-hamburg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Bundesstr. 55 // // 20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Georef_Grid_Move_H #define HEADER_INCLUDED__Georef_Grid_Move_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGeoref_Grid_Move : public CSG_Module_Interactive { public: CGeoref_Grid_Move(void); virtual ~CGeoref_Grid_Move(void); protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); virtual bool On_Execute_Finish (void); private: bool m_bModified; CSG_Point m_Down, m_Move; CSG_Grid *m_pGrid, *m_pSource; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Georef_Grid_Move_H saga-2.3.1/src/modules/projection/pj_georeference/Georef_Engine.cpp0000744000175000017500000004700612737416176026547 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Engine.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_Georeference // // // //-------------------------------------------------------// // // // Georef_Engine.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Georef_Engine.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGeoref_Engine::CGeoref_Engine(void) { m_Method = GEOREF_NotSet; m_Order = 0; m_Scaling = 0.0; m_TIN_Fwd.Add_Field("X", SG_DATATYPE_Double); m_TIN_Fwd.Add_Field("Y", SG_DATATYPE_Double); m_TIN_Inv.Add_Field("X", SG_DATATYPE_Double); m_TIN_Inv.Add_Field("Y", SG_DATATYPE_Double); } //--------------------------------------------------------- bool CGeoref_Engine::Destroy(void) { m_Method = GEOREF_NotSet; m_Error.Clear(); m_From.Clear(); m_To .Clear(); m_TIN_Fwd.Del_Records(); m_TIN_Inv.Del_Records(); m_Spline_Fwd[0].Destroy(); m_Spline_Fwd[1].Destroy(); m_Spline_Inv[0].Destroy(); m_Spline_Inv[1].Destroy(); m_Polynom_Fwd[0].Destroy(); m_Polynom_Fwd[1].Destroy(); m_Polynom_Inv[0].Destroy(); m_Polynom_Inv[1].Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Engine::Add_Reference(TSG_Point From, TSG_Point To) { if( m_From.Add(From) && m_To.Add(To) ) { m_Method = GEOREF_NotSet; if( Get_Reference_Count() == 1 ) { m_rFrom.Assign(From, From); m_rTo .Assign(To , To ); } else { m_rFrom.Union(From); m_rTo .Union(To ); } return( true ); } if( m_From.Get_Count() > m_To.Get_Count() ) { m_From.Del(m_From.Get_Count() - 1); } return( false ); } //--------------------------------------------------------- bool CGeoref_Engine::Add_Reference(double xFrom, double yFrom, double xTo, double yTo) { return( Add_Reference(CSG_Point(xFrom, yFrom), CSG_Point(xTo, yTo)) ); } //--------------------------------------------------------- bool CGeoref_Engine::Set_Reference(CSG_Shapes *pFrom, CSG_Shapes *pTo) { if( !pFrom || pFrom->Get_Count() <= 0 || !pTo || pTo ->Get_Count() <= 0 ) { return( false ); } Destroy(); for(int iShape=0; iShapeGet_Count() && iShapeGet_Count(); iShape++) { CSG_Shape *_pFrom = pFrom->Get_Shape(iShape); CSG_Shape *_pTo = pTo ->Get_Shape(iShape); for(int iPart=0; iPart<_pFrom->Get_Part_Count() && iPart<_pTo->Get_Part_Count(); iPart++) { for(int iPoint=0; iPoint<_pFrom->Get_Point_Count(iPart) && iPoint<_pTo->Get_Point_Count(iPart); iPoint++) { Add_Reference(_pFrom->Get_Point(iPoint, iPart), _pTo->Get_Point(iPoint, iPart)); } } } return( true ); } //--------------------------------------------------------- bool CGeoref_Engine::Set_Reference(CSG_Shapes *pFrom, int xTo_Field, int yTo_Field) { if( !pFrom || pFrom->Get_Count() <= 0 || pFrom->Get_Type() != SHAPE_TYPE_Point || xTo_Field < 0 || xTo_Field >= pFrom->Get_Field_Count() || yTo_Field < 0 || yTo_Field >= pFrom->Get_Field_Count() ) { return( false ); } Destroy(); for(int iPoint=0; iPointGet_Count(); iPoint++) { CSG_Shape *pPoint = pFrom->Get_Shape(iPoint); Add_Reference( pPoint->Get_Point(0).x, pPoint->Get_Point(0).y, pPoint->asDouble(xTo_Field), pPoint->asDouble(yTo_Field) ); } return( true ); } //--------------------------------------------------------- bool CGeoref_Engine::Get_Reference_Extent(CSG_Rect &Extent, bool bInverse) { CSG_Points &Points = bInverse ? m_From : m_To; if( Points.Get_Count() >= 3 ) { Extent.Assign(Points[0], Points[1]); for(int i=2; i= 0 && i < Get_Reference_Count() ) { TSG_Point p = m_From[i]; if( Get_Converted(p) ) { return( SG_Get_Distance(p, m_To[i]) ); } } return( -1.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Engine::Set_Scaling(double Scaling) { m_Scaling = Scaling > 0.0 ? Scaling : 0.0; return( m_Scaling > 0.0 ); } //--------------------------------------------------------- bool CGeoref_Engine::Get_Converted(TSG_Point &Point, bool bInverse) { return( Get_Converted(Point.x, Point.y, bInverse) ); } //--------------------------------------------------------- bool CGeoref_Engine::Get_Converted(double &x, double &y, bool bInverse) { bool bResult; if( m_Scaling > 0.0 ) { x = bInverse ? (x - m_rTo .Get_XMin()) * m_Scaling / m_rTo .Get_XRange() : (x - m_rFrom.Get_XMin()) * m_Scaling / m_rFrom.Get_XRange(); y = bInverse ? (y - m_rTo .Get_YMin()) * m_Scaling / m_rTo .Get_YRange() : (y - m_rFrom.Get_YMin()) * m_Scaling / m_rFrom.Get_YRange(); } switch( m_Method ) { case GEOREF_Triangulation: bResult = _Get_Triangulation(x, y, bInverse ? &m_TIN_Inv : &m_TIN_Fwd ); break; case GEOREF_Spline: bResult = _Get_Spline (x, y, bInverse ? m_Spline_Inv : m_Spline_Fwd ); break; case GEOREF_Affine: case GEOREF_Polynomial_1st_Order: case GEOREF_Polynomial_2nd_Order: case GEOREF_Polynomial_3rd_Order: case GEOREF_Polynomial: bResult = _Get_Polynomial (x, y, bInverse ? m_Polynom_Inv : m_Polynom_Fwd); break; default: bResult = false; break; } if( bResult && m_Scaling > 0.0 ) { x = bInverse ? m_rFrom.Get_XMin() + x * m_rFrom.Get_XRange() / m_Scaling : m_rTo .Get_XMin() + x * m_rTo .Get_XRange() / m_Scaling; y = bInverse ? m_rFrom.Get_YMin() + y * m_rFrom.Get_YRange() / m_Scaling : m_rTo .Get_YMin() + y * m_rTo .Get_YRange() / m_Scaling; } return( bResult ); } //--------------------------------------------------------- bool CGeoref_Engine::Evaluate(int Method, int Order) { //----------------------------------------------------- if( Method == GEOREF_NotSet ) // Automatic { if( Get_Reference_Count() >= 4 ) return( Evaluate(GEOREF_Spline) ); // if( Get_Reference_Count() >= 4 ) return( Evaluate(GEOREF_Polynomial_1st_Order) ); return( Evaluate(GEOREF_Affine) ); } //----------------------------------------------------- int n = _Get_Reference_Minimum(Method, Order); if( n < 0 || Get_Reference_Count() < n ) { m_Error.Printf(SG_T("%s\n%s: %d"), _TL("not enough reference points"), _TL("minimum requirement"), n); return( false ); } //----------------------------------------------------- CSG_Points From, To; if( m_Scaling > 0.0 ) { From = m_From; To = m_To; for(int i=0; i 0.0 ) { m_From = From; m_To = To; } if( !bResult ) { m_Method = GEOREF_NotSet; } return( bResult ); } //--------------------------------------------------------- int CGeoref_Engine::_Get_Reference_Minimum(int Method, int Order) { switch( Method ) { default: return( 0 ); case GEOREF_Triangulation: return( 3 ); case GEOREF_Spline: return( 3 ); case GEOREF_Affine: return( 3 ); // 3: a + bx + cy aka RST=rotation/scaling/translation case GEOREF_Polynomial_1st_Order: return( 4 ); // 4: a + bx + cy + dxy case GEOREF_Polynomial_2nd_Order: return( 6 ); // 6: a + bx + cy + dxy + ex^2 + fy^2 case GEOREF_Polynomial_3rd_Order: return( 10 ); // 10: a + bx + cy + dxy + ex^2 + fy^2 + gx^3 + hy^3 + ix^2y + jxy^2 case GEOREF_Polynomial: return( Order > 0 ? (int)SG_Get_Square(Order + 1) : -1 ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Engine::_Set_Triangulation(void) { m_TIN_Fwd.Del_Records(); m_TIN_Inv.Del_Records(); for(int i=0; iSet_Value(0, m_To [i].x); pNode->Set_Value(1, m_To [i].y); pNode = m_TIN_Inv.Add_Node(m_To [i], NULL, false); pNode->Set_Value(0, m_From[i].x); pNode->Set_Value(1, m_From[i].y); } return( m_TIN_Fwd.Update() && m_TIN_Inv.Update() ); } //--------------------------------------------------------- bool CGeoref_Engine::_Get_Triangulation(double &x, double &y, CSG_TIN *pTIN) { CSG_Point p(x, y); for(int i=0; iGet_Triangle_Count(); i++) { CSG_TIN_Triangle *pTriangle = pTIN->Get_Triangle(i); if( pTriangle->is_Containing(p) ) { return( pTriangle->Get_Value(0, p, x) && pTriangle->Get_Value(1, p, y) ); } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Engine::_Set_Spline(void) { m_Spline_Fwd[0].Destroy(); m_Spline_Fwd[1].Destroy(); m_Spline_Inv[0].Destroy(); m_Spline_Inv[1].Destroy(); for(int i=0; i&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/projection/pj_georeference ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libpj_georeference_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libpj_georeference_la_OBJECTS = Collect_Points.lo \ direct_georeferencing.lo Georef_Engine.lo Georef_Grid.lo \ georef_grid_move.lo Georef_Shapes.lo MLB_Interface.lo \ set_grid_georeference.lo libpj_georeference_la_OBJECTS = $(am_libpj_georeference_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libpj_georeference_la_SOURCES) DIST_SOURCES = $(libpj_georeference_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1843 2013-09-18 10:49:15Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libpj_georeference.la libpj_georeference_la_SOURCES = \ Collect_Points.cpp\ direct_georeferencing.cpp\ Georef_Engine.cpp\ Georef_Grid.cpp\ georef_grid_move.cpp\ Georef_Shapes.cpp\ MLB_Interface.cpp\ set_grid_georeference.cpp\ Collect_Points.h\ direct_georeferencing.h\ Georef_Engine.h\ Georef_Grid.h\ georef_grid_move.h\ Georef_Shapes.h\ MLB_Interface.h\ set_grid_georeference.h libpj_georeference_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/projection/pj_georeference/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/projection/pj_georeference/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libpj_georeference.la: $(libpj_georeference_la_OBJECTS) $(libpj_georeference_la_DEPENDENCIES) $(EXTRA_libpj_georeference_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libpj_georeference_la_OBJECTS) $(libpj_georeference_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Collect_Points.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Georef_Engine.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Georef_Grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Georef_Shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/direct_georeferencing.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/georef_grid_move.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_grid_georeference.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/projection/pj_georeference/set_grid_georeference.h0000744000175000017500000001071112737416176030022 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: set_grid_georeference.h 1834 2013-09-11 18:33:29Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // set_grid_georeference.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__set_grid_georeference_H #define HEADER_INCLUDED__set_grid_georeference_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSet_Grid_Georeference : public CSG_Module_Grid { public: CSet_Grid_Georeference(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__set_grid_georeference_H saga-2.3.1/src/modules/projection/pj_georeference/Collect_Points.cpp0000744000175000017500000002257612737416176027001 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Collect_Points.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Collect_Points.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Collect_Points.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CCollect_Points::CCollect_Points(void) { //----------------------------------------------------- Set_Name (_TL("Create Reference Points")); Set_Author (SG_T("O.Conrad (c) 2013")); Set_Description (_TW( "Digitize reference points for georeferencing grids, images and shapes. " "Click with the mouse on known locations in the map window " "and add the reference coordinates. " "After choosing 4 or more points, stop the interactive module execution " "by unchecking it in the in the modules menu." )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "REF_SOURCE" , _TL("Reference Points (Origin)"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "REF_TARGET" , _TL("Reference Points (Projection)"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), GEOREF_METHODS_CHOICE, 0 ); Parameters.Add_Value( NULL , "ORDER" ,_TL("Polynomial Order"), _TL(""), PARAMETER_TYPE_Int, 3, 1, true ); Parameters.Add_Value( NULL , "REFRESH" , _TL("Clear Reference Points"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- CSG_Parameters *pParameters = Add_Parameters("REFERENCE", _TL("Point Position"), _TL("")); pParameters->Add_Value( NULL , "X" , _TL("x Position"), _TL(""), PARAMETER_TYPE_Double ); pParameters->Add_Value( NULL , "Y" , _TL("y Position"), _TL(""), PARAMETER_TYPE_Double ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCollect_Points::is_Compatible(CSG_Shapes *pPoints) { return( pPoints != DATAOBJECT_NOTSET && pPoints != DATAOBJECT_CREATE && pPoints->Get_Count() > 0 && pPoints->Get_Field_Count() >= 5 ); } //--------------------------------------------------------- int CCollect_Points::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("ORDER", pParameter->asInt() == GEOREF_Polynomial); // only show for polynomial, user defined order } if( !SG_STR_CMP(pParameter->Get_Identifier(), "REF_SOURCE") ) { pParameters->Get_Parameter("REFRESH")->Set_Enabled(is_Compatible(pParameter->asShapes())); } return( 1 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CCollect_Points::On_Execute(void) { m_Engine.Destroy(); m_pPoints = Parameters("REF_SOURCE")->asShapes(); Get_Parameters("REFERENCE")->Restore_Defaults(); if( !is_Compatible(m_pPoints) || Parameters("REFRESH")->asBool() ) { m_pPoints->Create(SHAPE_TYPE_Point, _TL("Reference Points (Origin)")); m_pPoints->Add_Field("X_SRC", SG_DATATYPE_Double); m_pPoints->Add_Field("Y_SRC", SG_DATATYPE_Double); m_pPoints->Add_Field("X_MAP", SG_DATATYPE_Double); m_pPoints->Add_Field("Y_MAP", SG_DATATYPE_Double); m_pPoints->Add_Field("RESID", SG_DATATYPE_Double); } else { for(int i=0; iGet_Count(); i++) { CSG_Shape *pPoint = m_pPoints->Get_Shape(i); m_Engine.Add_Reference(pPoint->Get_Point(0), CSG_Point( pPoint->asDouble(2), pPoint->asDouble(3) )); } int Method = Parameters("METHOD")->asInt(); int Order = Parameters("ORDER" )->asInt(); m_Engine.Evaluate(Method, Order); } return( true ); } //--------------------------------------------------------- bool CCollect_Points::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { if( Mode == MODULE_INTERACTIVE_LUP ) { TSG_Point ptTarget; if( m_Engine.Get_Converted(ptTarget = ptWorld) ) { Get_Parameters("REFERENCE")->Get_Parameter("X")->Set_Value(ptTarget.x); Get_Parameters("REFERENCE")->Get_Parameter("Y")->Set_Value(ptTarget.y); } if( Dlg_Parameters("REFERENCE") ) { int Method = Parameters("METHOD")->asInt(); int Order = Parameters("ORDER" )->asInt(); CSG_Shape *pPoint = m_pPoints->Add_Shape(); pPoint->Add_Point(ptWorld); pPoint->Set_Value(0, ptWorld.Get_X()); pPoint->Set_Value(1, ptWorld.Get_Y()); pPoint->Set_Value(2, ptTarget.x = Get_Parameters("REFERENCE")->Get_Parameter("X")->asDouble()); pPoint->Set_Value(3, ptTarget.y = Get_Parameters("REFERENCE")->Get_Parameter("Y")->asDouble()); if( m_Engine.Add_Reference(ptWorld, ptTarget) && m_Engine.Evaluate(Method, Order) && m_pPoints->Get_Count() == m_Engine.Get_Reference_Count() ) { for(int i=0; iGet_Count(); i++) { m_pPoints->Get_Shape(i)->Set_Value(4, m_Engine.Get_Reference_Residual(i)); } } DataObject_Update(m_pPoints); } } return( true ); } //--------------------------------------------------------- bool CCollect_Points::On_Execute_Finish(void) { CSG_Shapes *pTarget = Parameters("REF_TARGET")->asShapes(); if( pTarget != NULL ) { pTarget->Create(SHAPE_TYPE_Point, _TL("Reference Points (Projection)")); pTarget->Add_Field("X_SRC", SG_DATATYPE_Double); pTarget->Add_Field("Y_SRC", SG_DATATYPE_Double); pTarget->Add_Field("X_MAP", SG_DATATYPE_Double); pTarget->Add_Field("Y_MAP", SG_DATATYPE_Double); pTarget->Add_Field("RESID", SG_DATATYPE_Double); for(int iPoint=0; iPointGet_Count(); iPoint++) { CSG_Shape *pPoint = pTarget->Add_Shape(m_pPoints->Get_Shape(iPoint), SHAPE_COPY_ATTR); pPoint->Add_Point( pPoint->asDouble(2), pPoint->asDouble(3) ); } } m_Engine.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_georeference/Makefile.am0000744000175000017500000000151112737416176025372 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1843 2013-09-18 10:49:15Z oconrad $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libpj_georeference.la libpj_georeference_la_SOURCES =\ Collect_Points.cpp\ direct_georeferencing.cpp\ Georef_Engine.cpp\ Georef_Grid.cpp\ georef_grid_move.cpp\ Georef_Shapes.cpp\ MLB_Interface.cpp\ set_grid_georeference.cpp\ Collect_Points.h\ direct_georeferencing.h\ Georef_Engine.h\ Georef_Grid.h\ georef_grid_move.h\ Georef_Shapes.h\ MLB_Interface.h\ set_grid_georeference.h libpj_georeference_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/projection/pj_georeference/Georef_Engine.h0000744000175000017500000001511712737416176026212 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Engine.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Georef_Engine.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Georef_Engine_H #define HEADER_INCLUDED__Georef_Engine_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { GEOREF_NotSet, GEOREF_Triangulation, GEOREF_Spline, GEOREF_Affine, GEOREF_Polynomial_1st_Order, GEOREF_Polynomial_2nd_Order, GEOREF_Polynomial_3rd_Order, GEOREF_Polynomial }; //--------------------------------------------------------- #define GEOREF_METHODS_CHOICE CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|"),\ _TL("Automatic"),\ _TL("Triangulation"),\ _TL("Spline"),\ _TL("Affine"),\ _TL("1st Order Polynomial"),\ _TL("2nd Order Polynomial"),\ _TL("3rd Order Polynomial"),\ _TL("Polynomial, Order")\ ) /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGeoref_Engine { public: CGeoref_Engine(void); bool Destroy (void); bool Add_Reference (TSG_Point From, TSG_Point To); bool Add_Reference (double xFrom, double yFrom, double xTo, double yTo); bool Set_Reference (CSG_Shapes *pFrom, CSG_Shapes *pTo); bool Set_Reference (CSG_Shapes *pFrom, int xTo_Field, int yTo_Field); int Get_Reference_Count (void) { return( m_From.Get_Count() ); } bool Get_Reference_Extent (CSG_Rect &Extent, bool bInverse = false); double Get_Reference_Residual (int i); bool Set_Scaling (double Scaling); double Get_Scaling (void) { return( m_Scaling ); } bool Evaluate (int Method = GEOREF_NotSet, int Order = 1); bool is_Okay (void) { return( m_Method != GEOREF_NotSet ); } bool Get_Converted (TSG_Point &Point , bool bInverse = false); bool Get_Converted (double &x, double &y, bool bInverse = false); CSG_String Get_Error (void) { return( m_Error ); } private: int m_Method, m_Order; double m_Scaling; CSG_String m_Error; CSG_Rect m_rFrom, m_rTo; CSG_Points m_From, m_To; CSG_Vector m_Polynom_Fwd[2], m_Polynom_Inv[2]; CSG_Thin_Plate_Spline m_Spline_Fwd[2], m_Spline_Inv[2]; CSG_TIN m_TIN_Fwd, m_TIN_Inv; int _Get_Reference_Minimum (int Method, int Order); bool _Set_Triangulation (void); bool _Get_Triangulation (double &x, double &y, CSG_TIN *pTIN); bool _Set_Spline (void); bool _Get_Spline (double &x, double &y, CSG_Thin_Plate_Spline Spline[2]); bool _Set_Polynomial (CSG_Points &From, CSG_Points &To, CSG_Vector Polynom[2]); bool _Get_Polynomial (double &x, double &y, CSG_Vector Polynom[2]); void _Get_Polynomial (double x, double y, double *z); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Georef_Engine_H saga-2.3.1/src/modules/projection/pj_georeference/direct_georeferencing.cpp0000744000175000017500000005101512737416176030362 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: direct_georeferencing.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // georeferencing // // // //-------------------------------------------------------// // // // direct_georeferencing.cpp // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "direct_georeferencing.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Direct_Georeferencer::CSG_Direct_Georeferencer(void) {} /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Direct_Georeferencer::Add_Parameters(CSG_Parameters &Parameters) { CSG_Parameter *pNode; //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "NODE_POS" , _TL("Position"), _TL("") ); Parameters.Add_Value( pNode , "X" , _TL("X"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "Y" , _TL("Y"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "Z" , _TL("Flying Height"), _TL(""), PARAMETER_TYPE_Double , 1000.0 ); //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "NODE_DIR" , _TL("Orientation"), _TL("") ); Parameters.Add_Choice( pNode , "ORIENTATION" , _TL("Orientation"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("BLUH"), _TL("PATB") ), 0 ); Parameters.Add_Value( pNode , "OMEGA" , _TL("Omega [degree]"), _TL("rotation around the X axis (roll)"), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "PHI" , _TL("Phi [degree]"), _TL("rotation around the Y axis (pitch)"), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "KAPPA" , _TL("Kappa [degree]"), _TL("rotation around the Z axis (heading)"), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "KAPPA_OFF" , _TL("Kappa Offset [degree]"), _TL("origin adjustment for Z axis (heading)"), PARAMETER_TYPE_Double , 90.0 ); //----------------------------------------------------- pNode = Parameters.Add_Node( NULL , "NODE_CAMERA" , _TL("Camera"), _TL("") ); Parameters.Add_Value( pNode , "CFL" , _TL("Focal Length [mm]"), _TL(""), PARAMETER_TYPE_Double , 80, 0.0, true ); Parameters.Add_Value( pNode , "PXSIZE" , _TL("CCD Physical Pixel Size [micron]"), _TL(""), PARAMETER_TYPE_Double , 5.2, 0.0, true ); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_Direct_Georeferencer::Set_Transformation(CSG_Parameters &Parameters, int nCols, int nRows) { //----------------------------------------------------- m_O.Create(2); m_O[0] = nCols / 2.0; m_O[1] = nRows / 2.0; m_f = Parameters("CFL" )->asDouble() / 1000; // [mm] -> [m] m_s = Parameters("PXSIZE")->asDouble() / 1000000; // [micron] -> [m] //----------------------------------------------------- m_T.Create(3); m_T[0] = Parameters("X")->asDouble(); m_T[1] = Parameters("Y")->asDouble(); m_T[2] = Parameters("Z")->asDouble(); //----------------------------------------------------- double a; CSG_Matrix Rx(3, 3), Ry(3, 3), Rz(3, 3); a = Parameters("OMEGA")->asDouble() * M_DEG_TO_RAD; Rx[0][0] = 1; Rx[0][1] = 0; Rx[0][2] = 0; Rx[1][0] = 0; Rx[1][1] = cos(a); Rx[1][2] = -sin(a); Rx[2][0] = 0; Rx[2][1] = sin(a); Rx[2][2] = cos(a); a = Parameters("PHI" )->asDouble() * M_DEG_TO_RAD; Ry[0][0] = cos(a); Ry[0][1] = 0; Ry[0][2] = sin(a); Ry[1][0] = 0; Ry[1][1] = 1; Ry[1][2] = 0; Ry[2][0] = -sin(a); Ry[2][1] = 0; Ry[2][2] = cos(a); a = Parameters("KAPPA")->asDouble() * M_DEG_TO_RAD + Parameters("KAPPA_OFF")->asDouble() * M_DEG_TO_RAD; Rz[0][0] = cos(a); Rz[0][1] = -sin(a); Rz[0][2] = 0; Rz[1][0] = sin(a); Rz[1][1] = cos(a); Rz[1][2] = 0; Rz[2][0] = 0; Rz[2][1] = 0; Rz[2][2] = 1; switch( Parameters("ORIENTATION")->asInt() ) { case 0: default: m_R = Rz * Rx * Ry; break; // BLUH case 1: m_R = Rx * Ry * Rz; break; // PATB } m_Rinv = m_R.Get_Inverse(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline TSG_Point CSG_Direct_Georeferencer::World_to_Image(double x_w, double y_w, double z_w) { TSG_Point p; CSG_Vector Pw(3), Pc; Pw[0] = x_w; Pw[1] = y_w; Pw[2] = z_w; Pc = m_Rinv * (Pw - m_T); p.x = m_O[0] - (m_f / m_s) * (Pc[0] / Pc[2]); p.y = m_O[1] - (m_f / m_s) * (Pc[1] / Pc[2]); return( p ); } //--------------------------------------------------------- inline TSG_Point CSG_Direct_Georeferencer::Image_to_World(double x_i, double y_i, double z_w) { double k; TSG_Point p; CSG_Vector Pc(3), Pw; Pc[0] = (m_O[0] - x_i) * m_s; Pc[1] = (m_O[1] - y_i) * m_s; Pc[2] = m_f; Pw = m_R * Pc; k = (z_w - m_T[2]) / Pw[2]; p.x = m_T[0] + k * Pw[0]; p.y = m_T[1] + k * Pw[1]; return( p ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDirect_Georeferencing::CDirect_Georeferencing(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Direct Georeferencing of Airborne Photographs")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "Direct georeferencing of aerial photographs uses extrinsic " "(position, attitude) and intrinsic (focal length, physical " "pixel size) camera parameters. Orthorectification routine supports " "additional data from a Digital Elevation Model (DEM).\n" "\nReferences:\n" "Baumker, M. / Heimes, F.J. (2001): " "New Calibration and Computing Method for Direct Georeferencing of Image and Scanner Data Using the Position and Angular Data of an Hybrid Inertial Navigation System. " "OEEPE Workshop, Integrated Sensor Orientation, Hannover 2001. " "online.\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "INPUT" , _TL("Unreferenced Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "OUTPUT" , _TL("Referenced Grids"), _TL(""), PARAMETER_OUTPUT, false ); Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); //----------------------------------------------------- pNode = Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT_OPTIONAL, false ); Parameters.Add_Value( pNode , "ZREF" , _TL("Default Reference Height"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); //----------------------------------------------------- m_Georeferencer.Add_Parameters(Parameters); //----------------------------------------------------- Parameters.Add_Choice( NULL , "RESAMPLING" , _TL("Resampling"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 3 ); Parameters.Add_Choice( NULL , "DATA_TYPE" , _TL("Data Storage Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|%s|%s|%s|"), _TL("1 byte unsigned integer"), _TL("1 byte signed integer"), _TL("2 byte unsigned integer"), _TL("2 byte signed integer"), _TL("4 byte unsigned integer"), _TL("4 byte signed integer"), _TL("4 byte floating point"), _TL("8 byte floating point"), _TL("same as original") ), 8 ); Parameters.Add_Choice( NULL , "ROW_ORDER" , _TL("Row Order"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("top down"), _TL("bottom up") ), 0 ); //----------------------------------------------------- m_Grid_Target.Create(Add_Parameters("TARGET", _TL("Target Grid System"), _TL("")), false); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CDirect_Georeferencing::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Grid_Target.On_Parameter_Changed(pParameters, pParameter); return( CSG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CDirect_Georeferencing::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Grid_Target.On_Parameters_Enable(pParameters, pParameter); return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDirect_Georeferencing::On_Execute(void) { //----------------------------------------------------- if( !m_Georeferencer.Set_Transformation(Parameters, Get_NX(), Get_NY()) ) { return( false ); } //----------------------------------------------------- CSG_Grid *pDEM = Parameters("DEM" )->asGrid(); double zRef = Parameters("ZREF" )->asDouble(); bool bFlip = Parameters("ROW_ORDER")->asInt() == 1; //----------------------------------------------------- TSG_Grid_Resampling Resampling; switch( Parameters("RESAMPLING")->asInt() ) { default: Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: Resampling = GRID_RESAMPLING_Bilinear; break; case 2: Resampling = GRID_RESAMPLING_BicubicSpline; break; case 3: Resampling = GRID_RESAMPLING_BSpline; break; } //----------------------------------------------------- TSG_Point p[4]; p[0] = m_Georeferencer.Image_to_World( 0, 0, zRef); p[1] = m_Georeferencer.Image_to_World(Get_NX(), 0, zRef); p[2] = m_Georeferencer.Image_to_World(Get_NX(), Get_NY(), zRef); p[3] = m_Georeferencer.Image_to_World( 0, Get_NY(), zRef); CSG_Rect r(p[0], p[1]); r.Union(p[2]); r.Union(p[3]); //----------------------------------------------------- CSG_Shapes *pShapes = Parameters("EXTENT")->asShapes(); if( pShapes ) { pShapes->Create(SHAPE_TYPE_Polygon, _TL("Extent")); pShapes->Add_Field(_TL("OID"), SG_DATATYPE_Int); CSG_Shape *pExtent = pShapes->Add_Shape(); pExtent->Add_Point(p[0]); pExtent->Add_Point(p[1]); pExtent->Add_Point(p[2]); pExtent->Add_Point(p[3]); } //----------------------------------------------------- double Cellsize = SG_Get_Distance(p[0], p[1]) / Get_NX(); CSG_Grid_System System(Cellsize, r); m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), System); if( !Dlg_Parameters("TARGET") ) { return( false ); } System = m_Grid_Target.Get_System(); if( !System.is_Valid() ) { return( false ); } //----------------------------------------------------- CSG_Parameter_Grid_List *pInput = Parameters("INPUT" )->asGridList(); CSG_Parameter_Grid_List *pOutput = Parameters("OUTPUT")->asGridList(); pOutput->Del_Items(); if( pInput->Get_Count() <= 0 ) { return( false ); } else { TSG_Data_Type Type; switch( Parameters("DATA_TYPE")->asInt() ) { case 0: Type = SG_DATATYPE_Byte; break; case 1: Type = SG_DATATYPE_Char; break; case 2: Type = SG_DATATYPE_Word; break; case 3: Type = SG_DATATYPE_Short; break; case 4: Type = SG_DATATYPE_DWord; break; case 5: Type = SG_DATATYPE_Int; break; case 6: Type = SG_DATATYPE_Float; break; case 7: Type = SG_DATATYPE_Double; break; default: Type = SG_DATATYPE_Undefined; break; } for(int i=0; iGet_Count(); i++) { CSG_Grid *pGrid = SG_Create_Grid(System, Type != SG_DATATYPE_Undefined ? Type : pInput->asGrid(i)->Get_Type()); if( !pGrid || !pGrid->is_Valid() ) { if( pGrid ) { delete(pGrid); } return( false ); } pOutput->Add_Item(pGrid); pGrid->Set_Name(pInput->asGrid(i)->Get_Name()); } } //----------------------------------------------------- for(int y=0; yGet_Value(px, py, pz) ) { pz = zRef; } TSG_Point p = m_Georeferencer.World_to_Image(px, py, pz); if( bFlip ) { p.y = (Get_NY() - 1) - p.y; } for(int i=0; iGet_Count(); i++) { if( pInput->asGrid(i)->Get_Value(p.x, p.y, pz, Resampling) ) { pOutput->asGrid(i)->Set_Value(x, y, pz); } else { pOutput->asGrid(i)->Set_NoData(x, y); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDirect_Georeferencing_WorldFile::CDirect_Georeferencing_WorldFile(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("World File from Flight and Camera Settings")); Set_Author (SG_T("O.Conrad (c) 2014")); Set_Description (_TW( "Creates a world file (RST = rotation, scaling, translation) " "for georeferencing images by direct georeferencing. " "Direct georeferencing uses extrinsic " "(position, attitude) and intrinsic (focal length, physical " "pixel size) camera parameters.\n" "\nReferences:\n" "Baumker, M. / Heimes, F.J. (2001): " "New Calibration and Computing Method for Direct Georeferencing of Image and Scanner Data Using the Position and Angular Data of an Hybrid Inertial Navigation System. " "OEEPE Workshop, Integrated Sensor Orientation, Hannover 2001. " "online.\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "EXTENT" , _TL("Extent"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_FilePath( NULL , "FILE" , _TL("World File"), _TL(""), CSG_String::Format(SG_T("%s|*.*"), _TL("All Files")), NULL, true ); pNode = Parameters.Add_Node( NULL , "NODE_IMAGE" , _TL("Image Properties"), _TL("") ); Parameters.Add_Value( pNode , "NX" , _TL("Number of Columns"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Value( pNode , "NY" , _TL("Number of Columns"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); //----------------------------------------------------- m_Georeferencer.Add_Parameters(Parameters); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDirect_Georeferencing_WorldFile::On_Execute(void) { //----------------------------------------------------- int nx = Parameters("NX")->asInt(); int ny = Parameters("NY")->asInt(); if( !m_Georeferencer.Set_Transformation(Parameters, nx, ny) ) { return( false ); } //----------------------------------------------------- CSG_String File = Parameters("FILE")->asString(); if( File.is_Empty() ) { return( false ); } //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(File, SG_FILE_W, false) ) { return( false ); } //----------------------------------------------------- CSG_Matrix R(m_Georeferencer.Get_Transformation()); R *= 0.001 * Parameters("Z")->asDouble() / Parameters("CFL")->asDouble() * Parameters("PXSIZE")->asDouble(); TSG_Point p = m_Georeferencer.Image_to_World(0, ny); Stream.Printf(SG_T("%.10f\n%.10f\n%.10f\n%.10f\n%.10f\n%.10f\n"), R[0][0], // A: pixel size in the x-direction in map units/pixel R[1][0], // D: rotation about y-axis -R[0][1], // B: rotation about x-axis -R[1][1], // E: pixel size in the y-direction in map units, almost always negative p.x, // X: top left pixel center p.y // Y: top left pixel center ); //----------------------------------------------------- CSG_Shapes *pExtents = Parameters("EXTENT")->asShapes(); if( pExtents ) { pExtents->Create(SHAPE_TYPE_Polygon, SG_File_Get_Name(File, false)); pExtents->Add_Field(_TL("NAME"), SG_DATATYPE_String); CSG_Shape *pExtent = pExtents->Add_Shape(); p = m_Georeferencer.Image_to_World( 0, 0); pExtent->Add_Point(p.x, p.y); p = m_Georeferencer.Image_to_World( 0, ny); pExtent->Add_Point(p.x, p.y); p = m_Georeferencer.Image_to_World(nx, ny); pExtent->Add_Point(p.x, p.y); p = m_Georeferencer.Image_to_World(nx, 0); pExtent->Add_Point(p.x, p.y); pExtent->Set_Value(0, SG_File_Get_Name(File, false)); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_georeference/Georef_Grid.cpp0000744000175000017500000003430512737416176026225 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Grid.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Georef_Grid.cpp // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Georef_Grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGeoref_Grid::CGeoref_Grid(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Rectify Grid")); Set_Author (SG_T("O.Conrad (c) 2006")); Set_Description (_TW( "Georeferencing and rectification for grids. Either choose the attribute fields (x/y) " "with the projected coordinates for the reference points (origin) or supply a " "additional points layer with correspondend points in the target projection. " )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "REF_SOURCE" , _TL("Reference Points (Origin)"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "REF_TARGET" , _TL("Reference Points (Projection)"), _TL(""), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "XFIELD" , _TL("x Position"), _TL("") ); Parameters.Add_Table_Field( pNode , "YFIELD" , _TL("y Position"), _TL("") ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), GEOREF_METHODS_CHOICE, 0 ); Parameters.Add_Value( NULL , "ORDER" ,_TL("Polynomial Order"), _TL(""), PARAMETER_TYPE_Int, 3, 1, true ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Choice( NULL , "RESAMPLING" , _TL("Resampling"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 3 ); Parameters.Add_Value( NULL , "BYTEWISE" , _TL("Bytewise Interpolation"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- m_Grid_Target.Create(Add_Parameters("TARGET", _TL("Target Grid System"), _TL("")), true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGeoref_Grid::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "REF_SOURCE") && pParameter->asShapes() ) { pParameters->Get_Parameter("XFIELD")->Set_Value(pParameter->asShapes()->Get_Field("X_MAP")); pParameters->Get_Parameter("YFIELD")->Set_Value(pParameter->asShapes()->Get_Field("Y_MAP")); } return( m_Grid_Target.On_Parameter_Changed(pParameters, pParameter) ? 1 : 0 ); } //--------------------------------------------------------- int CGeoref_Grid::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "REF_TARGET") ) { pParameters->Set_Enabled("XFIELD", pParameter->asShapes() == NULL); pParameters->Set_Enabled("YFIELD", pParameter->asShapes() == NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "METHOD") ) { pParameters->Set_Enabled("ORDER", pParameter->asInt() == GEOREF_Polynomial); // only show for polynomial, user defined order } if( !SG_STR_CMP(pParameter->Get_Identifier(), "RESAMPLING") ) { pParameters->Set_Enabled("BYTEWISE", pParameter->asInt() > 0); } return( m_Grid_Target.On_Parameters_Enable(pParameters, pParameter) ? 1 : 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pShapes_A = Parameters("REF_SOURCE")->asShapes(); CSG_Shapes *pShapes_B = Parameters("REF_TARGET")->asShapes(); int xField = Parameters("XFIELD")->asInt(); int yField = Parameters("YFIELD")->asInt(); //----------------------------------------------------- if( ( pShapes_B && m_Engine.Set_Reference(pShapes_A, pShapes_B)) || (!pShapes_B && m_Engine.Set_Reference(pShapes_A, xField, yField)) ) { int Method = Parameters("METHOD")->asInt(); int Order = Parameters("ORDER" )->asInt(); if( m_Engine.Evaluate(Method, Order) && Get_Conversion() ) { m_Engine.Destroy(); return( true ); } } //----------------------------------------------------- if( !m_Engine.Get_Error().is_Empty() ) { Error_Set(m_Engine.Get_Error()); } m_Engine.Destroy(); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid::Get_Conversion(void) { //----------------------------------------------------- CSG_Rect Extent; CSG_Grid *pSource = Parameters("GRID")->asGrid(); //----------------------------------------------------- if( !Get_Target_Extent(Extent, true) || !m_Grid_Target.Set_User_Defined(Get_Parameters("TARGET"), Extent, pSource->Get_NY()) ) { Error_Set(_TL("failed to estimate target extent")); return( false ); } if( !Dlg_Parameters("TARGET") ) { return( false ); } //----------------------------------------------------- TSG_Grid_Resampling Resampling; switch( Parameters("RESAMPLING")->asInt() ) { default: Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: Resampling = GRID_RESAMPLING_Bilinear; break; case 2: Resampling = GRID_RESAMPLING_BicubicSpline; break; case 3: Resampling = GRID_RESAMPLING_BSpline; break; } CSG_Grid *pReferenced = m_Grid_Target.Get_Grid(Resampling == GRID_RESAMPLING_NearestNeighbour ? pSource->Get_Type() : SG_DATATYPE_Float); if( !pReferenced ) { Error_Set(_TL("failed to initialize target grid")); return( false ); } //----------------------------------------------------- if( !Set_Grid(pSource, pReferenced, Resampling) ) { Error_Set(_TL("failed to project target grid")); return( false ); } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pSource, P) ) { DataObject_Add(pReferenced); DataObject_Set_Parameters(pReferenced, P); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid::Get_Target_Extent(CSG_Rect &Extent, bool bEdge) { if( Parameters("METHOD")->asInt() == GEOREF_Triangulation ) // triangulation { return( m_Engine.Get_Reference_Extent(Extent) ); } //----------------------------------------------------- CSG_Grid *pGrid = Parameters("GRID")->asGrid(); Extent.m_rect.xMin = Extent.m_rect.yMin = 1.0; Extent.m_rect.xMax = Extent.m_rect.yMax = 0.0; //----------------------------------------------------- if( bEdge ) { for(int y=0; yGet_NY(); y++) { Add_Target_Extent(Extent, pGrid->Get_XMin(), pGrid->Get_System().Get_yGrid_to_World(y)); Add_Target_Extent(Extent, pGrid->Get_XMax(), pGrid->Get_System().Get_yGrid_to_World(y)); } for(int x=0; xGet_NX(); x++) { Add_Target_Extent(Extent, pGrid->Get_System().Get_xGrid_to_World(x), pGrid->Get_YMin()); Add_Target_Extent(Extent, pGrid->Get_System().Get_xGrid_to_World(x), pGrid->Get_YMax()); } } //----------------------------------------------------- else { for(int y=0; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { if( !pGrid->is_NoData(x, y) ) { TSG_Point p = pGrid->Get_System().Get_Grid_to_World(x, y); Add_Target_Extent(Extent, p.x, p.y); } } } } return( is_Progress() && Extent.Get_XRange() > 0.0 && Extent.Get_YRange() > 0.0 ); } //--------------------------------------------------------- inline void CGeoref_Grid::Add_Target_Extent(CSG_Rect &Extent, double x, double y) { if( m_Engine.Get_Converted(x, y) ) { if( Extent.Get_XRange() >= 0.0 && Extent.Get_YRange() >= 0.0 ) { Extent.Union(CSG_Point(x, y)); } else { Extent.Assign(x, y, x, y); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGeoref_Grid::Set_Grid(CSG_Grid *pGrid, CSG_Grid *pReferenced, TSG_Grid_Resampling Resampling) { if( !pGrid || !pReferenced || !m_Engine.is_Okay() ) { return( false ); } //----------------------------------------------------- bool bBytewise = Parameters("BYTEWISE")->asBool(); //----------------------------------------------------- pReferenced->Set_Name (pGrid->Get_Name()); pReferenced->Set_Unit (pGrid->Get_Unit()); pReferenced->Set_Scaling(pGrid->Get_Scaling(), pGrid->Get_Offset()); pReferenced->Set_NoData_Value_Range(pGrid->Get_NoData_Value(), pGrid->Get_NoData_hiValue()); pReferenced->Assign_NoData(); //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, pReferenced->Get_NY()); y++) { #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double z; TSG_Point p = pReferenced->Get_System().Get_Grid_to_World(x, y); if( m_Engine.Get_Converted(p, true) && pGrid->Get_Value(p, z, Resampling, bBytewise) ) { pReferenced->Set_Value(x, y, z); } else { pReferenced->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGeoref_Grid::Set_Points(CSG_Grid *pGrid, CSG_Shapes *pReferenced) { if( !pGrid || !pReferenced || pReferenced->Get_Type() != SHAPE_TYPE_Point || !m_Engine.is_Okay() ) { return( false ); } //----------------------------------------------------- pReferenced->Create(SHAPE_TYPE_Point, pGrid->Get_Name()); pReferenced->Add_Field("Z", SG_DATATYPE_Double); //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++) { for(int x=0; xGet_NX(); x++) { if( !pGrid->is_NoData(x, y) ) { TSG_Point Point = pGrid->Get_System().Get_Grid_to_World(x, y); if( m_Engine.Get_Converted(Point) ) { CSG_Shape *pPoint = pReferenced->Add_Shape(); pPoint->Add_Point(Point); pPoint->Set_Value(0, pGrid->asDouble(x, y)); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/projection/pj_georeference/MLB_Interface.h0000744000175000017500000000746012737416176026112 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Library Template // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Author // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: author@email.de // // // // contact: Author // // Sesame Street. 7 // // 12345 Metropolis // // Nirwana // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pj_georeference_H #define HEADER_INCLUDED__pj_georeference_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef pj_georeference_EXPORTS #define pj_georeference_EXPORT _SAGA_DLL_EXPORT #else #define pj_georeference_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pj_georeference_H saga-2.3.1/src/modules/projection/pj_georeference/Georef_Grid.h0000744000175000017500000001147012737416176025670 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Georef_Grid.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // Georef_Grid.h // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Georef_Grid_H #define HEADER_INCLUDED__Georef_Grid_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Georef_Engine.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGeoref_Grid : public CSG_Module { public: CGeoref_Grid(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Parameters_Grid_Target m_Grid_Target; CGeoref_Engine m_Engine; bool Get_Conversion (void); bool Get_Target_Extent (CSG_Rect &Extent, bool bEdge); void Add_Target_Extent (CSG_Rect &Extent, double x, double y); bool Set_Grid (CSG_Grid *pGrid, CSG_Grid *pReferenced, TSG_Grid_Resampling Resampling); bool Set_Points (CSG_Grid *pGrid, CSG_Shapes *pReferenced); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Georef_Grid_H saga-2.3.1/src/modules/projection/pj_georeference/MLB_Interface.cpp0000744000175000017500000001107612737416176026443 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // pj_georeference // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003-13 by // // SAGA User Group Association // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Georeferencing") ); case MLB_INFO_Category: return( _TL("Projection") ); case MLB_INFO_Author: return( SG_T("SAGA User Group Association (c) 2003-13") ); case MLB_INFO_Description: return( _TL("Tools for the georeferencing of spatial data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Projection|Georeferencing") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Collect_Points.h" #include "Georef_Grid.h" #include "Georef_Shapes.h" #include "georef_grid_move.h" #include "direct_georeferencing.h" #include "set_grid_georeference.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CCollect_Points ); case 1: return( new CGeoref_Grid ); case 2: return( new CGeoref_Shapes ); case 3: return( new CGeoref_Grid_Move ); case 4: return( new CDirect_Georeferencing ); case 6: return( new CDirect_Georeferencing_WorldFile ); case 5: return( new CSet_Grid_Georeference ); case 10: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/projection/pj_georeference/direct_georeferencing.h0000744000175000017500000001374412737416176030036 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: direct_georeferencing.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // georeferencing // // // //-------------------------------------------------------// // // // direct_georeferencing.h // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__direct_georeferencing_H #define HEADER_INCLUDED__direct_georeferencing_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSG_Direct_Georeferencer { public: CSG_Direct_Georeferencer(void); bool Add_Parameters (CSG_Parameters &Parameters); bool Set_Transformation (CSG_Parameters &Parameters, int nCols, int nRows); const CSG_Matrix & Get_Transformation (void) const { return( m_R ); } TSG_Point World_to_Image (double x_w, double y_w, double z_w = 0.0); TSG_Point Image_to_World (double x_i, double y_i, double z_w = 0.0); private: double m_f, m_s; CSG_Vector m_T, m_O; CSG_Matrix m_R, m_Rinv; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDirect_Georeferencing : public CSG_Module_Grid { public: CDirect_Georeferencing(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Parameters_Grid_Target m_Grid_Target; CSG_Direct_Georeferencer m_Georeferencer; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDirect_Georeferencing_WorldFile : public CSG_Module { public: CDirect_Georeferencing_WorldFile(void); protected: virtual bool On_Execute (void); private: CSG_Direct_Georeferencer m_Georeferencer; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__direct_georeferencing_H saga-2.3.1/src/modules/garden/0000775000175000017500000000000012737740003017270 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/garden/garden_3d_viewer/0000775000175000017500000000000012737740003022477 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/garden/garden_3d_viewer/3d_viewer_globe_grid.h0000744000175000017500000001055112737416156026726 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: 3d_viewer_globe_grid.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // 3d_viewer_globe_grid.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__3d_viewer_globe_grid_H #define HEADER_INCLUDED__3d_viewer_globe_grid_H /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_Globe_Grid : public CSG_Module_Grid { public: C3D_Viewer_Globe_Grid(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__3d_viewer_globe_grid_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_3d_viewer/3d_viewer_tin.h0000744000175000017500000001047212737416156025425 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: 3d_viewer_tin.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // 3d_viewer_tin.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__3d_viewer_tin_H #define HEADER_INCLUDED__3d_viewer_tin_H /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_TIN : public CSG_Module { public: C3D_Viewer_TIN(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__3d_viewer_tin_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_3d_viewer/3d_viewer_globe_grid.cpp0000744000175000017500000004523112737416156027264 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: 3d_viewer_globe_grid.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // 3d_viewer_globe_grid.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "3d_viewer_globe_grid.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_Globe_Grid_Panel : public CSG_3DView_Panel { public: C3D_Viewer_Globe_Grid_Panel(wxWindow *pParent, CSG_Grid *pGrid, CSG_Grid *pZ); virtual ~C3D_Viewer_Globe_Grid_Panel(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual void Update_Statistics (void); virtual void Update_Parent (void); virtual void On_Key_Down (wxKeyEvent &event); virtual bool On_Draw (void); virtual int Get_Color (double Value); private: bool m_Color_bGrad; double m_Color_Min, m_Color_Scale, m_Radius; CSG_Colors m_Colors; CSG_Grid *m_pGrid, *m_pZ; TSG_Point_Z **m_pNodes; bool Create_Nodes (void); bool Get_Node (int x, int y, TSG_Triangle_Node &Node); //----------------------------------------------------- DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(C3D_Viewer_Globe_Grid_Panel, CSG_3DView_Panel) EVT_KEY_DOWN (C3D_Viewer_Globe_Grid_Panel::On_Key_Down) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- C3D_Viewer_Globe_Grid_Panel::C3D_Viewer_Globe_Grid_Panel(wxWindow *pParent, CSG_Grid *pGrid, CSG_Grid *pZ) : CSG_3DView_Panel(pParent) { m_pGrid = pGrid; m_pZ = pZ; m_pNodes = NULL; Create_Nodes(); //----------------------------------------------------- CSG_Parameter *pNode, *pNode_1, *pNode_2; m_Parameters("BGCOLOR" )->Set_Value((int)SG_COLOR_BLACK); m_Parameters("DRAW_BOX")->Set_Value(false); //----------------------------------------------------- pNode = m_Parameters("NODE_GENERAL"); m_Parameters.Add_Value( pNode , "RADIUS" , _TL("Radius"), _TL(""), PARAMETER_TYPE_Double, 6371.0, 0.0, true ); m_Parameters.Add_Value( pNode , "Z_SCALE" , _TL("Exaggeration"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); //----------------------------------------------------- pNode = m_Parameters.Add_Node( NULL , "NODE_VIEW" , _TL("Grid View Settings"), _TL("") ); pNode_1 = m_Parameters.Add_Value( pNode , "DRAW_FACES" , _TL("Draw Faces"), _TL(""), PARAMETER_TYPE_Bool, true ); pNode_2 = m_Parameters.Add_Value( pNode_1 , "COLOR_ASRGB" , _TL("RGB Values"), _TL(""), PARAMETER_TYPE_Bool, false ); m_Parameters.Add_Colors( pNode_2 , "COLORS" , _TL("Colours"), _TL("") ); m_Parameters.Add_Value( pNode_2 , "COLORS_GRAD" , _TL("Graduated"), _TL(""), PARAMETER_TYPE_Bool, true ); m_Parameters.Add_Range( pNode_2 , "COLORS_RANGE" , _TL("Value Range"), _TL("") ); pNode_2 = m_Parameters.Add_Choice( pNode_1 , "SHADING" , _TL("Shading"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("none"), _TL("shading") ), 1 ); m_Parameters.Add_Value( pNode_2 , "SHADE_DEC" , _TL("Light Source Height"), _TL(""), PARAMETER_TYPE_Double, 0.0, -90.0, true, 90.0, true ); m_Parameters.Add_Value( pNode_2 , "SHADE_AZI" , _TL("Light Source Direction"), _TL(""), PARAMETER_TYPE_Double, 315.0, 0.0, true, 360.0, true ); //----------------------------------------------------- pNode_1 = m_Parameters.Add_Value( pNode , "DRAW_EDGES" , _TL("Draw Wire"), _TL(""), PARAMETER_TYPE_Bool, false ); m_Parameters.Add_Value( pNode_1 , "EDGE_COLOR" , _TL("Colour"), _TL(""), PARAMETER_TYPE_Color, SG_GET_RGB(150, 150, 150) ); //----------------------------------------------------- m_Parameters("COLORS_RANGE")->asRange()->Set_Range( m_pGrid->Get_Mean() - 1.5 * m_pGrid->Get_StdDev(), m_pGrid->Get_Mean() + 1.5 * m_pGrid->Get_StdDev() ); Update_Statistics(); } //--------------------------------------------------------- C3D_Viewer_Globe_Grid_Panel::~C3D_Viewer_Globe_Grid_Panel(void) { if( m_pNodes ) { SG_Free(m_pNodes[0]); SG_Free(m_pNodes); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int C3D_Viewer_Globe_Grid_Panel::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "COLOR_ASRGB") ) { pParameters->Get_Parameter("COLORS" )->Set_Enabled(pParameter->asBool() == false); pParameters->Get_Parameter("COLORS_RANGE")->Set_Enabled(pParameter->asBool() == false); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "SHADING") ) { pParameters->Get_Parameter("SHADE_DEC")->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("SHADE_AZI")->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DRAW_EDGES") ) { pParameters->Get_Parameter("EDGE_COLOR")->Set_Enabled(pParameter->asBool()); } return( CSG_3DView_Panel::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_Globe_Grid_Panel::Create_Nodes(void) { m_pNodes = (TSG_Point_Z **)SG_Malloc(m_pGrid->Get_NY () * sizeof(TSG_Point_Z *)); m_pNodes[0] = (TSG_Point_Z *)SG_Malloc(m_pGrid->Get_NCells() * sizeof(TSG_Point_Z )); for(int y=0; yGet_NY(); y++) { m_pNodes[y] = m_pNodes[0] + y * m_pGrid->Get_NX(); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_Globe_Grid_Panel::Update_Statistics(void) { double Radius = m_Parameters("RADIUS")->asDouble(); double zScale = m_pZ ? m_Parameters("Z_SCALE")->asDouble() : 0.0; m_Data_Min.x = m_Data_Max.x = 0.0; m_Data_Min.y = m_Data_Max.y = 0.0; m_Data_Min.z = m_Data_Max.z = 0.0; for(int y=0; yGet_NY(); y++) { TSG_Point_Z *pNode = m_pNodes[y]; double wy = M_DEG_TO_RAD * (m_pGrid->Get_YMin() + y * m_pGrid->Get_Cellsize()); double wx = M_DEG_TO_RAD * (m_pGrid->Get_XMin()); for(int x=0; xGet_NX(); x++, pNode++, wx+=M_DEG_TO_RAD*m_pGrid->Get_Cellsize()) { if( !m_pGrid->is_NoData(x, y) ) { double r = zScale ? Radius + zScale * m_pZ->asDouble(x, y) : Radius; pNode->z = r * sin(wy); double s = r * cos(wy); pNode->x = s * cos(wx); pNode->y = s * sin(wx); if( m_Data_Min.x > pNode->x ) m_Data_Min.x = pNode->x; else if( m_Data_Max.x < pNode->x ) m_Data_Max.x = pNode->x; if( m_Data_Min.y > pNode->y ) m_Data_Min.y = pNode->y; else if( m_Data_Max.y < pNode->y ) m_Data_Max.y = pNode->y; if( m_Data_Min.z > pNode->z ) m_Data_Min.z = pNode->z; else if( m_Data_Max.z < pNode->z ) m_Data_Max.z = pNode->z; } } } //----------------------------------------------------- Update_View(); } //--------------------------------------------------------- void C3D_Viewer_Globe_Grid_Panel::Update_Parent(void) { ((CSG_3DView_Dialog *)GetParent())->Update_Controls(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_Globe_Grid_Panel::On_Key_Down(wxKeyEvent &event) { switch( event.GetKeyCode() ) { default: CSG_3DView_Panel::On_Key_Down(event); return; case WXK_F1: m_Parameters("Z_SCALE")->Set_Value(m_Parameters("Z_SCALE")->asDouble() - 0.5); break; case WXK_F2: m_Parameters("Z_SCALE")->Set_Value(m_Parameters("Z_SCALE")->asDouble() + 0.5); break; } //----------------------------------------------------- Update_View(true); Update_Parent(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int C3D_Viewer_Globe_Grid_Panel::Get_Color(double Value) { if( m_Color_Scale <= 0.0 ) { return( (int)Value ); } double c = m_Color_Scale * (Value - m_Color_Min); return( m_Color_bGrad ? m_Colors.Get_Interpolated(c) : m_Colors[(int)c] ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool C3D_Viewer_Globe_Grid_Panel::Get_Node(int x, int y, TSG_Triangle_Node &Node) { if( m_pGrid->is_InGrid(x, y) ) { TSG_Point_Z p = m_pNodes[y][x]; m_Projector.Get_Projection(p); Node.x = p.x; Node.y = p.y; Node.z = p.z; Node.c = m_pGrid->asDouble(x, y); return( true ); } return( false ); } //--------------------------------------------------------- bool C3D_Viewer_Globe_Grid_Panel::On_Draw(void) { //----------------------------------------------------- if( m_Parameters("COLORS_RANGE")->asRange()->Get_LoVal() >= m_Parameters("COLORS_RANGE")->asRange()->Get_HiVal() ) { m_Parameters("COLORS_RANGE")->asRange()->Set_Range( m_pGrid->Get_Mean() - 1.5 * m_pGrid->Get_StdDev(), m_pGrid->Get_Mean() + 1.5 * m_pGrid->Get_StdDev() ); } bool bValueAsColor = m_Parameters("COLOR_ASRGB")->asBool(); m_Colors = *m_Parameters("COLORS")->asColors(); m_Color_bGrad = m_Parameters("COLORS_GRAD")->asBool(); m_Color_Min = m_Parameters("COLORS_RANGE")->asRange()->Get_LoVal(); m_Color_Scale = m_Colors.Get_Count() / (m_Parameters("COLORS_RANGE")->asRange()->Get_HiVal() - m_Color_Min); //----------------------------------------------------- if( m_Parameters("DRAW_FACES")->asBool() ) // Faces { int Shading = m_Parameters("SHADING" )->asInt (); double Shade_Dec = m_Parameters("SHADE_DEC")->asDouble() * -M_DEG_TO_RAD; double Shade_Azi = m_Parameters("SHADE_AZI")->asDouble() * M_DEG_TO_RAD; #pragma omp parallel for for(int y=1; yGet_NY(); y++) { for(int x=1; xGet_NX(); x++) { TSG_Triangle_Node p[3]; if( Get_Node(x - 1, y - 1, p[0]) && Get_Node(x , y , p[1]) ) { if( Get_Node(x, y - 1, p[2]) ) { if( Shading ) Draw_Triangle(p, bValueAsColor, Shade_Dec, Shade_Azi); else Draw_Triangle(p, bValueAsColor); } if( Get_Node(x - 1, y, p[2]) ) { if( Shading ) Draw_Triangle(p, bValueAsColor, Shade_Dec, Shade_Azi); else Draw_Triangle(p, bValueAsColor); } } } } } //----------------------------------------------------- if( m_Parameters("DRAW_EDGES")->asBool() ) // Edges { int Color = m_Parameters("EDGE_COLOR")->asColor(); #pragma omp parallel for for(int y=1; yGet_NY(); y++) { for(int x=1; xGet_NX(); x++) { TSG_Triangle_Node p[2]; if( Get_Node(x - 1, y - 1, p[0]) && Get_Node(x , y , p[1]) ) { if( !bValueAsColor ) { p[0].c = Get_Color(p[0].c); p[1].c = Get_Color(p[1].c); } Draw_Line(p[0].x, p[0].y, p[0].z, p[1].x, p[1].y, p[1].z, p[0].c, p[1].c); if( Get_Node(x, y - 1, p[1]) ) { if( !bValueAsColor ) { p[1].c = Get_Color(p[1].c); } Draw_Line(p[0].x, p[0].y, p[0].z, p[1].x, p[1].y, p[1].z, p[0].c, p[1].c); Draw_Line(p[0].x, p[0].y, p[0].z, p[1].x, p[1].y, p[1].z, p[0].c, p[1].c); } if( Get_Node(x - 1, y, p[1]) ) { if( !bValueAsColor ) { p[1].c = Get_Color(p[1].c); } Draw_Line(p[0].x, p[0].y, p[0].z, p[1].x, p[1].y, p[1].z, p[0].c, p[1].c); Draw_Line(p[0].x, p[0].y, p[0].z, p[1].x, p[1].y, p[1].z, p[0].c, p[1].c); } } } } } //----------------------------------------------------- if( !m_Parameters("DRAW_FACES")->asBool() && !m_Parameters("DRAW_EDGES")->asBool() ) // Nodes { int Color = m_Parameters("EDGE_COLOR")->asColor(); for(int y=0; yGet_NY(); y++) { for(int x=0; xGet_NX(); x++) { TSG_Triangle_Node p; Get_Node(x, y, p); Draw_Point(p.x, p.y, p.z, bValueAsColor ? p.c : Get_Color(p.c), 2); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_Globe_Grid_Dialog : public CSG_3DView_Dialog { public: C3D_Viewer_Globe_Grid_Dialog(CSG_Grid *pGrid, CSG_Grid *pZ); virtual void Update_Controls (void); protected: wxCheckBox *m_pFaces, *m_pEdges; virtual void On_Update_Control (wxCommandEvent &event); private: DECLARE_EVENT_TABLE() }; //--------------------------------------------------------- BEGIN_EVENT_TABLE(C3D_Viewer_Globe_Grid_Dialog, CSG_3DView_Dialog) EVT_CHECKBOX (wxID_ANY , C3D_Viewer_Globe_Grid_Dialog::On_Update_Control) END_EVENT_TABLE() //--------------------------------------------------------- C3D_Viewer_Globe_Grid_Dialog::C3D_Viewer_Globe_Grid_Dialog(CSG_Grid *pGrid, CSG_Grid *pZ) : CSG_3DView_Dialog(_TL("Globe Viewer for Grids")) { Create(new C3D_Viewer_Globe_Grid_Panel(this, pGrid, pZ)); Add_Spacer(); m_pFaces = Add_CheckBox(_TL("Faces"), m_pPanel->m_Parameters("DRAW_FACES")->asBool()); m_pEdges = Add_CheckBox(_TL("Edges"), m_pPanel->m_Parameters("DRAW_EDGES")->asBool()); } //--------------------------------------------------------- void C3D_Viewer_Globe_Grid_Dialog::On_Update_Control(wxCommandEvent &event) { CHECKBOX_UPDATE(m_pFaces, "DRAW_FACES"); CHECKBOX_UPDATE(m_pEdges, "DRAW_EDGES"); CSG_3DView_Dialog::On_Update_Control(event); } //--------------------------------------------------------- void C3D_Viewer_Globe_Grid_Dialog::Update_Controls(void) { m_pFaces->SetValue(m_pPanel->m_Parameters("DRAW_FACES")->asBool()); m_pEdges->SetValue(m_pPanel->m_Parameters("DRAW_EDGES")->asBool()); CSG_3DView_Dialog::Update_Controls(); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- C3D_Viewer_Globe_Grid::C3D_Viewer_Globe_Grid(void) { //----------------------------------------------------- Set_Name (_TL("Globe Viewer for Grids")); Set_Author ("O. Conrad (c) 2014"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "Z" , _TL("Elevation"), _TL(""), PARAMETER_INPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_Globe_Grid::On_Execute(void) { C3D_Viewer_Globe_Grid_Dialog dlg( Parameters("GRID")->asGrid(), Parameters("Z" )->asGrid() ); dlg.ShowModal(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_3d_viewer/3d_viewer_shapes.cpp0000744000175000017500000003377412737416156026463 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: 3d_viewer_shapes.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // 3d_viewer_shapes.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "3d_viewer_shapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_Shapes_Panel : public CSG_3DView_Panel { public: C3D_Viewer_Shapes_Panel(wxWindow *pParent, CSG_Shapes *pShapes, int Field_Color); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual void Update_Statistics (void); virtual void Update_Parent (void); virtual void On_Key_Down (wxKeyEvent &event); virtual bool On_Before_Draw (void); virtual bool On_Draw (void); virtual int Get_Color (double Value); private: bool m_Color_bGrad; double m_Color_Min, m_Color_Scale; CSG_Colors m_Colors; CSG_Shapes *m_pShapes; void Draw_Shape (CSG_Shape *pShape, int Field_Color); //----------------------------------------------------- DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(C3D_Viewer_Shapes_Panel, CSG_3DView_Panel) EVT_KEY_DOWN (C3D_Viewer_Shapes_Panel::On_Key_Down) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- C3D_Viewer_Shapes_Panel::C3D_Viewer_Shapes_Panel(wxWindow *pParent, CSG_Shapes *pShapes, int cField) : CSG_3DView_Panel(pParent) { m_pShapes = pShapes; //----------------------------------------------------- CSG_String Attributes; for(int i=0; iGet_Field_Count(); i++) { Attributes += m_pShapes->Get_Field_Name(i); Attributes += "|"; } //----------------------------------------------------- CSG_Parameter *pNode, *pNode_1; //----------------------------------------------------- pNode = m_Parameters("NODE_GENERAL"); m_Parameters.Add_Value( pNode , "Z_SCALE" , _TL("Exaggeration"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); //----------------------------------------------------- pNode = m_Parameters.Add_Node( NULL , "NODE_VIEW" , _TL("Shapes View Settings"), _TL("") ); pNode_1 = m_Parameters.Add_Choice( pNode , "COLORS_ATTR" , _TL("Colour Attribute"), _TL(""), Attributes, cField ); m_Parameters.Add_Colors( pNode_1 , "COLORS" , _TL("Colours"), _TL("") ); m_Parameters.Add_Value( pNode_1 , "COLORS_GRAD" , _TL("Graduated"), _TL(""), PARAMETER_TYPE_Bool, true ); m_Parameters.Add_Range( pNode_1 , "COLORS_RANGE" , _TL("Value Range"), _TL("") ); //----------------------------------------------------- Update_Statistics(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int C3D_Viewer_Shapes_Panel::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( CSG_3DView_Panel::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_Shapes_Panel::Update_Statistics(void) { int Field = m_Parameters("COLORS_ATTR")->asInt(); m_Parameters("COLORS_RANGE")->asRange()->Set_Range( m_pShapes->Get_Mean(Field) - 1.5 * m_pShapes->Get_StdDev(Field), m_pShapes->Get_Mean(Field) + 1.5 * m_pShapes->Get_StdDev(Field) ); m_Data_Min.x = m_pShapes->Get_Extent().Get_XMin(); m_Data_Max.x = m_pShapes->Get_Extent().Get_XMax(); m_Data_Min.y = m_pShapes->Get_Extent().Get_YMin(); m_Data_Max.y = m_pShapes->Get_Extent().Get_YMax(); m_Data_Min.z = m_pShapes->Get_ZMin(); m_Data_Max.z = m_pShapes->Get_ZMax(); //----------------------------------------------------- Update_View(); } //--------------------------------------------------------- void C3D_Viewer_Shapes_Panel::Update_Parent(void) { ((CSG_3DView_Dialog *)GetParent())->Update_Controls(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_Shapes_Panel::On_Key_Down(wxKeyEvent &event) { switch( event.GetKeyCode() ) { default: CSG_3DView_Panel::On_Key_Down(event); return; case WXK_F1: m_Parameters("Z_SCALE")->Set_Value(m_Parameters("Z_SCALE")->asDouble() - 0.5); break; case WXK_F2: m_Parameters("Z_SCALE")->Set_Value(m_Parameters("Z_SCALE")->asDouble() + 0.5); break; } //----------------------------------------------------- Update_View(); Update_Parent(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_Shapes_Panel::On_Before_Draw(void) { if( m_Play_State == SG_3DVIEW_PLAY_STOP ) { m_Projector.Set_zScaling(m_Projector.Get_xScaling() * m_Parameters("Z_SCALE")->asDouble()); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int C3D_Viewer_Shapes_Panel::Get_Color(double Value) { if( m_Color_Scale <= 0.0 ) { return( (int)Value ); } double c = m_Color_Scale * (Value - m_Color_Min); return( m_Color_bGrad ? m_Colors.Get_Interpolated(c) : m_Colors[(int)c] ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_Shapes_Panel::On_Draw(void) { //----------------------------------------------------- int cField = m_Parameters("COLORS_ATTR")->asInt(); if( m_Parameters("COLORS_RANGE")->asRange()->Get_LoVal() >= m_Parameters("COLORS_RANGE")->asRange()->Get_HiVal() ) { m_Parameters("COLORS_RANGE")->asRange()->Set_Range( m_pShapes->Get_Mean(cField) - 1.5 * m_pShapes->Get_StdDev(cField), m_pShapes->Get_Mean(cField) + 1.5 * m_pShapes->Get_StdDev(cField) ); } m_Colors = *m_Parameters("COLORS")->asColors(); m_Color_bGrad = m_Parameters("COLORS_GRAD")->asBool(); m_Color_Min = m_Parameters("COLORS_RANGE")->asRange()->Get_LoVal(); m_Color_Scale = m_Colors.Get_Count() / (m_Parameters("COLORS_RANGE")->asRange()->Get_HiVal() - m_Color_Min); //------------------------------------------------- for(int iShape=0; iShapeGet_Count(); iShape++) { Draw_Shape(m_pShapes->Get_Shape(iShape), cField); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_Shapes_Panel::Draw_Shape(CSG_Shape *pShape, int Field_Color) { int Color = Get_Color(pShape->asDouble(Field_Color)); for(int iPart=0; iPartGet_Part_Count(); iPart++) { switch( pShape->Get_Type() ) { //------------------------------------------------- case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point_Z a; TSG_Point p = pShape->Get_Point(iPoint, iPart); a.x = p.x; a.y = p.y; a.z = pShape->Get_Z(iPoint, iPart); m_Projector.Get_Projection(a); Draw_Point(a.x, a.y, a.z, Color, 2); } } break; //------------------------------------------------- case SHAPE_TYPE_Line: { TSG_Point_Z a, b; TSG_Point p = pShape->Get_Point(0, iPart); a.x = p.x; a.y = p.y; a.z = pShape->Get_Z(0, iPart); m_Projector.Get_Projection(a); for(int iPoint=1; iPointGet_Point_Count(iPart); iPoint++) { b = a; p = pShape->Get_Point(iPoint, iPart); a.x = p.x; a.y = p.y; a.z = pShape->Get_Z(iPoint, iPart); m_Projector.Get_Projection(a); Draw_Line(a, b, Color); } } break; //------------------------------------------------- case SHAPE_TYPE_Polygon: { TSG_Point_Z a, b; TSG_Point p = pShape->Get_Point(0, iPart, false); a.x = p.x; a.y = p.y; a.z = pShape->Get_Z(0, iPart, false); m_Projector.Get_Projection(a); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { b = a; p = pShape->Get_Point(iPoint, iPart); a.x = p.x; a.y = p.y; a.z = pShape->Get_Z(iPoint, iPart); m_Projector.Get_Projection(a); Draw_Line(a, b, Color); } } break; } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_Shapes_Dialog : public CSG_3DView_Dialog { public: C3D_Viewer_Shapes_Dialog(CSG_Shapes *pShapes, int Field_Color) : CSG_3DView_Dialog(_TL("3D Shapes Viewer")) { Create(new C3D_Viewer_Shapes_Panel(this, pShapes, Field_Color)); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- C3D_Viewer_Shapes::C3D_Viewer_Shapes(void) { //----------------------------------------------------- Set_Name (_TL("3D Shapes Viewer")); Set_Author ("O. Conrad (c) 2014"); Set_Description (_TW( "3D viewer for 3D Shapes." )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "COLOR" , _TL("Colour"), _TL("") ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_Shapes::On_Execute(void) { CSG_Shapes *pShapes = Parameters("SHAPES")->asShapes(); if( !pShapes->is_Valid() ) { Error_Set(_TL("invalid input")); return( false ); } C3D_Viewer_Shapes_Dialog dlg(pShapes, Parameters("COLOR")->asInt()); dlg.ShowModal(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_3d_viewer/3d_viewer_shapes.h0000744000175000017500000001051612737416156026115 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: 3d_viewer_shapes.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // 3d_viewer_shapes.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__3d_viewer_shapes_H #define HEADER_INCLUDED__3d_viewer_shapes_H /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_Shapes : public CSG_Module { public: C3D_Viewer_Shapes(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__3d_viewer_shapes_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_3d_viewer/Makefile.in0000664000175000017500000005702612737447615024573 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/garden/garden_3d_viewer ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libgarden_3d_viewer_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la \ $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la am_libgarden_3d_viewer_la_OBJECTS = MLB_Interface.lo \ 3d_viewer_globe_grid.lo 3d_viewer_multiple_grids.lo \ 3d_viewer_pointcloud.lo 3d_viewer_shapes.lo 3d_viewer_tin.lo libgarden_3d_viewer_la_OBJECTS = $(am_libgarden_3d_viewer_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libgarden_3d_viewer_la_SOURCES) DIST_SOURCES = $(libgarden_3d_viewer_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libgarden_3d_viewer.la libgarden_3d_viewer_la_SOURCES = \ MLB_Interface.cpp\ 3d_viewer_globe_grid.cpp\ 3d_viewer_multiple_grids.cpp\ 3d_viewer_pointcloud.cpp\ 3d_viewer_shapes.cpp\ 3d_viewer_tin.cpp\ MLB_Interface.h\ 3d_viewer_globe_grid.h\ 3d_viewer_multiple_grids.h\ 3d_viewer_pointcloud.h\ 3d_viewer_shapes.h\ 3d_viewer_tin.h libgarden_3d_viewer_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la $(ADD_MLBS) all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/garden/garden_3d_viewer/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/garden/garden_3d_viewer/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libgarden_3d_viewer.la: $(libgarden_3d_viewer_la_OBJECTS) $(libgarden_3d_viewer_la_DEPENDENCIES) $(EXTRA_libgarden_3d_viewer_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libgarden_3d_viewer_la_OBJECTS) $(libgarden_3d_viewer_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/3d_viewer_globe_grid.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/3d_viewer_multiple_grids.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/3d_viewer_pointcloud.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/3d_viewer_shapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/3d_viewer_tin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/garden/garden_3d_viewer/3d_viewer_pointcloud.cpp0000744000175000017500000007055012737416156027351 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: 3d_viewer_pointcloud.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // 3d_viewer_pointcloud.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "3d_viewer_pointcloud.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_PointCloud_Panel : public CSG_3DView_Panel { public: C3D_Viewer_PointCloud_Panel(wxWindow *pParent, CSG_PointCloud *pPoints, int Field_Color); void Set_Extent (CSG_Rect Extent); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual void Update_Statistics (void); virtual void Update_Parent (void); virtual void On_Key_Down (wxKeyEvent &event); virtual bool On_Before_Draw (void); virtual bool On_Draw (void); virtual int Get_Color (double Value, double z); private: bool m_Color_bGrad; double m_Color_Min, m_Color_Scale, m_Color_Dim_Min, m_Color_Dim_Max; CSG_Array m_Selection; CSG_Colors m_Colors; CSG_Rect m_Extent; CSG_PointCloud *m_pPoints; //----------------------------------------------------- DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(C3D_Viewer_PointCloud_Panel, CSG_3DView_Panel) EVT_KEY_DOWN (C3D_Viewer_PointCloud_Panel::On_Key_Down) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- C3D_Viewer_PointCloud_Panel::C3D_Viewer_PointCloud_Panel(wxWindow *pParent, CSG_PointCloud *pPoints, int cField) : CSG_3DView_Panel(pParent) { m_pPoints = pPoints; //----------------------------------------------------- CSG_String Attributes; for(int i=0; iGet_Field_Count(); i++) { Attributes += m_pPoints->Get_Field_Name(i); Attributes += "|"; } //----------------------------------------------------- CSG_Parameter *pNode, *pNode_1; //----------------------------------------------------- pNode = m_Parameters("NODE_GENERAL"); m_Parameters.Add_Value( pNode , "Z_SCALE" , _TL("Exaggeration"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); //----------------------------------------------------- pNode = m_Parameters.Add_Node( NULL , "NODE_VIEW" , _TL("Point View Settings"), _TL("") ); pNode_1 = m_Parameters.Add_Value( pNode , "DETAIL" , _TL("Level of Detail"), _TL(""), PARAMETER_TYPE_Double, 100.0, 0.0, true, 100.0, true ); pNode_1 = m_Parameters.Add_Choice( pNode , "COLORS_ATTR" , _TL("Colour Attribute"), _TL(""), Attributes, cField ); m_Parameters.Add_Value( pNode_1 , "VAL_AS_RGB" , _TL("RGB Values"), _TL(""), PARAMETER_TYPE_Bool, false ); m_Parameters.Add_Colors( pNode_1 , "COLORS" , _TL("Colours"), _TL("") ); m_Parameters.Add_Value( pNode_1 , "COLORS_GRAD" , _TL("Graduated"), _TL(""), PARAMETER_TYPE_Bool, true ); m_Parameters.Add_Range( pNode_1 , "COLORS_RANGE" , _TL("Value Range"), _TL("") ); //----------------------------------------------------- pNode_1 = m_Parameters.Add_Value( pNode , "DIM" , _TL("Dim"), _TL(""), PARAMETER_TYPE_Bool, false ); m_Parameters.Add_Range( pNode_1 , "DIM_RANGE" , _TL("Distance Range"), _TL(""), 0.0, 1.0, 0.0, true ); //----------------------------------------------------- m_Parameters.Add_Value( pNode , "SIZE" , _TL("Size"), _TL(""), PARAMETER_TYPE_Int, 2, 1, true ); m_Parameters.Add_Value( pNode , "SIZE_SCALE" , _TL("Size Scaling"), _TL(""), PARAMETER_TYPE_Double, 250.0, 0.0, true ); //----------------------------------------------------- m_Parameters.Add_Choice( pNode , "OVERVIEW_ATTR" , _TL("Overview Content"), _TL(""), CSG_String::Format("%s|%s|", _TL("average value"), _TL("number of points") ), 0 ); //----------------------------------------------------- m_Extent = pPoints->Get_Extent(); m_Selection.Create(sizeof(int), 0, SG_ARRAY_GROWTH_2); Update_Statistics(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int C3D_Viewer_PointCloud_Panel::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "VAL_AS_RGB") ) { pParameters->Get_Parameter("COLORS" )->Set_Enabled(pParameter->asBool() == false); pParameters->Get_Parameter("COLORS_RANGE")->Set_Enabled(pParameter->asBool() == false); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DIM") ) { pParameters->Get_Parameter("DIM_RANGE")->Set_Enabled(pParameter->asBool()); } return( CSG_3DView_Panel::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_PointCloud_Panel::Set_Extent(CSG_Rect Extent) { if( Extent.Get_XRange() == 0.0 || Extent.Get_YRange() == 0.0 ) { Extent = m_pPoints->Get_Extent(); } if( Extent.is_Equal(m_Extent) == false ) { m_Extent = Extent; Update_View(true); } } //--------------------------------------------------------- void C3D_Viewer_PointCloud_Panel::Update_Statistics(void) { m_Data_Min.x = m_Extent.Get_XMin(); m_Data_Max.x = m_Extent.Get_XMax(); m_Data_Min.y = m_Extent.Get_YMin(); m_Data_Max.y = m_Extent.Get_YMax(); m_Selection.Set_Array(0); if( m_Extent.is_Equal(m_pPoints->Get_Extent()) ) { int cField = m_Parameters("COLORS_ATTR")->asInt(); m_Parameters("COLORS_RANGE")->asRange()->Set_Range( m_pPoints->Get_Mean(cField) - 1.5 * m_pPoints->Get_StdDev(cField), m_pPoints->Get_Mean(cField) + 1.5 * m_pPoints->Get_StdDev(cField) ); m_Data_Min.z = m_pPoints->Get_Minimum(2); // Get_ZMin(); ToDo in CSG_PointCloud class!!! m_Data_Max.z = m_pPoints->Get_Maximum(2); // Get_ZMax(); ToDo in CSG_PointCloud class!!! } else { CSG_Simple_Statistics cStats, zStats; int cField = m_Parameters("COLORS_ATTR")->asInt(); for(int i=0; iGet_Count(); i++) { m_pPoints->Set_Cursor(i); if( m_Extent.Contains(m_pPoints->Get_X(), m_pPoints->Get_Y()) && m_Selection.Inc_Array() ) { *((int *)m_Selection.Get_Entry(m_Selection.Get_Size() - 1)) = i; cStats += m_pPoints->Get_Value(cField); zStats += m_pPoints->Get_Z(); } } m_Parameters("COLORS_RANGE")->asRange()->Set_Range( cStats.Get_Mean() - 1.5 * cStats.Get_StdDev(), cStats.Get_Mean() + 1.5 * cStats.Get_StdDev() ); m_Data_Min.z = zStats.Get_Minimum(); m_Data_Max.z = zStats.Get_Maximum(); } } //--------------------------------------------------------- void C3D_Viewer_PointCloud_Panel::Update_Parent(void) { ((CSG_3DView_Dialog *)GetParent())->Update_Controls(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_PointCloud_Panel::On_Key_Down(wxKeyEvent &event) { switch( event.GetKeyCode() ) { default: CSG_3DView_Panel::On_Key_Down(event); return; case WXK_F1: m_Parameters("Z_SCALE" )->Set_Value(m_Parameters("Z_SCALE" )->asDouble() - 0.5); break; case WXK_F2: m_Parameters("Z_SCALE" )->Set_Value(m_Parameters("Z_SCALE" )->asDouble() + 0.5); break; case WXK_F5: m_Parameters("SIZE" )->Set_Value(m_Parameters("SIZE" )->asDouble() - 1.0); break; case WXK_F6: m_Parameters("SIZE" )->Set_Value(m_Parameters("SIZE" )->asDouble() + 1.0); break; case WXK_F7: m_Parameters("SIZE_SCALE")->Set_Value(m_Parameters("SIZE_SCALE")->asDouble() - 10.0); break; case WXK_F8: m_Parameters("SIZE_SCALE")->Set_Value(m_Parameters("SIZE_SCALE")->asDouble() + 10.0); break; } //----------------------------------------------------- Update_View(); Update_Parent(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_PointCloud_Panel::On_Before_Draw(void) { if( m_Play_State == SG_3DVIEW_PLAY_STOP ) { m_Projector.Set_zScaling(m_Projector.Get_xScaling() * m_Parameters("Z_SCALE")->asDouble()); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int C3D_Viewer_PointCloud_Panel::Get_Color(double Value, double z) { int Color; if( m_Color_Scale <= 0.0 ) { Color = (int)Value; } else { double c = m_Color_Scale * (Value - m_Color_Min); Color = m_Color_bGrad ? m_Colors.Get_Interpolated(c) : m_Colors[(int)c]; } //----------------------------------------------------- if( m_Color_Dim_Min < m_Color_Dim_Max ) { double dim = 1.0 - (z - m_Color_Dim_Min) / (m_Color_Dim_Max - m_Color_Dim_Min); if( dim < 1.0 ) { Color = Dim_Color(Color, dim < 0.1 ? 0.1 : dim); } } return( Color ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_PointCloud_Panel::On_Draw(void) { //----------------------------------------------------- int cField = m_Parameters("COLORS_ATTR")->asInt(); if( m_Parameters("COLORS_RANGE")->asRange()->Get_LoVal() >= m_Parameters("COLORS_RANGE")->asRange()->Get_HiVal() ) { m_Parameters("COLORS_RANGE")->asRange()->Set_Range( m_pPoints->Get_Mean(cField) - 1.5 * m_pPoints->Get_StdDev(cField), m_pPoints->Get_Mean(cField) + 1.5 * m_pPoints->Get_StdDev(cField) ); } m_Colors = *m_Parameters("COLORS")->asColors(); m_Color_bGrad = m_Parameters("COLORS_GRAD")->asBool(); m_Color_Min = m_Parameters("COLORS_RANGE")->asRange()->Get_LoVal(); m_Color_Scale = m_Parameters("VAL_AS_RGB")->asBool() ? 0.0 : m_Colors.Get_Count() / (m_Parameters("COLORS_RANGE")->asRange()->Get_HiVal() - m_Color_Min); if( m_Parameters("DIM")->asBool() ) { m_Color_Dim_Min = m_Parameters("DIM_RANGE")->asRange()->Get_LoVal() * (m_Data_Max.z - m_Data_Min.z); m_Color_Dim_Max = m_Parameters("DIM_RANGE")->asRange()->Get_HiVal() * (m_Data_Max.z - m_Data_Min.z); } else { m_Color_Dim_Min = m_Color_Dim_Max = 0.0; } //----------------------------------------------------- int Size = m_Parameters("SIZE" )->asInt (); double dSize = m_Parameters("SIZE_SCALE")->asDouble(); if( dSize > 0.0 ) dSize = 1.0 / dSize; else dSize = 0.0; //----------------------------------------------------- int nSkip = 1 + (int)(0.001 * m_pPoints->Get_Count() * SG_Get_Square(1.0 - 0.01 * m_Parameters("DETAIL")->asDouble())); //----------------------------------------------------- int nPoints = m_Selection.Get_Size() > 0 ? (int)m_Selection.Get_Size() : m_pPoints->Get_Count(); #pragma omp parallel for for(int iPoint=0; iPoint 0 ? *((int *)m_Selection.Get_Entry(iPoint)) : iPoint; TSG_Point_Z p = m_pPoints->Get_Point(jPoint); m_Projector.Get_Projection(p); Draw_Point(p.x, p.y, p.z, Get_Color(m_pPoints->Get_Value(jPoint, cField), p.z), Size + (dSize <= 0.0 ? 0 : (int)(20.0 * exp(-dSize * p.z))) ); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPointCloud_Overview : public wxDialog { public: CPointCloud_Overview(void) {} void Create (wxWindow *pParent, CSG_PointCloud *pPoints, C3D_Viewer_PointCloud_Panel *pPanel) { m_pPanel = pPanel; wxDialog::Create(pParent, wxID_ANY, _TL("Overview"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxCLOSE_BOX|wxSTAY_ON_TOP ); //------------------------------------------------- m_Ratio = pPoints->Get_Extent().Get_XRange() / pPoints->Get_Extent().Get_YRange(); CSG_Grid_System System(m_Ratio > 1.0 ? pPoints->Get_Extent().Get_XRange() / 100.0 : pPoints->Get_Extent().Get_YRange() / 100.0, pPoints->Get_Extent() ); m_Count.Create(System, SG_DATATYPE_Int); m_Value.Create(System, SG_DATATYPE_Double); for(int i=0, x, y; iGet_Count(); i++) { if( m_Count.Get_System().Get_World_to_Grid(x, y, pPoints->Get_X(i), pPoints->Get_Y(i)) ) // && m_Count.is_InGrid(x, y, false) ) { m_Count.Add_Value(x, y, 1); m_Value.Add_Value(x, y, pPoints->Get_Z(i)); } } m_Value.Divide(m_Count); int Size = GetClientSize().GetWidth(); if( m_Ratio > 1.0 ) Set_Size(Size, (int)(Size / m_Ratio), false); else Set_Size((int)(Size * m_Ratio), Size, false); } private: bool m_bCount; double m_Ratio; wxPoint m_Mouse_Down, m_Mouse_Move; CSG_Rect m_Selection; wxImage m_Image; CSG_Grid m_Count, m_Value; C3D_Viewer_PointCloud_Panel *m_pPanel; //--------------------------------------------------------- void On_Mouse_LDown (wxMouseEvent &event) { m_Mouse_Down = m_Mouse_Move = event.GetPosition(); Draw_Inverse(m_Mouse_Down, m_Mouse_Move); CaptureMouse(); } //--------------------------------------------------------- void On_Mouse_Motion (wxMouseEvent &event) { if( HasCapture() && event.Dragging() && event.LeftIsDown() ) { Draw_Inverse(m_Mouse_Down, m_Mouse_Move); Draw_Inverse(m_Mouse_Down, event.GetPosition()); } m_Mouse_Move = event.GetPosition(); } //--------------------------------------------------------- void On_Mouse_LUp (wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } if( m_Mouse_Down.x != event.GetX() && m_Mouse_Down.y != event.GetY() ) { double dx = m_Count.Get_XRange() / GetClientSize().GetWidth (); double dy = -m_Count.Get_YRange() / GetClientSize().GetHeight(); m_Selection.Assign( m_Count.Get_XMin() + dx * m_Mouse_Down.x, m_Count.Get_YMax() + dy * m_Mouse_Down.y, m_Count.Get_XMin() + dx * event.GetX(), m_Count.Get_YMax() + dy * event.GetY() ); m_pPanel->Set_Extent(m_Selection); } Refresh(false); } //--------------------------------------------------------- void On_Mouse_RDown (wxMouseEvent &event) { m_Selection.Assign(0.0, 0.0, 0.0, 0.0); m_pPanel->Set_Extent(m_Selection); Refresh(false); } //--------------------------------------------------------- void On_Key_Down (wxKeyEvent &event) { switch( event.GetKeyCode() ) { case WXK_PAGEUP: Set_Size(GetClientSize().GetWidth() * 1.25, GetClientSize().GetHeight() * 1.25, true); break; case WXK_PAGEDOWN: Set_Size(GetClientSize().GetWidth() / 1.25, GetClientSize().GetHeight() / 1.25, true); break; case WXK_SPACE: m_pPanel->m_Parameters("OVERVIEW_ATTR")->Set_Value(m_pPanel->m_Parameters("OVERVIEW_ATTR")->asInt() ? 0 : 1); Set_Image(true); break; } } //--------------------------------------------------------- void On_Close (wxCloseEvent &event) { Hide(); ((CSG_3DView_Dialog *)GetParent())->Update_Controls(); } //--------------------------------------------------------- void On_Paint (wxPaintEvent &WXUNUSED(event)) { wxPaintDC dc(this); if( m_Image.IsOk() ) { dc.DrawBitmap(wxBitmap(m_Image), GetClientRect().GetTopLeft()); } if( m_Selection.Get_XRange() > 0.0 && m_Selection.Get_YRange() > 0.0 ) { dc.SetPen(wxPen(*wxRED)); double dx = GetClientSize().GetWidth () / m_Count.Get_XRange(); double dy = -GetClientSize().GetHeight() / m_Count.Get_YRange(); int ax = dx * (m_Selection.Get_XMin() - m_Count.Get_XMin()); int ay = dy * (m_Selection.Get_YMin() - m_Count.Get_YMin()) + GetClientSize().GetHeight(); int bx = dx * (m_Selection.Get_XMax() - m_Count.Get_XMin()); int by = dy * (m_Selection.Get_YMax() - m_Count.Get_YMin()) + GetClientSize().GetHeight(); Draw_Inverse(wxPoint(ax, ay), wxPoint(bx, by)); dc.DrawLine(ax, ay, ax, by); dc.DrawLine(ax, by, bx, by); dc.DrawLine(bx, by, bx, ay); dc.DrawLine(bx, ay, ax, ay); } } //--------------------------------------------------------- void Draw_Inverse (wxPoint A, wxPoint B) { wxClientDC dc(this); dc.SetLogicalFunction(wxINVERT); dc.DrawRectangle(A.x, A.y, B.x - A.x, B.y - A.y); } //--------------------------------------------------------- void Set_Size (int Width, int Height, bool bRefresh) { if( Width < 100 || Height < 100 || Width > 1000 || Height > 1000 ) { return; } SetClientSize(Width, Height); if( !m_Image.IsOk() || m_Image.GetWidth() != Width ) { m_Image.Create(Width, Height, false); Set_Image(bRefresh); } } //--------------------------------------------------------- void Set_Image (bool bRefresh) { if( m_Image.IsOk() && m_Count.is_Valid() ) { bool bCount = m_pPanel->m_Parameters("OVERVIEW_ATTR")->asInt() == 1; CSG_Colors Colors(11, SG_COLORS_RAINBOW); Colors.Set_Color(0, m_pPanel->m_Parameters("BGCOLOR")->asColor()); double dx = m_Count.Get_XRange() / (double)m_Image.GetWidth (); double dy = m_Count.Get_YRange() / (double)m_Image.GetHeight(); double dz = (Colors.Get_Count() - 2.0) / (bCount ? log(1.0 + m_Count.Get_ZMax()) : 4.0 * m_Value.Get_StdDev()); #pragma omp parallel for for(int y=0; y 0.0 ? log(1.0 + iz) : 0.0); } else if( m_Value.Get_Value(ix, iy, iz) ) { iz = dz * (iz - (m_Value.Get_Mean() - 2.0 * m_Value.Get_StdDev())); } else { iz = 0.0; } int ic = Colors.Get_Interpolated(iz); m_Image.SetRGB(x, y, SG_GET_R(ic), SG_GET_G(ic), SG_GET_B(ic)); } } } if( bRefresh ) { Refresh(false); } } DECLARE_EVENT_TABLE() }; //--------------------------------------------------------- BEGIN_EVENT_TABLE(CPointCloud_Overview, wxDialog) EVT_LEFT_DOWN (CPointCloud_Overview::On_Mouse_LDown) EVT_LEFT_UP (CPointCloud_Overview::On_Mouse_LUp) EVT_RIGHT_DOWN (CPointCloud_Overview::On_Mouse_RDown) EVT_MOTION (CPointCloud_Overview::On_Mouse_Motion) EVT_KEY_DOWN (CPointCloud_Overview::On_Key_Down) EVT_CLOSE (CPointCloud_Overview::On_Close) EVT_PAINT (CPointCloud_Overview::On_Paint) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_PointCloud_Dialog : public CSG_3DView_Dialog { public: C3D_Viewer_PointCloud_Dialog(CSG_PointCloud *pPoints, int Field_Color) : CSG_3DView_Dialog(_TL("Point Cloud Viewer")) { Create(new C3D_Viewer_PointCloud_Panel(this, pPoints, Field_Color)); wxArrayString Attributes; for(int i=0; iGet_Field_Count(); i++) { Attributes.Add(pPoints->Get_Field_Name(i)); } Add_Spacer(); m_pField_C = Add_Choice (_TL("Colour" ), Attributes, Field_Color); Add_Spacer(); m_pOverview = Add_CheckBox(_TL("Overview"), false); m_Overview.Create(this, pPoints, (C3D_Viewer_PointCloud_Panel *)m_pPanel); } virtual void Update_Controls (void); protected: wxChoice *m_pField_C; wxCheckBox *m_pOverview; CPointCloud_Overview m_Overview; virtual void On_Update_Choices (wxCommandEvent &event); virtual void On_Update_Control (wxCommandEvent &event); virtual void Set_Menu (wxMenu &Menu); virtual void On_Menu (wxCommandEvent &event); virtual void On_Menu_UI (wxUpdateUIEvent &event); private: DECLARE_EVENT_TABLE() }; //--------------------------------------------------------- BEGIN_EVENT_TABLE(C3D_Viewer_PointCloud_Dialog, CSG_3DView_Dialog) EVT_CHECKBOX (wxID_ANY, C3D_Viewer_PointCloud_Dialog::On_Update_Control) EVT_CHOICE (wxID_ANY, C3D_Viewer_PointCloud_Dialog::On_Update_Choices) END_EVENT_TABLE() //--------------------------------------------------------- void C3D_Viewer_PointCloud_Dialog::On_Update_Choices(wxCommandEvent &event) { if( event.GetEventObject() == m_pField_C ) { m_pPanel->m_Parameters("COLORS_ATTR")->Set_Value(m_pField_C->GetSelection()); m_pPanel->Update_View(true); return; } CSG_3DView_Dialog::On_Update_Choices(event); } //--------------------------------------------------------- void C3D_Viewer_PointCloud_Dialog::On_Update_Control(wxCommandEvent &event) { if( event.GetEventObject() == m_pOverview ) { #ifdef _SAGA_MSW m_Overview.Show(m_pOverview->GetValue() == 1 ? true : false); // unluckily this does not work with linux (broken event handler chain, non-modal dialog as subprocess of a modal one!!) #else m_Overview.ShowModal(); #endif } CSG_3DView_Dialog::On_Update_Control(event); } //--------------------------------------------------------- void C3D_Viewer_PointCloud_Dialog::Update_Controls(void) { m_pField_C->SetSelection(m_pPanel->m_Parameters("COLORS_ATTR")->asInt()); m_pOverview->SetValue(m_Overview.IsShown()); CSG_3DView_Dialog::Update_Controls(); } //--------------------------------------------------------- enum { MENU_SCALE_Z_DEC = MENU_USER_FIRST, MENU_SCALE_Z_INC, MENU_VAL_AS_RGB, MENU_COLORS_GRAD, MENU_SIZE_DEC, MENU_SIZE_INC, MENU_SIZE_SCALE_DEC, MENU_SIZE_SCALE_INC }; //--------------------------------------------------------- void C3D_Viewer_PointCloud_Dialog::Set_Menu(wxMenu &Menu) { wxMenu *pMenu = Menu.FindChildItem(Menu.FindItem(_TL("Display")))->GetSubMenu(); pMenu->AppendSeparator(); pMenu->Append (MENU_SCALE_Z_DEC , _TL("Decrease Exaggeration [F1]")); pMenu->Append (MENU_SCALE_Z_INC , _TL("Increase Exaggeration [F2]")); pMenu->AppendSeparator(); pMenu->Append (MENU_SIZE_DEC , _TL("Decrease Size [F5]")); pMenu->Append (MENU_SIZE_INC , _TL("Increase Size [F6]")); pMenu->AppendSeparator(); pMenu->Append (MENU_SIZE_SCALE_DEC, _TL("Decrease Size Scaling Factor [F7]")); pMenu->Append (MENU_SIZE_SCALE_INC, _TL("Increase Size Scaling Factor [F8]")); pMenu->AppendSeparator(); pMenu->AppendCheckItem(MENU_VAL_AS_RGB , _TL("Value as RGB")); pMenu->AppendCheckItem(MENU_COLORS_GRAD , _TL("Graduated Colours")); } //--------------------------------------------------------- void C3D_Viewer_PointCloud_Dialog::On_Menu(wxCommandEvent &event) { switch( event.GetId() ) { default: CSG_3DView_Dialog::On_Menu(event); return; case MENU_SCALE_Z_DEC : MENU_VALUE_ADD("Z_SCALE" , -0.5); return; case MENU_SCALE_Z_INC : MENU_VALUE_ADD("Z_SCALE" , 0.5); return; case MENU_SIZE_DEC : MENU_VALUE_ADD("SIZE" , -1.0); return; case MENU_SIZE_INC : MENU_VALUE_ADD("SIZE" , 1.0); return; case MENU_SIZE_SCALE_DEC: MENU_VALUE_ADD("SIZE_SCALE", -10.0); return; case MENU_SIZE_SCALE_INC: MENU_VALUE_ADD("SIZE_SCALE", 10.0); return; case MENU_VAL_AS_RGB : MENU_TOGGLE("VAL_AS_RGB" ); return; case MENU_COLORS_GRAD : MENU_TOGGLE("COLORS_GRAD"); return; } } //--------------------------------------------------------- void C3D_Viewer_PointCloud_Dialog::On_Menu_UI(wxUpdateUIEvent &event) { switch( event.GetId() ) { default: CSG_3DView_Dialog::On_Menu_UI(event); break; case MENU_VAL_AS_RGB : event.Check(m_pPanel->m_Parameters("VAL_AS_RGB" )->asBool()); break; case MENU_COLORS_GRAD: event.Check(m_pPanel->m_Parameters("COLORS_GRAD")->asBool()); break; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- C3D_Viewer_PointCloud::C3D_Viewer_PointCloud(void) { //----------------------------------------------------- Set_Name (_TL("Point Cloud Viewer")); Set_Author ("O. Conrad (c) 2014"); Set_Description (_TW( "3D viewer for point clouds." )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Point Cloud"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "COLOR" , _TL("Color"), _TL("") ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_PointCloud::On_Execute(void) { CSG_PointCloud *pPoints = Parameters("POINTS")->asPointCloud(); if( pPoints->Get_Count() <= 0 ) { Message_Add(_TL("point cloud viewer will not be started, because point cloud has no points")); return( false ); } C3D_Viewer_PointCloud_Dialog dlg(pPoints, Parameters("COLOR")->asInt()); dlg.ShowModal(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_3d_viewer/Makefile.am0000744000175000017500000000165112737416156024546 0ustar00oconradoconrad00000000000000if DEBUG DBGFLAGS = -g -DDEBUG endif DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libgarden_3d_viewer.la libgarden_3d_viewer_la_SOURCES =\ MLB_Interface.cpp\ 3d_viewer_globe_grid.cpp\ 3d_viewer_multiple_grids.cpp\ 3d_viewer_pointcloud.cpp\ 3d_viewer_shapes.cpp\ 3d_viewer_tin.cpp\ MLB_Interface.h\ 3d_viewer_globe_grid.h\ 3d_viewer_multiple_grids.h\ 3d_viewer_pointcloud.h\ 3d_viewer_shapes.h\ 3d_viewer_tin.h libgarden_3d_viewer_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(top_srcdir)/src/saga_core/saga_gdi/libsaga_gdi.la $(ADD_MLBS) saga-2.3.1/src/modules/garden/garden_3d_viewer/3d_viewer_pointcloud.h0000744000175000017500000001054612737416156027015 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: 3d_viewer_pointcloud.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // 3d_viewer_pointcloud.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__3d_viewer_pointcloud_H #define HEADER_INCLUDED__3d_viewer_pointcloud_H /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_PointCloud : public CSG_Module { public: C3D_Viewer_PointCloud(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__3d_viewer_pointcloud_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_3d_viewer/3d_viewer_multiple_grids.cpp0000744000175000017500000003557512737416156030224 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: 3d_viewer_multiple_grids.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // 3d_viewer_multiple_grids.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "3d_viewer_multiple_grids.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_Multiple_Grids_Panel : public CSG_3DView_Panel { public: C3D_Viewer_Multiple_Grids_Panel(wxWindow *pParent, CSG_Parameter_Grid_List *pGrids); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual void Update_Statistics (void); virtual void Update_Parent (void); virtual void On_Key_Down (wxKeyEvent &event); virtual bool On_Before_Draw (void); virtual bool On_Draw (void); virtual int Get_Color (double Value); private: bool m_Color_bGrad; double m_Color_Min, m_Color_Scale; CSG_Colors m_Colors; CSG_Parameter_Grid_List *m_pGrids; bool Get_Node (CSG_Grid *pGrid, int x, int y, TSG_Triangle_Node &Node); void Draw_Grid (CSG_Grid *pGrid); //----------------------------------------------------- DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(C3D_Viewer_Multiple_Grids_Panel, CSG_3DView_Panel) EVT_KEY_DOWN (C3D_Viewer_Multiple_Grids_Panel::On_Key_Down) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- C3D_Viewer_Multiple_Grids_Panel::C3D_Viewer_Multiple_Grids_Panel(wxWindow *pParent, CSG_Parameter_Grid_List *pGrids) : CSG_3DView_Panel(pParent) { m_pGrids = pGrids; //----------------------------------------------------- CSG_Parameter *pNode, *pNode_1; //----------------------------------------------------- pNode = m_Parameters("NODE_GENERAL"); m_Parameters.Add_Value( pNode , "Z_SCALE" , _TL("Exaggeration"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); //----------------------------------------------------- pNode = m_Parameters.Add_Node( NULL , "NODE_VIEW" , _TL("Grid View Settings"), _TL("") ); pNode_1 = m_Parameters.Add_Colors( pNode , "COLORS" , _TL("Colours"), _TL("") ); m_Parameters.Add_Value( pNode_1 , "COLORS_GRAD" , _TL("Graduated"), _TL(""), PARAMETER_TYPE_Bool, true ); pNode_1 = m_Parameters.Add_Choice( pNode , "SHADING" , _TL("Shading"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("none"), _TL("shading") ), 1 ); m_Parameters.Add_Value( pNode_1 , "SHADE_DEC" , _TL("Light Source Height"), _TL(""), PARAMETER_TYPE_Double, 0.0, -90.0, true, 90.0, true ); m_Parameters.Add_Value( pNode_1 , "SHADE_AZI" , _TL("Light Source Direction"), _TL(""), PARAMETER_TYPE_Double, 315.0, 0.0, true, 360.0, true ); //----------------------------------------------------- Update_Statistics(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int C3D_Viewer_Multiple_Grids_Panel::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "SHADING") ) { pParameters->Get_Parameter("SHADE_DEC")->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("SHADE_AZI")->Set_Enabled(pParameter->asBool()); } return( CSG_3DView_Panel::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_Multiple_Grids_Panel::Update_Statistics(void) { m_Data_Min.x = m_pGrids->asGrid(0)->Get_XMin(); m_Data_Max.x = m_pGrids->asGrid(0)->Get_XMax(); m_Data_Min.y = m_pGrids->asGrid(0)->Get_YMin(); m_Data_Max.y = m_pGrids->asGrid(0)->Get_YMax(); m_Data_Min.z = m_pGrids->asGrid(0)->Get_ZMin(); m_Data_Max.z = m_pGrids->asGrid(0)->Get_ZMax(); for(int i=1; iGet_Count(); i++) { CSG_Grid *pGrid = m_pGrids->asGrid(i); if( m_Data_Min.x > pGrid->Get_XMin() ) m_Data_Min.x = pGrid->Get_XMin(); else if( m_Data_Max.x < pGrid->Get_XMax() ) m_Data_Max.x = pGrid->Get_XMax(); if( m_Data_Min.y > pGrid->Get_YMin() ) m_Data_Min.y = pGrid->Get_YMin(); else if( m_Data_Max.y < pGrid->Get_YMax() ) m_Data_Max.y = pGrid->Get_YMax(); if( m_Data_Min.z > pGrid->Get_ZMin() ) m_Data_Min.z = pGrid->Get_ZMin(); else if( m_Data_Max.z < pGrid->Get_ZMax() ) m_Data_Max.z = pGrid->Get_ZMax(); } Update_View(); } //--------------------------------------------------------- void C3D_Viewer_Multiple_Grids_Panel::Update_Parent(void) { ((CSG_3DView_Dialog *)GetParent())->Update_Controls(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_Multiple_Grids_Panel::On_Key_Down(wxKeyEvent &event) { switch( event.GetKeyCode() ) { default: CSG_3DView_Panel::On_Key_Down(event); return; case WXK_F1: m_Parameters("Z_SCALE")->Set_Value(m_Parameters("Z_SCALE")->asDouble() - 0.5); break; case WXK_F2: m_Parameters("Z_SCALE")->Set_Value(m_Parameters("Z_SCALE")->asDouble() + 0.5); break; } //----------------------------------------------------- Update_View(); Update_Parent(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_Multiple_Grids_Panel::On_Before_Draw(void) { if( m_Play_State == SG_3DVIEW_PLAY_STOP ) { m_Projector.Set_zScaling(m_Projector.Get_xScaling() * m_Parameters("Z_SCALE")->asDouble()); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int C3D_Viewer_Multiple_Grids_Panel::Get_Color(double Value) { if( m_Color_Scale <= 0.0 ) { return( (int)Value ); } double c = m_Color_Scale * (Value - m_Color_Min); return( m_Color_bGrad ? m_Colors.Get_Interpolated(c) : m_Colors[(int)c] ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_Multiple_Grids_Panel::On_Draw(void) { //------------------------------------------------- for(int i=0; iGet_Count(); i++) { Draw_Grid(m_pGrids->asGrid(i)); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool C3D_Viewer_Multiple_Grids_Panel::Get_Node(CSG_Grid *pGrid, int x, int y, TSG_Triangle_Node &Node) { if( pGrid->is_InGrid(x, y) ) { TSG_Point_Z p; p.x = pGrid->Get_System().Get_xGrid_to_World(x); p.y = pGrid->Get_System().Get_yGrid_to_World(y); p.z = Node.c = pGrid->asDouble(x, y); m_Projector.Get_Projection(p); Node.x = p.x; Node.y = p.y; Node.z = p.z; return( true ); } return( false ); } //--------------------------------------------------------- void C3D_Viewer_Multiple_Grids_Panel::Draw_Grid(CSG_Grid *pGrid) { //----------------------------------------------------- if( !SG_UI_DataObject_Colors_Get(pGrid, &m_Colors) ) { m_Colors = *m_Parameters("COLORS")->asColors(); } m_Color_bGrad = m_Parameters("COLORS_GRAD")->asBool(); m_Color_Min = pGrid->Get_ZMin(); m_Color_Scale = pGrid->Get_ZRange() > 0.0 ? m_Colors.Get_Count() / pGrid->Get_ZRange() : 0.0; //----------------------------------------------------- int Shading = m_Parameters("SHADING" )->asInt (); double Shade_Dec = m_Parameters("SHADE_DEC")->asDouble() * -M_DEG_TO_RAD; double Shade_Azi = m_Parameters("SHADE_AZI")->asDouble() * M_DEG_TO_RAD; //----------------------------------------------------- #pragma omp parallel for for(int y=1; yGet_NY(); y++) { for(int x=1; xGet_NX(); x++) { TSG_Triangle_Node p[3]; if( Get_Node(pGrid, x - 1, y - 1, p[0]) && Get_Node(pGrid, x , y , p[1]) ) { if( Get_Node(pGrid, x , y - 1, p[2]) ) { if( Shading ) Draw_Triangle(p, false, Shade_Dec, Shade_Azi); else Draw_Triangle(p, false); } if( Get_Node(pGrid, x - 1, y , p[2]) ) { if( Shading ) Draw_Triangle(p, false, Shade_Dec, Shade_Azi); else Draw_Triangle(p, false); } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_Multiple_Grids_Dialog : public CSG_3DView_Dialog { public: C3D_Viewer_Multiple_Grids_Dialog(CSG_Parameter_Grid_List *pGrids) : CSG_3DView_Dialog(_TL("Multiple Grids Viewer")) { Create(new C3D_Viewer_Multiple_Grids_Panel(this, pGrids)); } protected: virtual void Set_Menu (wxMenu &Menu); virtual void On_Menu (wxCommandEvent &event); }; //--------------------------------------------------------- enum { MENU_SCALE_Z_DEC = MENU_USER_FIRST, MENU_SCALE_Z_INC }; //--------------------------------------------------------- void C3D_Viewer_Multiple_Grids_Dialog::Set_Menu(wxMenu &Menu) { wxMenu *pMenu = Menu.FindChildItem(Menu.FindItem(_TL("Display")))->GetSubMenu(); pMenu->AppendSeparator(); pMenu->Append(MENU_SCALE_Z_DEC, _TL("Decrease Exaggeration [F1]")); pMenu->Append(MENU_SCALE_Z_INC, _TL("Increase Exaggeration [F2]")); } //--------------------------------------------------------- void C3D_Viewer_Multiple_Grids_Dialog::On_Menu(wxCommandEvent &event) { switch( event.GetId() ) { case MENU_SCALE_Z_DEC: m_pPanel->m_Parameters("Z_SCALE")->Set_Value(m_pPanel->m_Parameters("Z_SCALE")->asDouble() - 0.5); m_pPanel->Update_View(); return; case MENU_SCALE_Z_INC: m_pPanel->m_Parameters("Z_SCALE")->Set_Value(m_pPanel->m_Parameters("Z_SCALE")->asDouble() + 0.5); m_pPanel->Update_View(); return; } CSG_3DView_Dialog::On_Menu(event); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- C3D_Viewer_Multiple_Grids::C3D_Viewer_Multiple_Grids(void) { //----------------------------------------------------- Set_Name (_TL("Multiple Grids Viewer")); Set_Author ("O. Conrad (c) 2014"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); } //--------------------------------------------------------- bool C3D_Viewer_Multiple_Grids::On_Execute(void) { CSG_Parameter_Grid_List *pGrids = Parameters("GRIDS")->asGridList(); if( pGrids->Get_Count() <= 0 ) { Message_Add(_TL("invalid input")); return( false ); } C3D_Viewer_Multiple_Grids_Dialog dlg(pGrids); dlg.ShowModal(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_3d_viewer/3d_viewer_tin.cpp0000744000175000017500000005756412737416156025775 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: 3d_viewer_tin.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // 3d_viewer_tin.cpp // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "3d_viewer_tin.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_TIN_Panel : public CSG_3DView_Panel { public: C3D_Viewer_TIN_Panel(wxWindow *pParent, CSG_TIN *pTIN, int Field_Z, int Field_Color, CSG_Grid *pDrape); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual void Update_Statistics (void); virtual void Update_Parent (void); virtual void On_Key_Down (wxKeyEvent &event); virtual bool On_Before_Draw (void); virtual bool On_Draw (void); virtual int Get_Color (double Value); private: bool m_Color_bGrad; double m_Color_Min, m_Color_Scale; CSG_Colors m_Colors; CSG_TIN *m_pTIN; //----------------------------------------------------- DECLARE_EVENT_TABLE() }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- BEGIN_EVENT_TABLE(C3D_Viewer_TIN_Panel, CSG_3DView_Panel) EVT_KEY_DOWN (C3D_Viewer_TIN_Panel::On_Key_Down) END_EVENT_TABLE() /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- C3D_Viewer_TIN_Panel::C3D_Viewer_TIN_Panel(wxWindow *pParent, CSG_TIN *pTIN, int zField, int cField, CSG_Grid *pDrape) : CSG_3DView_Panel(pParent, pDrape) { m_pTIN = pTIN; //----------------------------------------------------- CSG_String Attributes; for(int i=0; iGet_Field_Count(); i++) { Attributes += pTIN->Get_Field_Name(i); Attributes += "|"; } //----------------------------------------------------- CSG_Parameter *pNode, *pNode_1, *pNode_2; //----------------------------------------------------- pNode = m_Parameters("NODE_GENERAL"); pNode_1 = m_Parameters.Add_Choice( pNode , "Z_ATTR" , _TL("Z Attribute"), _TL(""), Attributes, zField ); m_Parameters.Add_Value( pNode_1 , "Z_SCALE" , _TL("Exaggeration"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); //----------------------------------------------------- pNode = m_Parameters.Add_Node( NULL , "NODE_VIEW" , _TL("TIN View Settings"), _TL("") ); pNode_1 = m_Parameters.Add_Value( pNode , "DRAW_FACES" , _TL("Draw Faces"), _TL(""), PARAMETER_TYPE_Bool, true ); pNode_2 = m_Parameters.Add_Choice( pNode_1 , "COLORS_ATTR" , _TL("Colour Attribute"), _TL(""), Attributes, cField ); m_Parameters.Add_Colors( pNode_2 , "COLORS" , _TL("Colours"), _TL("") ); m_Parameters.Add_Value( pNode_2 , "COLORS_GRAD" , _TL("Graduated"), _TL(""), PARAMETER_TYPE_Bool, true ); m_Parameters.Add_Range( pNode_2 , "COLORS_RANGE" , _TL("Value Range"), _TL("") ); pNode_2 = m_Parameters.Add_Choice( pNode_1 , "SHADING" , _TL("Shading"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("none"), _TL("shading"), _TL("shading (fixed light source)") ), 1 ); m_Parameters.Add_Value( pNode_2 , "SHADE_DEC" , _TL("Light Source Height"), _TL(""), PARAMETER_TYPE_Double, 45.0, -90.0, true, 90.0, true ); m_Parameters.Add_Value( pNode_2 , "SHADE_AZI" , _TL("Light Source Direction"), _TL(""), PARAMETER_TYPE_Double, 90.0, 0.0, true, 360.0, true ); //----------------------------------------------------- pNode_1 = m_Parameters.Add_Value( pNode , "DRAW_EDGES" , _TL("Draw Wire"), _TL(""), PARAMETER_TYPE_Bool, false ); pNode_2 = m_Parameters.Add_Value( pNode_1 , "EDGE_COLOR_UNI" , _TL("Single Colour"), _TL(""), PARAMETER_TYPE_Bool, false ); m_Parameters.Add_Value( pNode_2 , "EDGE_COLOR" , _TL("Colour"), _TL(""), PARAMETER_TYPE_Color, SG_GET_RGB(150, 150, 150) ); //----------------------------------------------------- pNode = m_Parameters.Add_Value( NULL , "DRAW_NODES" , _TL("Draw Nodes"), _TL(""), PARAMETER_TYPE_Bool, false ); m_Parameters.Add_Value( pNode , "NODE_COLOR" , _TL("Colour"), _TL(""), PARAMETER_TYPE_Color, SG_COLOR_BLACK ); m_Parameters.Add_Value( pNode , "NODE_SIZE" , _TL("Size"), _TL(""), PARAMETER_TYPE_Int, 2, 1, true ); m_Parameters.Add_Value( pNode , "NODE_SCALE" , _TL("Size Scaling"), _TL(""), PARAMETER_TYPE_Double, 250.0, 1.0, true ); //----------------------------------------------------- Update_Statistics(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int C3D_Viewer_TIN_Panel::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "DRAW_FACES") ) { CSG_Parameter *pDrape = pParameters->Get_Parameter("DO_DRAPE"); pParameters->Get_Parameter("COLORS_ATTR")->Set_Enabled(pParameter->asBool() && (!pDrape || !pDrape->asBool())); pParameters->Get_Parameter("SHADING" )->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DO_DRAPE") ) { CSG_Parameter *pFaces = pParameters->Get_Parameter("DRAW_FACES"); pParameters->Get_Parameter("COLORS_ATTR")->Set_Enabled(pParameter->asBool() == false && pFaces->asBool() == true); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "SHADING") ) { pParameters->Get_Parameter("SHADE_DEC" )->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("SHADE_AZI" )->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DRAW_EDGES") ) { pParameters->Get_Parameter("EDGE_COLOR_UNI" )->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "EDGE_COLOR_UNI") ) { pParameters->Get_Parameter("EDGE_COLOR" )->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DRAW_NODES") ) { pParameters->Get_Parameter("NODE_COLOR" )->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("NODE_SIZE" )->Set_Enabled(pParameter->asBool()); pParameters->Get_Parameter("NODE_SCALE" )->Set_Enabled(pParameter->asBool()); } return( CSG_3DView_Panel::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_TIN_Panel::Update_Statistics(void) { int Field = m_Parameters("COLORS_ATTR")->asInt(); m_Parameters("COLORS_RANGE")->asRange()->Set_Range( m_pTIN->Get_Mean(Field) - 1.5 * m_pTIN->Get_StdDev(Field), m_pTIN->Get_Mean(Field) + 1.5 * m_pTIN->Get_StdDev(Field) ); m_Data_Min.x = m_pTIN->Get_Extent().Get_XMin(); m_Data_Max.x = m_pTIN->Get_Extent().Get_XMax(); m_Data_Min.y = m_pTIN->Get_Extent().Get_YMin(); m_Data_Max.y = m_pTIN->Get_Extent().Get_YMax(); m_Data_Min.z = m_pTIN->Get_Minimum(m_Parameters("Z_ATTR")->asInt()); m_Data_Max.z = m_pTIN->Get_Maximum(m_Parameters("Z_ATTR")->asInt()); //----------------------------------------------------- Update_View(); } //--------------------------------------------------------- void C3D_Viewer_TIN_Panel::Update_Parent(void) { ((CSG_3DView_Dialog *)GetParent())->Update_Controls(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void C3D_Viewer_TIN_Panel::On_Key_Down(wxKeyEvent &event) { switch( event.GetKeyCode() ) { default: CSG_3DView_Panel::On_Key_Down(event); return; case WXK_F1: m_Parameters("Z_SCALE" )->Set_Value(m_Parameters("Z_SCALE" )->asDouble() - 0.5); break; case WXK_F2: m_Parameters("Z_SCALE" )->Set_Value(m_Parameters("Z_SCALE" )->asDouble() + 0.5); break; case WXK_F5: m_Parameters("SIZE" )->Set_Value(m_Parameters("SIZE" )->asDouble() - 1.0); break; case WXK_F6: m_Parameters("SIZE" )->Set_Value(m_Parameters("SIZE" )->asDouble() + 1.0); break; case WXK_F7: m_Parameters("SIZE_SCALE")->Set_Value(m_Parameters("SIZE_SCALE")->asDouble() - 10.0); break; case WXK_F8: m_Parameters("SIZE_SCALE")->Set_Value(m_Parameters("SIZE_SCALE")->asDouble() + 10.0); break; } //----------------------------------------------------- Update_View(); Update_Parent(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_TIN_Panel::On_Before_Draw(void) { if( m_Play_State == SG_3DVIEW_PLAY_STOP ) { m_Projector.Set_zScaling(m_Projector.Get_xScaling() * m_Parameters("Z_SCALE")->asDouble()); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int C3D_Viewer_TIN_Panel::Get_Color(double Value) { if( m_Color_Scale <= 0.0 ) { return( (int)Value ); } double c = m_Color_Scale * (Value - m_Color_Min); return( m_Color_bGrad ? m_Colors.Get_Interpolated(c) : m_Colors[(int)c] ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_TIN_Panel::On_Draw(void) { int zField = m_Parameters("Z_ATTR" )->asInt(); //----------------------------------------------------- int cField = m_Parameters("COLORS_ATTR")->asInt(); if( m_Parameters("COLORS_RANGE")->asRange()->Get_LoVal() >= m_Parameters("COLORS_RANGE")->asRange()->Get_HiVal() ) { m_Parameters("COLORS_RANGE")->asRange()->Set_Range( m_pTIN->Get_Mean(cField) - 1.5 * m_pTIN->Get_StdDev(cField), m_pTIN->Get_Mean(cField) + 1.5 * m_pTIN->Get_StdDev(cField) ); } m_Colors = *m_Parameters("COLORS")->asColors(); m_Color_bGrad = m_Parameters("COLORS_GRAD")->asBool(); m_Color_Min = m_Parameters("COLORS_RANGE")->asRange()->Get_LoVal(); m_Color_Scale = m_Colors.Get_Count() / (m_Parameters("COLORS_RANGE")->asRange()->Get_HiVal() - m_Color_Min); //----------------------------------------------------- if( m_Parameters("DRAW_FACES")->asBool() ) // Face { bool bDrape = m_Parameters("DO_DRAPE") && m_Parameters("DO_DRAPE")->asBool(); int Shading = m_Parameters("SHADING")->asInt(); double Shade_Dec = m_Parameters("SHADE_DEC")->asDouble() * -M_DEG_TO_RAD; double Shade_Azi = m_Parameters("SHADE_AZI")->asDouble() * M_DEG_TO_RAD; #pragma omp parallel for for(int iTriangle=0; iTriangleGet_Triangle_Count(); iTriangle++) { CSG_TIN_Triangle *pTriangle = m_pTIN->Get_Triangle(iTriangle); TSG_Triangle_Node p[3]; for(int i=0; i<3; i++) { CSG_TIN_Node *pNode = pTriangle->Get_Node(i); p[i].x = pNode->Get_Point().x; p[i].y = pNode->Get_Point().y; p[i].z = pNode->asDouble(zField); if( bDrape ) { p[i].c = pNode->Get_Point().x; p[i].d = pNode->Get_Point().y; } else { p[i].c = pNode->asDouble(cField); } m_Projector.Get_Projection(p[i].x, p[i].y, p[i].z); } //--------------------------------------------- switch( Shading ) { default: case 0: Draw_Triangle(p, false); break; case 1: Draw_Triangle(p, false, Shade_Dec, Shade_Azi); break; case 2: { double s, a; pTriangle->Get_Gradient(zField, s, a); Draw_Triangle(p, false, acos(sin(M_PI_090 - s) * sin(Shade_Dec) + cos(M_PI_090 - s) * cos(Shade_Dec) * cos(a - Shade_Azi)) / M_PI_090); } break; } } } //----------------------------------------------------- if( m_Parameters("DRAW_EDGES")->asBool() ) // Edges { bool bColor = m_Parameters("EDGE_COLOR_UNI")->asBool(); int Color = m_Parameters("EDGE_COLOR" )->asColor(); #pragma omp parallel for for(int iEdge=0; iEdgeGet_Edge_Count(); iEdge++) { CSG_TIN_Edge *pEdge = m_pTIN->Get_Edge(iEdge); TSG_Triangle_Node p[2]; for(int i=0; i<2; i++) { CSG_TIN_Node *pNode = pEdge->Get_Node(i); p[i].x = pNode->Get_Point().x; p[i].y = pNode->Get_Point().y; p[i].z = pNode->asDouble(zField); p[i].c = Get_Color(pNode->asDouble(cField)); m_Projector.Get_Projection(p[i].x, p[i].y, p[i].z); } //--------------------------------------------- if( bColor ) { Draw_Line(p[0].x, p[0].y, p[0].z, p[1].x, p[1].y, p[1].z, Color); } else { Draw_Line(p[0].x, p[0].y, p[0].z, p[1].x, p[1].y, p[1].z, p[0].c, p[1].c); } } } //------------------------------------------------- if( m_Parameters("DRAW_NODES")->asBool() ) // Nodes { int Color = m_Parameters("NODE_COLOR")->asColor (); int Size = m_Parameters("NODE_SIZE" )->asInt (); // double dSize = m_Parameters("NODE_SCALE")->asDouble(); // if( dSize > 1.0 ) // { // size = (int)(20.0 * exp(-dSize * z)); // } #pragma omp parallel for for(int iNode=0; iNodeGet_Node_Count(); iNode++) { CSG_TIN_Node *pNode = m_pTIN->Get_Node(iNode); TSG_Point_Z p; p.x = pNode->Get_Point().x; p.y = pNode->Get_Point().y; p.z = pNode->asDouble(zField); m_Projector.Get_Projection(p.x, p.y, p.z); Draw_Point(p.x, p.y, p.z, Color, Size); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_TIN_Dialog : public CSG_3DView_Dialog { public: C3D_Viewer_TIN_Dialog(CSG_TIN *pTIN, int Field_Z, int Field_Color, CSG_Grid *pDrape); virtual void Update_Controls (void); protected: wxChoice *m_pField_Z, *m_pField_C; // wxCheckBox *m_pFaces, *m_pEdges, *m_pNodes; virtual void On_Update_Choices (wxCommandEvent &event); // virtual void On_Update_Control (wxCommandEvent &event); virtual void Set_Menu (wxMenu &Menu); virtual void On_Menu (wxCommandEvent &event); virtual void On_Menu_UI (wxUpdateUIEvent &event); private: DECLARE_EVENT_TABLE() }; //--------------------------------------------------------- BEGIN_EVENT_TABLE(C3D_Viewer_TIN_Dialog, CSG_3DView_Dialog) EVT_CHOICE (wxID_ANY, C3D_Viewer_TIN_Dialog::On_Update_Choices) // EVT_CHECKBOX (wxID_ANY, C3D_Viewer_TIN_Dialog::On_Update_Control) END_EVENT_TABLE() //--------------------------------------------------------- C3D_Viewer_TIN_Dialog::C3D_Viewer_TIN_Dialog(CSG_TIN *pTIN, int Field_Z, int Field_Color, CSG_Grid *pDrape) : CSG_3DView_Dialog(_TL("TIN Viewer")) { Create(new C3D_Viewer_TIN_Panel(this, pTIN, Field_Z, Field_Color, pDrape)); wxArrayString Attributes; for(int i=0; iGet_Field_Count(); i++) { Attributes.Add(pTIN->Get_Field_Name(i)); } Add_Spacer(); m_pField_Z = Add_Choice (_TL("Elevation"), Attributes, Field_Z); m_pField_C = Add_Choice (_TL("Colour" ), Attributes, Field_Color); // Add_Spacer(); // m_pFaces = Add_CheckBox(_TL("Faces"), m_pPanel->m_Parameters("DRAW_FACES")->asBool()); // m_pEdges = Add_CheckBox(_TL("Edges"), m_pPanel->m_Parameters("DRAW_EDGES")->asBool()); // m_pNodes = Add_CheckBox(_TL("Nodes"), m_pPanel->m_Parameters("DRAW_NODES")->asBool()); } //--------------------------------------------------------- void C3D_Viewer_TIN_Dialog::On_Update_Choices(wxCommandEvent &event) { if( event.GetEventObject() == m_pField_Z ) { m_pPanel->m_Parameters("Z_ATTR")->Set_Value(m_pField_Z->GetSelection()); m_pPanel->Update_View(true); return; } if( event.GetEventObject() == m_pField_C ) { m_pPanel->m_Parameters("COLORS_ATTR")->Set_Value(m_pField_C->GetSelection()); m_pPanel->Update_View(true); return; } CSG_3DView_Dialog::On_Update_Choices(event); } //--------------------------------------------------------- //void C3D_Viewer_TIN_Dialog::On_Update_Control(wxCommandEvent &event) //{ // CHECKBOX_UPDATE(m_pFaces, "DRAW_FACES"); // CHECKBOX_UPDATE(m_pEdges, "DRAW_EDGES"); // CHECKBOX_UPDATE(m_pNodes, "DRAW_NODES"); // CSG_3DView_Dialog::On_Update_Control(event); //} //--------------------------------------------------------- void C3D_Viewer_TIN_Dialog::Update_Controls(void) { m_pField_Z->SetSelection(m_pPanel->m_Parameters("Z_ATTR" )->asInt()); m_pField_C->SetSelection(m_pPanel->m_Parameters("COLORS_ATTR")->asInt()); // m_pFaces->SetValue(m_pPanel->m_Parameters("DRAW_FACES")->asBool()); // m_pEdges->SetValue(m_pPanel->m_Parameters("DRAW_EDGES")->asBool()); // m_pNodes->SetValue(m_pPanel->m_Parameters("DRAW_NODES")->asBool()); CSG_3DView_Dialog::Update_Controls(); } //--------------------------------------------------------- enum { MENU_SCALE_Z_DEC = MENU_USER_FIRST, MENU_SCALE_Z_INC, MENU_COLORS_GRAD, MENU_SHADING, MENU_FACES, MENU_EDGES, MENU_NODES }; //--------------------------------------------------------- void C3D_Viewer_TIN_Dialog::Set_Menu(wxMenu &Menu) { wxMenu *pMenu = Menu.FindChildItem(Menu.FindItem(_TL("Display")))->GetSubMenu(); pMenu->AppendSeparator(); pMenu->Append(MENU_SCALE_Z_DEC, _TL("Decrease Exaggeration [F1]")); pMenu->Append(MENU_SCALE_Z_INC, _TL("Increase Exaggeration [F2]")); pMenu->AppendSeparator(); pMenu->AppendCheckItem(MENU_COLORS_GRAD, _TL("Graduated Colours")); Menu.AppendSeparator(); Menu.AppendCheckItem(MENU_SHADING, _TL("Shading")); Menu.AppendSeparator(); Menu.AppendCheckItem(MENU_FACES, _TL("Faces")); Menu.AppendCheckItem(MENU_EDGES, _TL("Edges")); Menu.AppendCheckItem(MENU_NODES, _TL("Nodes")); } //--------------------------------------------------------- void C3D_Viewer_TIN_Dialog::On_Menu(wxCommandEvent &event) { switch( event.GetId() ) { case MENU_SCALE_Z_DEC: m_pPanel->m_Parameters("Z_SCALE")->Set_Value(m_pPanel->m_Parameters("Z_SCALE")->asDouble() - 0.5); m_pPanel->Update_View(); return; case MENU_SCALE_Z_INC: m_pPanel->m_Parameters("Z_SCALE")->Set_Value(m_pPanel->m_Parameters("Z_SCALE")->asDouble() + 0.5); m_pPanel->Update_View(); return; case MENU_COLORS_GRAD: MENU_TOGGLE("COLORS_GRAD"); return; case MENU_SHADING : MENU_TOGGLE("SHADING" ); return; case MENU_FACES : MENU_TOGGLE("DRAW_FACES" ); return; case MENU_EDGES : MENU_TOGGLE("DRAW_EDGES" ); return; case MENU_NODES : MENU_TOGGLE("DRAW_NODES" ); return; } CSG_3DView_Dialog::On_Menu(event); } //--------------------------------------------------------- void C3D_Viewer_TIN_Dialog::On_Menu_UI(wxUpdateUIEvent &event) { switch( event.GetId() ) { case MENU_COLORS_GRAD: event.Check(m_pPanel->m_Parameters("COLORS_GRAD")->asBool()); return; case MENU_SHADING : event.Check(m_pPanel->m_Parameters("SHADING" )->asBool()); return; case MENU_FACES : event.Check(m_pPanel->m_Parameters("DRAW_FACES" )->asBool()); return; case MENU_EDGES : event.Check(m_pPanel->m_Parameters("DRAW_EDGES" )->asBool()); return; case MENU_NODES : event.Check(m_pPanel->m_Parameters("DRAW_NODES" )->asBool()); return; } CSG_3DView_Dialog::On_Menu_UI(event); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- C3D_Viewer_TIN::C3D_Viewer_TIN(void) { //----------------------------------------------------- Set_Name (_TL("TIN Viewer")); Set_Author ("O. Conrad (c) 2014"); Set_Description (_TW( "3D viewer for TIN." )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_TIN( NULL , "TIN" , _TL("TIN"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "HEIGHT" , _TL("Elevation"), _TL("") ); Parameters.Add_Table_Field( pNode , "COLOR" , _TL("Color"), _TL("") ); Parameters.Add_Grid( NULL , "DRAPE" , _TL("Map"), _TL("rgb coded raster map to be draped"), PARAMETER_INPUT_OPTIONAL ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool C3D_Viewer_TIN::On_Execute(void) { CSG_TIN *pTIN = Parameters("TIN")->asTIN(); if( !pTIN->is_Valid() ) { Error_Set(_TL("invalid input data")); return( false ); } C3D_Viewer_TIN_Dialog dlg(pTIN, Parameters("HEIGHT")->asInt(), Parameters("COLOR")->asInt(), Parameters("DRAPE")->asGrid()); dlg.ShowModal(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_3d_viewer/3d_viewer_multiple_grids.h0000744000175000017500000001057612737416156027663 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: 3d_viewer_multiple_grids.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // 3d_viewer_multiple_grids.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__3d_viewer_multiple_grids_H #define HEADER_INCLUDED__3d_viewer_multiple_grids_H /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class C3D_Viewer_Multiple_Grids : public CSG_Module { public: C3D_Viewer_Multiple_Grids(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__3d_viewer_multiple_grids_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_3d_viewer/MLB_Interface.h0000744000175000017500000000760412737416156025261 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pointcloud_viewer_mlb_H #define HEADER_INCLUDED__pointcloud_viewer_mlb_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef pointcloud_viewer_EXPORTS #define pointcloud_viewer_EXPORT _SAGA_DLL_EXPORT #else #define pointcloud_viewer_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pointcloud_viewer_mlb_H saga-2.3.1/src/modules/garden/garden_3d_viewer/MLB_Interface.cpp0000744000175000017500000001147712737416156025617 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // 3d_viewer // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute for Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("3D Viewer") ); case MLB_INFO_Category: return( _TL("Visualization") ); case MLB_INFO_Author: return( SG_T("O.Conrad (c) 2014") ); case MLB_INFO_Description: return( _TL("3D Viewer." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Visualization|3D Viewer" )); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "3d_viewer_tin.h" #include "3d_viewer_pointcloud.h" #include "3d_viewer_shapes.h" #include "3d_viewer_globe_grid.h" #include "3d_viewer_multiple_grids.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new C3D_Viewer_TIN ); case 1: return( new C3D_Viewer_PointCloud ); case 2: return( new C3D_Viewer_Shapes ); case 3: return( new C3D_Viewer_Globe_Grid ); case 4: return( new C3D_Viewer_Multiple_Grids ); default: return( NULL ); // default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/garden/garden_fractals/0000775000175000017500000000000012737740003022407 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/garden/garden_fractals/Gaussian_Landscapes.h0000744000175000017500000001070112737416157026477 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Gaussian_Landscapes.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Fractals // // // //-------------------------------------------------------// // // // Gaussian_Landscapes.h // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Gaussian_Landscapes_H #define HEADER_INCLUDED__Gaussian_Landscapes_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGaussian_Landscapes : public CSG_Module { public: CGaussian_Landscapes(void); virtual ~CGaussian_Landscapes(void); protected: virtual bool On_Execute (void); private: int m_Method; double m_M; CSG_Grid *m_pGrid; void Set_Value (int x, int y, double Value); void Set_Values (int x_0, int y_0, int x_1, int y_1, double z_00, double z_10, double z_11, double z_01, double s, double r); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Gaussian_Landscapes_H saga-2.3.1/src/modules/garden/garden_fractals/Mandelbrot.h0000744000175000017500000001137612737416157024670 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Mandelbrot.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Fractals // // // //-------------------------------------------------------// // // // Mandelbrot.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Mandelbrot_H #define HEADER_INCLUDED__Mandelbrot_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMandelbrot : public CSG_Module_Grid_Interactive { public: CMandelbrot(void); virtual ~CMandelbrot(void); protected: virtual bool On_Execute (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: int m_Method, m_maxIterations; double m_maxDistance, m_xJulia, m_yJulia; CSG_Point m_Down, m_Up; CSG_Rect m_Extent; CSG_Grid *m_pGrid; void Calculate (void); int Get_Mandelbrot (double xPos, double yPos); int Get_Julia (double xPos, double yPos); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Mandelbrot_H saga-2.3.1/src/modules/garden/garden_fractals/Grid_FractalDimension.cpp0000744000175000017500000001631712737416157027323 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_FractalDimension.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Fractals // // // //-------------------------------------------------------// // // // Grid_FractalDimension.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Grid_FractalDimension.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_FractalDimension::CGrid_FractalDimension(void) { Set_Name (_TL("Fractal Dimension of Grid Surface")); Set_Author (SG_T("O.Conrad (c) 2001")); Set_Description (_TW( "Calculates surface areas for increasing mesh sizes.") ); Parameters.Add_Grid (NULL, "INPUT" , _TL("Input") , _TL(""), PARAMETER_INPUT); Parameters.Add_Table(NULL, "RESULT", _TL("Result"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "DSIZE" , _TL("Scale" ), _TL(""), PARAMETER_TYPE_Double, 1.5, 1.0001, true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_FractalDimension::On_Execute(void) { double maxSize, dSize; CSG_Grid *pGrid; CSG_Table *pTable; //----------------------------------------------------- pGrid = Parameters("INPUT" )->asGrid(); pTable = Parameters("RESULT")->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("Fractal Dimension")); pTable->Add_Field(SG_T("CLASS" ), SG_DATATYPE_Int); pTable->Add_Field(SG_T("SCALE" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("BASAL" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("SURFACE"), SG_DATATYPE_Double); pTable->Add_Field(SG_T("RATIO" ), SG_DATATYPE_Double); pTable->Add_Field(SG_T("CHANGE" ), SG_DATATYPE_Double); //----------------------------------------------------- Get_Area(pGrid, pTable); maxSize = 0.5 * (pGrid->Get_XRange() > pGrid->Get_YRange() ? pGrid->Get_XRange() : pGrid->Get_YRange()); dSize = Parameters("DSIZE")->asDouble(); for(double Cellsize=dSize*pGrid->Get_Cellsize(); CellsizeGet_XMin(true), pGrid->Get_YMin(true), pGrid->Get_XMax(true), pGrid->Get_YMax(true) )); g.Assign(pGrid, GRID_RESAMPLING_BSpline); Get_Area(&g, pTable); Set_Show_Progress(true); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CGrid_FractalDimension::Get_Area(CSG_Grid *pGrid, CSG_Table *pTable) { double scale = pGrid->Get_Cellsize(); CSG_Grid g; if( !Get_System()->is_Equal(pGrid->Get_System()) ) { g.Create(*Get_System()); g.Assign(pGrid, GRID_RESAMPLING_BSpline); pGrid = &g; } double basal = 0.0; double surface = 0.0; for(int y=0; yGet_NY() && Process_Get_Okay(); y++) { for(int x=0; xGet_NX(); x++) { double s, a; if( pGrid->Get_Gradient(x, y, s, a) ) { basal += pGrid->Get_Cellarea(); surface += pGrid->Get_Cellarea() / cos(s); } } } //----------------------------------------------------- if( basal > 0.0 ) { CSG_Table_Record *pRecord = pTable->Add_Record(); pRecord->Set_Value(0, pTable->Get_Count()); // CLASS pRecord->Set_Value(1, scale); // SCALE pRecord->Set_Value(2, basal); // BASAL pRecord->Set_Value(3, surface); // SURFACE pRecord->Set_Value(4, surface / basal); // RATIO if( (pRecord = pTable->Get_Record(pTable->Get_Count() - 2)) != NULL ) { pRecord->Set_Value(5, pRecord->asDouble(3) - surface); // CHANGE } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_fractals/Newton.cpp0000744000175000017500000002077212737416157024406 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Newton.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // $$modul$$ // // // //-------------------------------------------------------// // // // Newton.cpp // // // // Copyright (C) 2003 Your Name // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: your@e-mail.abc // // // // contact: Your Name // // And Address // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #pragma warning(disable: 4275) #include "Newton.h" #include using namespace std; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CNewton::CNewton(void) { //----------------------------------------------------- // Place information about your module here... Set_Name(_TL("Newton-Raphson")); Set_Author(_TL("Copyrights (c) 2003 by Andre Ringeler")); Set_Description (_TW( "Newton-Raphson Fractals") ); //----------------------------------------------------- Parameters.Add_Grid_Output( NULL , "RESULT" , _TL("Result"), _TL("") ); Parameters.Add_Grid_Output( NULL , "SHADE" , _TL("Shade"), _TL("") ); Parameters.Add_Value( NULL , "NX" , _TL("Width (Cells)") , _TL(""), PARAMETER_TYPE_Int, 400, 1, true); Parameters.Add_Value( NULL , "NY" , _TL("Height (Cells)") , _TL(""), PARAMETER_TYPE_Int, 400, 1, true); Parameters.Add_Range( NULL , "XRANGE" , _TL("X-Range" ) , _TL(""), -2.0, 2.0); Parameters.Add_Range( NULL , "YRANGE" , _TL("Y-Range" ) , _TL(""), -2.0, 2.0); Parameters.Add_Choice( NULL , "METHOD" , _TL("Equation") , _TL(""), _TW("z^3-1|" "z^4-1|" "z^5-1|" "z^6-1|" "z^10 + 0.2 i * z^5 - 1|"), 0); //----------------------------------------------------- Parameters.Add_Value( NULL, "MAXITER" , _TL("Max Iterations") , _TL("Maximum Iterations") , PARAMETER_TYPE_Double , 50); } //--------------------------------------------------------- CNewton::~CNewton(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CNewton::On_Execute(void) { int x, y; x = Parameters("NX")->asInt(); xMin = Parameters("XRANGE")->asRange()->Get_LoVal(); dx = xMax = Parameters("XRANGE")->asRange()->Get_HiVal(); dx = (dx - xMin) / (x - 1.0); y = Parameters("NY")->asInt(); yMin = Parameters("YRANGE")->asRange()->Get_LoVal(); dy = yMax = Parameters("YRANGE")->asRange()->Get_HiVal(); dy = (dy - yMin) / (y - 1.0); method = Parameters("METHOD")->asInt(); pResult = SG_Create_Grid(SG_DATATYPE_Double, x, y, dx, xMin, yMin); pResult->Set_Name(_TL("Newton [A]")); Parameters("RESULT")->Set_Value(pResult); pShade = SG_Create_Grid(SG_DATATYPE_Double, x, y, dx, xMin, yMin); pShade->Set_Name(_TL("Newton [B]")); Parameters("SHADE") ->Set_Value(pShade); Get_System()->Assign(pShade->Get_System()); //----------------------------------------------------- iMax = Parameters("MAXITER")->asInt(); if( doNewton() ) { DataObject_Update(pResult, true); DataObject_Update(pShade , true); return( true ); } return( false ); } bool CNewton::doNewton() { int x, y, n; double i, r; complex z , old; for(y=0; y::real(double&)' // error: candidates are: double std::complex::real() const #ifdef _SAGA_VC z.real(r); z.imag(i); #endif for (n = 0 ;n< iMax; n++) { old = z; switch( method ) { case 0: default: z = z - ( z * z * z- 1.0 ) / (3.0 * z *z); break; case 1: z = z - ( z * z * z * z- 1.0 ) / (4.0 * z * z *z); break; case 2: z = z - (z * z * z * z * z- 1.0 ) / (5.0 * z * z * z *z); break; case 3: // "z^10 + 0.2 i * z^5 - 1", 0); { complex z5; z5= z*z; z5= z5 * z5; z5= z5*z; z =z - (z5*z - 1.0 ) / ( 6.0 * z5); break; } case 4: { complex z9 , z4, wert(0,0.2); z4 = z*z, z4= z4*z4; z9 = z4*z4*z; z = z -(z9*z + wert * z4*z -1.0 ) / (10.0 * z9 + 5.0 * wert * z4); } } if ( abs(old - z)< 0.05 ) break; } if(n < iMax ) pResult->Set_Value(x, y, z.real()); else pResult->Set_NoData(x,y); pShade->Set_Value(x,y, exp (-(double) ((n - iMax/2)*(n - iMax/2))/(double)(iMax*iMax)) ); } } //----------------------------------------------------- return( true ); } bool CNewton::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { //----------------------------------------------------- if( Mode != MODULE_INTERACTIVE_LDOWN && Mode != MODULE_INTERACTIVE_RDOWN ) { return( false ); } //----------------------------------------------------- int ok = true; int x= Get_xGrid(); int y = Get_yGrid(); double xpos, ypos; double deltax, deltay; xpos = (double ) x / Get_NX()*(xMax-xMin) + xMin; ypos = (double ) y / Get_NY()*(yMax-yMin) + yMin; deltax = (xMax-xMin); deltay = (yMax-yMin); if(Mode == MODULE_INTERACTIVE_LDOWN) { deltax/=4.0; deltay/=4.0; xMin = xpos - deltax; xMax = xpos + deltax; yMin = ypos - deltay; yMax = ypos + deltay; } if(Mode == MODULE_INTERACTIVE_RDOWN) { xMin = xpos - deltax; xMax = xpos + deltax; yMin = ypos - deltay; yMax = ypos + deltay; } doNewton(); DataObject_Update(pResult,pResult->Get_ZMin(), pResult->Get_ZMax()); DataObject_Update(pShade ,pShade ->Get_ZMin(), pShade ->Get_ZMax()); return true; } saga-2.3.1/src/modules/garden/garden_fractals/Mandelbrot.cpp0000744000175000017500000002325512737416157025222 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Mandelbrot.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Fractals // // // //-------------------------------------------------------// // // // Mandelbrot.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Mandelbrot.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMandelbrot::CMandelbrot(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("Mandelbrot Set")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (_TW( "Calculates Mandelbrot and Julia sets.\n\n" "References:\n" "- Mandelbrot, B.B. (1983): 'The Fractal Geometry of Nature', New York, 490p.\n") ); //----------------------------------------------------- // 2. Grids... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_Value( NULL , "NX" , _TL("Width (Cells)"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Value( NULL , "NY" , _TL("Height (Cells)"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Range( NULL , "XRANGE" , _TL("X-Range"), _TL(""), -2.0, 1.0 ); Parameters.Add_Range( NULL , "YRANGE" , _TL("Y-Range"), _TL(""), -1.5, 1.5 ); Parameters.Add_Value( NULL , "JULIA_X" , _TL("Julia - X"), _TL(""), PARAMETER_TYPE_Double, -0.7 ); Parameters.Add_Value( NULL , "JULIA_Y" , _TL("Julia - Y"), _TL(""), PARAMETER_TYPE_Double, 0.3 ); Parameters.Add_Value( NULL , "MAXITER" , _TL("Maximum Iterations"), _TL(""), PARAMETER_TYPE_Int, 300, 1, true ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Fractal Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Mandelbrot"), _TL("Julia") ), 0 ); } //--------------------------------------------------------- CMandelbrot::~CMandelbrot(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMandelbrot::On_Execute(void) { //----------------------------------------------------- m_Extent.Assign( Parameters("XRANGE")->asRange()->Get_LoVal(), Parameters("YRANGE")->asRange()->Get_LoVal(), Parameters("XRANGE")->asRange()->Get_HiVal(), Parameters("YRANGE")->asRange()->Get_HiVal() ); m_maxIterations = Parameters("MAXITER") ->asInt(); m_maxDistance = 4.0; m_Method = Parameters("METHOD") ->asInt(); m_xJulia = Parameters("JULIA_X") ->asDouble(); m_yJulia = Parameters("JULIA_Y") ->asDouble(); m_pGrid = SG_Create_Grid(SG_DATATYPE_Int, Parameters("NX")->asInt(), Parameters("NY")->asInt()); m_pGrid->Set_Name(m_Method == 0 ? _TL("Mandelbrot Set") : _TL("Julia Set")); Parameters("GRID")->Set_Value(m_pGrid); //----------------------------------------------------- Calculate(); //----------------------------------------------------- return( true ); } //--------------------------------------------------------- #define GET_POS(p) p.Assign(\ m_Extent.Get_XMin() + m_Extent.Get_XRange() * (ptWorld.Get_X() - m_pGrid->Get_XMin()) / m_pGrid->Get_XRange(),\ m_Extent.Get_YMin() + m_Extent.Get_YRange() * (ptWorld.Get_Y() - m_pGrid->Get_YMin()) / m_pGrid->Get_YRange()); #define SET_POS(a, b) if( a.Get_X() > b.Get_X() ) { d = a.Get_X(); a.Set_X(b.Get_X()); b.Set_X(d); }\ if( a.Get_Y() > b.Get_Y() ) { d = a.Get_Y(); a.Set_Y(b.Get_Y()); b.Set_Y(d); } //--------------------------------------------------------- bool CMandelbrot::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { double d; switch( Mode ) { default: break; case MODULE_INTERACTIVE_LDOWN: case MODULE_INTERACTIVE_RDOWN: GET_POS(m_Down); return( true ); case MODULE_INTERACTIVE_LUP: GET_POS(m_Up); SET_POS(m_Up, m_Down); if( m_Up.Get_X() >= m_Down.Get_X() || m_Up.Get_Y() >= m_Down.Get_Y() ) { m_Extent.Inflate(50.0); m_Extent.Move(m_Up - m_Extent.Get_Center()); } else { m_Extent.Assign(m_Up, m_Down); } Calculate(); return( true ); case MODULE_INTERACTIVE_RUP: GET_POS(m_Up); SET_POS(m_Up, m_Down); if( m_Up.Get_X() >= m_Down.Get_X() || m_Up.Get_Y() >= m_Down.Get_Y() ) { m_Extent.Deflate(50.0); m_Extent.Move(m_Up - m_Extent.Get_Center()); } else { m_Extent.Deflate(100.0 * (m_Down.Get_X() - m_Up.Get_X()) / m_Extent.Get_XRange()); m_Extent.Move(m_Up - m_Extent.Get_Center()); } Calculate(); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CMandelbrot::Calculate(void) { int x, y, i; double xPos, yPos, dx, dy; dx = m_Extent.Get_XRange() / (m_pGrid->Get_NX() - 1.0); dy = m_Extent.Get_YRange() / (m_pGrid->Get_NY() - 1.0); for(y=0, yPos=m_Extent.Get_YMin(); yGet_NY() && Set_Progress(y, m_pGrid->Get_NY()); y++, yPos+=dy) { for(x=0, xPos=m_Extent.Get_XMin(); xGet_NX(); x++, xPos+=dx) { switch( m_Method ) { default: case 0: i = Get_Mandelbrot (xPos, yPos); break; case 1: i = Get_Julia (xPos, yPos); break; } if( i >= m_maxIterations ) { m_pGrid->Set_NoData(x, y); } else { m_pGrid->Set_Value(x, y, i); } } } DataObject_Update(m_pGrid, true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CMandelbrot::Get_Mandelbrot(double xPos, double yPos) { int i; double x, y, k; for(i=0, x=0.0, y=0.0; i&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/garden/garden_fractals ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libgarden_fractals_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libgarden_fractals_la_OBJECTS = Bifurcation.lo \ Gaussian_Landscapes.lo Grid_FractalDimension.lo Mandelbrot.lo \ MLB_Interface.lo Newton.lo Pythagoras_Tree.lo libgarden_fractals_la_OBJECTS = $(am_libgarden_fractals_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libgarden_fractals_la_SOURCES) DIST_SOURCES = $(libgarden_fractals_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libgarden_fractals.la libgarden_fractals_la_SOURCES = \ Bifurcation.cpp\ Gaussian_Landscapes.cpp\ Grid_FractalDimension.cpp\ Mandelbrot.cpp\ MLB_Interface.cpp\ Newton.cpp\ Pythagoras_Tree.cpp\ Bifurcation.h\ Gaussian_Landscapes.h\ Grid_FractalDimension.h\ Mandelbrot.h\ MLB_Interface.h\ Newton.h\ Pythagoras_Tree.h libgarden_fractals_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/garden/garden_fractals/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/garden/garden_fractals/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libgarden_fractals.la: $(libgarden_fractals_la_OBJECTS) $(libgarden_fractals_la_DEPENDENCIES) $(EXTRA_libgarden_fractals_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libgarden_fractals_la_OBJECTS) $(libgarden_fractals_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Bifurcation.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Gaussian_Landscapes.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Grid_FractalDimension.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mandelbrot.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Newton.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Pythagoras_Tree.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/garden/garden_fractals/Pythagoras_Tree.h0000744000175000017500000001050112737416157025666 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Pythagoras_Tree.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Fractals // // // //-------------------------------------------------------// // // // Pythagoras_Tree.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Pythagoras_Tree_H #define HEADER_INCLUDED__Pythagoras_Tree_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPythagoras_Tree : public CSG_Module { public: CPythagoras_Tree(void); virtual ~CPythagoras_Tree(void); protected: virtual bool On_Execute(void); private: int Iteration, Method; double Min_Size, Size, sin_Angle, cos_Angle, var_Min, var_Range, var_Angle; CSG_Shapes *pShapes; void Set_Quadrat (TSG_Point pt_A, TSG_Point pt_B); void Add_Shape (TSG_Point pt_A, TSG_Point pt_B, TSG_Point pt_C, TSG_Point pt_D); void Add_Shape (TSG_Point pt_A, TSG_Point pt_B, TSG_Point pt_C); }; #endif // #ifndef HEADER_INCLUDED__Pythagoras_Tree_H saga-2.3.1/src/modules/garden/garden_fractals/Makefile.am0000744000175000017500000000141212737416157024452 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libgarden_fractals.la libgarden_fractals_la_SOURCES =\ Bifurcation.cpp\ Gaussian_Landscapes.cpp\ Grid_FractalDimension.cpp\ Mandelbrot.cpp\ MLB_Interface.cpp\ Newton.cpp\ Pythagoras_Tree.cpp\ Bifurcation.h\ Gaussian_Landscapes.h\ Grid_FractalDimension.h\ Mandelbrot.h\ MLB_Interface.h\ Newton.h\ Pythagoras_Tree.h libgarden_fractals_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/garden/garden_fractals/Pythagoras_Tree.cpp0000744000175000017500000002153012737416157026225 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Pythagoras_Tree.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Fractals // // // //-------------------------------------------------------// // // // Pythagoras_Tree.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Pythagoras_Tree.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPythagoras_Tree::CPythagoras_Tree(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name(_TL("Pythagoras' Tree")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (_TW("Pythagoras' Tree.")); //----------------------------------------------------- // 2. Grids... pNode = Parameters.Add_Shapes( NULL , "RESULT" , _TL("Pythagoras' Tree"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( pNode , "TYPE" , _TL("Shape Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Lines"), _TL("Polygons") ), 1 ); Parameters.Add_Value( NULL , "ANGLE" , _TL("Angle [Degree]"), _TL(""), PARAMETER_TYPE_Double , 55.0, 0.0, true, 90.0, true ); Parameters.Add_Value( NULL , "MINSIZE" , _TL("Minimum Size [%]"), _TL(""), PARAMETER_TYPE_Double , 2.0, 0.001, true, 100.0, true ); pNode = Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Fixed angle"), _TL("Constant variation range"), _TL("Low variation for low sizes"), _TL("High variation for low sizes") ), 0 ); Parameters.Add_Range( pNode , "VARRANGE" , _TL("Constant Variation Range [Degree]"), _TL(""), 0.0, 90.0, 0.0, true, 90.0, true ); } //--------------------------------------------------------- CPythagoras_Tree::~CPythagoras_Tree(void) {} /////////////////////////////////////////////////////////// // // // Run // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPythagoras_Tree::On_Execute(void) { TSG_Point pt_A, pt_B; pShapes = Parameters("RESULT") ->asShapes(); pShapes->Create(Parameters("TYPE")->asInt() == 0 ? SHAPE_TYPE_Line : SHAPE_TYPE_Polygon, _TL("Pythagoras' Tree")); pShapes->Add_Field(_TL("Iteration") , SG_DATATYPE_Int); pShapes->Add_Field(_TL("Size") , SG_DATATYPE_Double); Min_Size = Parameters("MINSIZE") ->asDouble() / 100.0; switch( (Method = Parameters("METHOD")->asInt()) ) { case 0: // Standard... sin_Angle = sin(Parameters("ANGLE")->asDouble() * M_DEG_TO_RAD); cos_Angle = cos(Parameters("ANGLE")->asDouble() * M_DEG_TO_RAD); break; case 1: // Variation Range... var_Min = Parameters("VARRANGE")->asRange()->Get_LoVal() * M_DEG_TO_RAD; var_Range = Parameters("VARRANGE")->asRange()->Get_HiVal() * M_DEG_TO_RAD; var_Range = (var_Range - var_Min) / (double)RAND_MAX; break; } srand((unsigned)time(NULL)); Iteration = 0; pt_A.x = 0.0; pt_B.x = 1.0; pt_A.y = pt_B.y = 0.0; Set_Quadrat(pt_A, pt_B); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPythagoras_Tree::Set_Quadrat(TSG_Point pt_A0, TSG_Point pt_B0) { double dx, dy; TSG_Point pt_A1, pt_B1; if( Process_Get_Okay(false) ) { Iteration++; dx = pt_B0.x - pt_A0.x; dy = pt_B0.y - pt_A0.y; Size = sqrt(dx*dx + dy*dy); pt_A1.x = pt_A0.x - dy; pt_A1.y = pt_A0.y + dx; pt_B1.x = pt_B0.x - dy; pt_B1.y = pt_B0.y + dx; Add_Shape(pt_A0, pt_B0, pt_B1, pt_A1); if( Size > Min_Size ) { switch( Method ) { case 1: // Variation Range... var_Angle = var_Min + (double)rand() * var_Range; sin_Angle = sin(var_Angle); cos_Angle = cos(var_Angle); break; case 2: // High Variation for low sizes... var_Range = Size * M_PI_090; var_Angle = (M_PI_045 - var_Range / 2.0) + (double)rand() * var_Range / (double)RAND_MAX; sin_Angle = sin(var_Angle); cos_Angle = cos(var_Angle); break; case 3: // Low Variation for low sizes... var_Range = (1.0 - Size) * M_PI_090; var_Angle = (M_PI_045 - var_Range / 2.0) + (double)rand() * var_Range / (double)RAND_MAX; sin_Angle = sin(var_Angle); cos_Angle = cos(var_Angle); break; } pt_A0.x = pt_A1.x + cos_Angle * (cos_Angle * dx - sin_Angle * dy); pt_A0.y = pt_A1.y + cos_Angle * (sin_Angle * dx + cos_Angle * dy); Add_Shape(pt_A1, pt_B1, pt_A0); Set_Quadrat(pt_A1, pt_A0); Set_Quadrat(pt_A0, pt_B1); } Iteration--; } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CPythagoras_Tree::Add_Shape(TSG_Point pt_A, TSG_Point pt_B, TSG_Point pt_C, TSG_Point pt_D) { CSG_Shape *pShape; pShape = pShapes->Add_Shape(); pShape->Set_Value(0, Iteration); pShape->Set_Value(1, Size); pShape->Add_Point(pt_A); pShape->Add_Point(pt_B); pShape->Add_Point(pt_C); pShape->Add_Point(pt_D); if( pShapes->Get_Type() == SHAPE_TYPE_Line ) { pShape->Add_Point(pt_A); } } //--------------------------------------------------------- void CPythagoras_Tree::Add_Shape(TSG_Point pt_A, TSG_Point pt_B, TSG_Point pt_C) { CSG_Shape *pShape; pShape = pShapes->Add_Shape(); pShape->Set_Value(0, Iteration); pShape->Set_Value(1, Size); pShape->Add_Point(pt_A); pShape->Add_Point(pt_B); pShape->Add_Point(pt_C); if( pShapes->Get_Type() == SHAPE_TYPE_Line ) { pShape->Add_Point(pt_A); } } saga-2.3.1/src/modules/garden/garden_fractals/Grid_FractalDimension.h0000744000175000017500000001052512737416157026763 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_FractalDimension.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Fractals // // // //-------------------------------------------------------// // // // Grid_FractalDimension.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GC_MEASUREFRACTDIM_H #define HEADER_INCLUDED__GC_MEASUREFRACTDIM_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_FractalDimension : public CSG_Module_Grid { public: CGrid_FractalDimension(void); protected: virtual bool On_Execute (void); private: void Get_Area (CSG_Grid *pGrid, CSG_Table *pTable); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GC_MEASUREFRACTDIM_H saga-2.3.1/src/modules/garden/garden_fractals/Gaussian_Landscapes.cpp0000744000175000017500000002001612737416157027032 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Gaussian_Landscapes.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Fractals // // // //-------------------------------------------------------// // // // Gaussian_Landscapes.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Gaussian_Landscapes.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define RANDOM(x) (rand() % x) #define RANDOMIZE() (srand((unsigned int)time(NULL))) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGaussian_Landscapes::CGaussian_Landscapes(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("Gaussian Landscapes")); Set_Author (SG_T("(c) 2005 by O.Conrad")); Set_Description (_TW( "Generates Gaussian landscapes.\n\n" "References:\n" "- Halling, H., Moeller, R. (1995): 'Mathematik fuers Auge', Heidelberg, 144p.\n" "- Mandelbrot, B.B. (1983): 'The Fractal Geometry of Nature', New York, 490p.\n") ); //----------------------------------------------------- // 2. Grids... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_Value( NULL , "NX" , _TL("Width (Cells)"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Value( NULL , "NY" , _TL("Height (Cells)"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Value( NULL , "H" , _TL("Roughness/Smoothness"), _TL(""), PARAMETER_TYPE_Double, 0.75, 0.0, true, 1.0, true ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Simple"), _TL("Flattening") ), 0 ); Parameters.Add_Value( NULL , "M" , _TL("Flattening"), _TL(""), PARAMETER_TYPE_Double, 2.0 ); } //--------------------------------------------------------- CGaussian_Landscapes::~CGaussian_Landscapes(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGaussian_Landscapes::On_Execute(void) { int nx, ny, n; double h, s, r; //----------------------------------------------------- nx = Parameters("NX")->asInt(); ny = Parameters("NY")->asInt(); m_pGrid = SG_Create_Grid(SG_DATATYPE_Float, nx, ny, 1.0, 0.0, 0.0); m_pGrid->Set_Name(_TL("Gaussian Landscape")); m_pGrid->Assign_NoData(); Parameters("GRID")->Set_Value(m_pGrid); m_Method = Parameters("METHOD") ->asInt(); m_M = Parameters("M") ->asDouble(); //----------------------------------------------------- nx = nx > ny ? nx : ny; ny = 1; do { n = (int)pow(2.0, ny++); } while( n < nx ); h = Parameters("H") ->asDouble(); r = 1.0 / pow(2.0, h); s = n * r; //----------------------------------------------------- Set_Values(0, 0, n, n, 0.0, 0.0, 0.0, 0.0, s, r); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CGaussian_Landscapes::Set_Value(int x, int y, double Value) { if( m_pGrid->is_InGrid(x, y, false) ) { switch( m_Method ) { case 0: default: m_pGrid->Set_Value(x, y, Value); break; case 1: m_pGrid->Set_Value(x, y, pow(Value, m_M)); break; } } } //--------------------------------------------------------- void CGaussian_Landscapes::Set_Values(int x_0, int y_0, int x_1, int y_1, double z_00, double z_10, double z_11, double z_01, double s, double r) { int x_n, y_n; double z_n, z_n1, z_n2, z_n3, z_n4; //----------------------------------------------------- x_n = (x_0 + x_1) / 2; y_n = (y_0 + y_1) / 2; z_n = (z_00 + z_10 + z_11 + z_01) / 4.0 + s * (double)(RANDOM(17) - 8) / 8.0; Set_Value(x_n, y_n, z_n); //----------------------------------------------------- if( x_0 != x_n && x_n != x_1 ) { z_n1 = (z_00 + z_10) / 2.0; z_n2 = (z_10 + z_11) / 2.0; z_n3 = (z_11 + z_01) / 2.0; z_n4 = (z_01 + z_00) / 2.0; s *= r; Set_Values(x_n, y_0, x_1, y_n, z_n1, z_10, z_n2, z_n , s, r); Set_Values(x_0, y_0, x_n, y_n, z_00, z_n1, z_n , z_n4, s, r); Set_Values(x_n, y_n, x_1, y_1, z_n , z_n2, z_11, z_n3, s, r); Set_Values(x_0, y_n, x_n, y_1, z_n4, z_n , z_n3, z_01, s, r); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_fractals/MLB_Interface.h0000744000175000017500000000743212737416157025171 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // garden_fractals // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__garden_fractals_H #define HEADER_INCLUDED__garden_fractals_H //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__garden_fractals_H saga-2.3.1/src/modules/garden/garden_fractals/Bifurcation.cpp0000744000175000017500000001332312737416157025373 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Bifurcation.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Fractals // // // //-------------------------------------------------------// // // // Bifurcation.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Bifurcation.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CBifurcation::CBifurcation(void) { Set_Name(_TL("Bifurcation")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW("Feigenbaum's Bifurcation")); Parameters.Add_Table( NULL, "TABLE" , _TL("Output") , _TL(""), PARAMETER_OUTPUT); Parameters.Add_Value( NULL, "ITERATIONS" , _TL("Value Count") , _TL(""), PARAMETER_TYPE_Int, 100); Parameters.Add_Value( NULL, "NVALUES" , _TL("Value Count") , _TL("Number of the last x Iteration to be plotted."), PARAMETER_TYPE_Int, 8); Parameters.Add_Value( NULL, "SEED" , _TL("Seed Value") , _TL(""), PARAMETER_TYPE_Double , 0.66, 0, true, 1.0, true); Parameters.Add_Range( NULL, "RANGE" , _TL("Range") , _TL(""), 1.0, 4.0, 0.0, true, 4.0, true); Parameters.Add_Value( NULL, "STEP" , _TL("Number of Steps") , _TL(""), PARAMETER_TYPE_Int , 1000, 2, true); } //--------------------------------------------------------- CBifurcation::~CBifurcation(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CBifurcation::On_Execute(void) { int i; double p, r, dr, max, min, seed, nValues, nPreIterations; CSG_Table_Record *pRecord; CSG_Table *pTable; nPreIterations = Parameters("ITERATIONS")->asInt(); nValues = Parameters("NVALUES")->asInt(); seed = Parameters("SEED")->asDouble(); min = Parameters("RANGE")->asRange()->Get_LoVal(); max = Parameters("RANGE")->asRange()->Get_HiVal(); dr = (max - min) / 1000.0; pTable = Parameters("TABLE")->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("Feigenbaum's Bifurcation")); pTable->Add_Field("Growth" , SG_DATATYPE_Double); for(i=0; iAdd_Field(CSG_String::Format(SG_T("VALUE_%d"), i + 1), SG_DATATYPE_Double); } for(r=min; r<=max; r+=dr) { pRecord = pTable->Add_Record(); pRecord->Set_Value(0, r); p = seed; for(i=0; iSet_Value(i + 1, p); } } return( true ); } saga-2.3.1/src/modules/garden/garden_fractals/Newton.h0000744000175000017500000000753012737416157024050 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Newton.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // $$modul$$ // // // //-------------------------------------------------------// // // // Newton.h // // // // Copyright (C) 2003 Your Name // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: your@e-mail.abc // // // // contact: Your Name // // And Address // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Newton_H #define HEADER_INCLUDED__Newton_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CNewton : public CSG_Module_Grid_Interactive { public: CNewton(void); virtual ~CNewton(void); bool doNewton(); protected: virtual bool On_Execute(void); virtual bool On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: double xMin, xMax, yMin, yMax; int iMax, method; double dx, dy; CSG_Grid *pResult, *pShade; }; #endif // #ifndef HEADER_INCLUDED__Newton_H saga-2.3.1/src/modules/garden/garden_fractals/MLB_Interface.cpp0000744000175000017500000001234212737416157025520 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Fractals // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Fractals") ); case MLB_INFO_Category: return( _TL("Garden") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2002") ); case MLB_INFO_Description: return( _TL("Fractals") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Garden|Recreations|Fractals") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Bifurcation.h" #include "Grid_FractalDimension.h" #include "Mandelbrot.h" #include "Pythagoras_Tree.h" #include "Newton.h" #include "Gaussian_Landscapes.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { // Don't forget to continuously enumerate the case switches // when adding new modules! Also bear in mind that the // enumeration always has to start with [case 0:] and // that [default:] must return NULL!... CSG_Module *pModule; switch( i ) { case 0: pModule = new CBifurcation; break; case 1: pModule = new CPythagoras_Tree; break; case 2: pModule = new CMandelbrot; break; case 3: pModule = new CGrid_FractalDimension; break; case 4: pModule = new CNewton; break; case 5: pModule = new CGaussian_Landscapes; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/garden/garden_games/0000775000175000017500000000000012737740003021704 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/garden/garden_games/Mine_Sweeper.h0000744000175000017500000001062412737416157024453 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Mine_Sweeper.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // Mine_Sweeper // // // //-------------------------------------------------------// // // // Mine_Sweeper.h // // // // Copyright (C) 2003 by Andre Ringeler // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: your@e-mail.abc // // // // contact: Your Name // // And Address // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Mine_Sweeper_H #define HEADER_INCLUDED__Mine_Sweeper_H //--------------------------------------------------------- #include "MLB_Interface.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTimer { public: CTimer(void); ~CTimer(void); int Time(void); protected: time_t starttime; }; class CMine_Sweeper : public CSG_Module_Interactive { public: CMine_Sweeper(void); virtual ~CMine_Sweeper(void); CSG_Grid *pInput; protected: virtual bool On_Execute(void); virtual bool On_Execute_Finish (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); bool Get_Grid_Pos(int &x, int &y); void SetSprite(int xpos, int ypos, int nr); bool MakeBoard(int level); void Make_GameBoard(int xpos,int ypos); void Show_GameBoard(bool ShowMines); int Get_Number_of_Bombs(int xpos, int ypos); bool Play(int xpos, int ypos,bool computer_move); void Mark(int xpos, int ypos); void ResetBoard(int xpos, int ypos); int Mine_NX,Mine_NY, N_Mines; int OpenFields, MarkedMines; CSG_Grid *GameBoard, *FlagBoard; bool First_Click; CTimer *Time; private: }; #endif // #ifndef HEADER_INCLUDED__Mine_Sweeper_H saga-2.3.1/src/modules/garden/garden_games/Sudoku.h0000744000175000017500000000777212737416157023355 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Sudoku.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // Sudoku // // // //-------------------------------------------------------// // // // Sudoku.h // // // // Copyright (C) 2006 by Victor Olaya // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: your@e-mail.abc // // // // contact: Your Name // // And Address // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Sudoku_H #define HEADER_INCLUDED__Sudoku_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// class CSudoku : public CSG_Module_Grid_Interactive { public: CSudoku(void); virtual ~CSudoku(void); protected: virtual bool On_Execute (void); virtual bool On_Execute_Finish (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: bool **m_pFixedCells; int **m_pSudoku; CSG_Grid *m_pBoard; bool Get_Grid_Pos (int &x, int &y); void DrawBoard(); void DrawCell(int iXCell, int iYCell, bool *pIsPossible); void CreateSudoku(); void DrawSquare(int iX, int iY, int iColor, int iSize); void GetPossibleValues(int iX, int iY, bool *pIsPossible); }; #endif // #ifndef HEADER_INCLUDED__Sudoku_H saga-2.3.1/src/modules/garden/garden_games/Mine_Sweeper.cpp0000744000175000017500000003004712737416157025007 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Mine_Sweeper.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // Mine_Sweeper // // // //-------------------------------------------------------// // // // Mine_Sweeper.cpp // // // // Copyright (C) 2003 Andre Ringeler // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: aringel@gwdg.de // // // // contact: Andre Ringeler // // // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Mine_Sweeper.h" /////////////////////////////////////////////////////////// // // // Import Resourcen // // // /////////////////////////////////////////////////////////// extern unsigned char mine_res[]; extern unsigned char mine_res_color[]; extern unsigned int SPRITE_SIZE; /////////////////////////////////////////////////////////// // // // Defines // // // /////////////////////////////////////////////////////////// #define FLAG 1 #define QUESTION 2 #define isBomb 1 #define isOpen 8 #define isBumm 16 #define SPRITE_CLOSE 0 #define SPRITE_FLAG 1 #define SPRITE_QUESTION 2 #define SPRITE_BOMB_BUMM 3 #define SPRITE_BOMB_NO 4 #define SPRITE_BOMB 5 #define SPRITE_OPEN 15 #define SPRITE_NUMMER(x) (15-x) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMine_Sweeper::CMine_Sweeper(void) { Set_Name (_TL("Mine Sweeper")); Set_Author (_TL("Copyrights (c) 2003 by Andre Ringeler")); Set_Description (_TW( "A Mine Sweeper Clone\n" "(created by Andre Ringeler).") ); Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_Choice( NULL ,"LEVEL" ,_TL("Level"), _TL("Game Level"), _TW( "Beginer|" "Advanced|" "Profi|") ,1 ); } //--------------------------------------------------------- CMine_Sweeper::~CMine_Sweeper(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMine_Sweeper::MakeBoard(int level) { int i, x, y; CSG_Colors Colors; switch( level ) { case 0: Mine_NX = 8; Mine_NY = 8; N_Mines=10; break; case 1: Mine_NX = 16; Mine_NY = 16; N_Mines=40; break; case 2: Mine_NX = 30; Mine_NY = 16; N_Mines=99; break; } pInput = SG_Create_Grid(SG_DATATYPE_Int,SPRITE_SIZE*Mine_NX, SPRITE_SIZE*Mine_NY); pInput->Set_Name(_TL("Mine Sweeper")); Parameters("GRID")->Set_Value(pInput); //----------------------------------------------------- CSG_Parameter *pLUT = DataObject_Get_Parameter(pInput, "LUT"); if( pLUT && pLUT->asTable() ) { pLUT->asTable()->Del_Records(); for(i=0; i<16; i++) { CSG_Table_Record *pRecord = pLUT->asTable()->Add_Record(); pRecord->Set_Value(0, SG_GET_RGB(mine_res_color[i*3], mine_res_color[i*3+1], mine_res_color[i*3+2])); pRecord->Set_Value(3, i); } DataObject_Set_Parameter(pInput, pLUT); DataObject_Set_Parameter(pInput, "COLORS_TYPE", 1); // Color Classification Type: Lookup Table } Colors.Set_Count(16); for ( i=0;i<16; i++) { Colors.Set_Color(i, SG_GET_RGB(mine_res_color[i*3], mine_res_color[i*3+1], mine_res_color[i*3+2])); } DataObject_Set_Colors(pInput, Colors); DataObject_Update(pInput, 0.0, 15.0, true); //----------------------------------------------------- for( y = 0; y < Mine_NY; y++) for( x = 0; x < Mine_NX; x++) { SetSprite(x,y,SPRITE_CLOSE); } pInput->Set_Value(0, 0); return true; } bool CMine_Sweeper::On_Execute(void) { MakeBoard(Parameters("LEVEL")->asInt()); GameBoard = (CSG_Grid *) new CSG_Grid(SG_DATATYPE_Int,Mine_NX,Mine_NY); FlagBoard = (CSG_Grid *) new CSG_Grid(SG_DATATYPE_Int,Mine_NX,Mine_NY); First_Click = true; Time = NULL; return( true ); } bool CMine_Sweeper::On_Execute_Finish(void) { delete GameBoard; delete FlagBoard; if (Time) delete Time; return true; } void CMine_Sweeper::ResetBoard(int xpos, int ypos) { OpenFields = 0; MarkedMines = 0; FlagBoard->Assign(); GameBoard->Assign(); if(Time) delete Time; Make_GameBoard( xpos , ypos); Time = new CTimer(); } //--------------------------------------------------------- bool CMine_Sweeper::Get_Grid_Pos(int &x, int &y) { bool bResult; if( pInput && pInput->is_Valid() ) { bResult = true; //------------------------------------------------- x = (int)(0.5 + (Get_xPosition() - pInput->Get_XMin()) / pInput->Get_Cellsize()); if( x < 0 ) { bResult = false; x = 0; } else if( x >= pInput->Get_NX() ) { bResult = false; x = pInput->Get_NX() - 1; } //------------------------------------------------- y = (int)(0.5 + (Get_yPosition() - pInput->Get_YMin()) / pInput->Get_Cellsize()); if( y < 0 ) { bResult = false; y = 0; } else if( y >= pInput->Get_NY() ) { bResult = false; y = pInput->Get_NY() - 1; } return( bResult ); } //----------------------------------------------------- x = 0; y = 0; return( false ); } bool CMine_Sweeper::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { int ok = true; int time; int redraw = false; int xpos; int ypos; if( !Get_Grid_Pos(xpos, ypos) ) return( false ); xpos/=SPRITE_SIZE; ypos/=SPRITE_SIZE; ypos=Mine_NY-1-ypos; switch( Mode ) { default: return( false ); case MODULE_INTERACTIVE_LDOWN: if(First_Click) { ResetBoard(xpos, ypos); First_Click=false; } ok = Play(xpos, ypos, false); redraw = true; break; case MODULE_INTERACTIVE_RDOWN: Mark(xpos, ypos); redraw = true; break; } if (redraw) { if(ok) { Show_GameBoard(false); time= Time->Time(); Message_Add(CSG_String::Format(SG_T(":-) Time:%ds Mines:%d\n"),time,N_Mines-MarkedMines)); if (OpenFields == Mine_NX*Mine_NY-N_Mines ) { Message_Add(CSG_String::Format(_TL(":-) :-) you are a winner :-) :-) Time:%ds\n"),time)); Message_Dlg(CSG_String::Format(_TL(":-) :-) you are a winner :-) :-) Time:%ds\n"),time)); Show_GameBoard(true); First_Click=true; } } else { Show_GameBoard(true); Message_Dlg(CSG_String::Format(_TL(":-( :-( you are a loser :-( :-("))); Message_Add(CSG_String::Format(_TL(":-( :-( you are a loser :-( :-("))); First_Click=true; } } return true; } void CMine_Sweeper::Make_GameBoard(int xpos,int ypos) { int mines = 0; srand( (unsigned)time( NULL ) ); while(mines < N_Mines) { int mx,my; mx = rand()%Mine_NX; my = rand()%Mine_NY; if( !(GameBoard->asInt(mx, my) & isBomb) && !((mx==xpos)&&(my==ypos)) ) { GameBoard->Set_Value(mx,my,isBomb); mines ++; } } } void CMine_Sweeper::Show_GameBoard(bool ShowMines) { int x,y; if (ShowMines) { for( y = 0; y < Mine_NY; y++) for( x = 0; x < Mine_NX; x++) { if(GameBoard->asInt(x, y) & isBomb) { if (FlagBoard->asInt(x,y) == FLAG) SetSprite(x,y,SPRITE_FLAG); else SetSprite(x,y,SPRITE_BOMB); } else { if (GameBoard->asInt(x, y) == isOpen ) SetSprite(x,y,SPRITE_NUMMER(Get_Number_of_Bombs(x,y))); else SetSprite(x,y,SPRITE_CLOSE); } if (GameBoard->asInt(x, y) & isBumm) SetSprite(x,y,SPRITE_BOMB_BUMM); if ( !(GameBoard->asInt(x, y) & isBomb) && (FlagBoard->asInt(x,y) == FLAG)) SetSprite(x,y,SPRITE_BOMB_NO); } } else for( y = 0; y < Mine_NY; y++) for( x = 0; x < Mine_NX; x++) { if(GameBoard->asInt(x, y) == isOpen) { SetSprite(x,y,SPRITE_NUMMER(Get_Number_of_Bombs(x,y))); } else { if(FlagBoard->asInt(x,y)) SetSprite(x,y,FlagBoard->asInt(x,y)); else SetSprite(x,y,SPRITE_CLOSE); } } DataObject_Update(pInput, 0.0, 15.0); } void CMine_Sweeper::SetSprite(int xpos, int ypos, int nr) { unsigned int x,y; for(y=0;ySet_Value( xpos * SPRITE_SIZE + x, pInput->Get_NY() - ypos * SPRITE_SIZE - y -1, (double)mine_res[ y * SPRITE_SIZE + x + nr * SPRITE_SIZE * SPRITE_SIZE]); } int CMine_Sweeper::Get_Number_of_Bombs(int xpos, int ypos) { int i; int number = 0; for( i = 0; i<8; i++) if (GameBoard->is_InGrid(pInput->Get_System().Get_xTo(i,xpos),pInput->Get_System().Get_yTo(i,ypos))) if (GameBoard->asInt(pInput->Get_System().Get_xTo(i,xpos),pInput->Get_System().Get_yTo(i,ypos)) & isBomb) number ++; return number; } bool CMine_Sweeper::Play(int xpos, int ypos,bool computer_move) { int i; if ( (!GameBoard->is_InGrid(xpos,ypos))|| (FlagBoard->asInt(xpos, ypos)==1) || ((GameBoard->asInt(xpos, ypos)) & isBomb && (computer_move)) ) { return true; } if ( (GameBoard->asInt(xpos, ypos)) & isBomb && (!computer_move) ) { GameBoard->Set_Value(xpos, ypos,isBomb|isBumm); return false; } if ( GameBoard->asInt(xpos, ypos) == 0 ) { GameBoard->Set_Value(xpos, ypos, isOpen); OpenFields ++; if (Get_Number_of_Bombs(xpos, ypos) ) return true; for( i = 0; i<8; i++) Play(pInput->Get_System().Get_xTo(i,xpos),pInput->Get_System().Get_yTo(i,ypos) ,true); } return true; } void CMine_Sweeper::Mark(int xpos, int ypos) { int val; val = FlagBoard->asInt(xpos , ypos); if (val == FLAG) MarkedMines --; val ++; val%=3; if (val == FLAG) MarkedMines ++ ; FlagBoard->Set_Value(xpos, ypos, val); } CTimer::CTimer() { time(&starttime); } CTimer::~CTimer() { } int CTimer::Time() { time_t nowtime; time(&nowtime); return (int) (nowtime-starttime); } saga-2.3.1/src/modules/garden/garden_games/Makefile.in0000664000175000017500000005554712737447615024006 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/garden/garden_games ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libgarden_games_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libgarden_games_la_OBJECTS = Mine_Sweeper.lo Mine_Sweeper_Res.lo \ MLB_Interface.lo Sudoku.lo libgarden_games_la_OBJECTS = $(am_libgarden_games_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libgarden_games_la_SOURCES) DIST_SOURCES = $(libgarden_games_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libgarden_games.la libgarden_games_la_SOURCES = \ Mine_Sweeper.cpp\ Mine_Sweeper_Res.cpp\ MLB_Interface.cpp\ Sudoku.cpp\ Mine_Sweeper.h\ MLB_Interface.h\ Sudoku.h libgarden_games_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/garden/garden_games/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/garden/garden_games/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libgarden_games.la: $(libgarden_games_la_OBJECTS) $(libgarden_games_la_DEPENDENCIES) $(EXTRA_libgarden_games_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libgarden_games_la_OBJECTS) $(libgarden_games_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mine_Sweeper.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Mine_Sweeper_Res.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sudoku.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/garden/garden_games/Makefile.am0000744000175000017500000000115712737416157023755 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libgarden_games.la libgarden_games_la_SOURCES =\ Mine_Sweeper.cpp\ Mine_Sweeper_Res.cpp\ MLB_Interface.cpp\ Sudoku.cpp\ Mine_Sweeper.h\ MLB_Interface.h\ Sudoku.h libgarden_games_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/garden/garden_games/MLB_Interface.h0000744000175000017500000000713412737416157024465 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Library Template // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Author // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: author@email.de // // // // contact: Author // // Sesame Street. 7 // // 12345 Metropolis // // Nirwana // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__garden_games_H #define HEADER_INCLUDED__garden_games_H //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__garden_games_H saga-2.3.1/src/modules/garden/garden_games/MLB_Interface.cpp0000744000175000017500000001144012737416157025013 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Library Template // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Author // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: author@email.de // // // // contact: Author // // Sesame Street. 7 // // 12345 Metropolis // // Nirwana // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Games") ); case MLB_INFO_Category: return( _TL("Garden") ); case MLB_INFO_Author: return( SG_T("SAGA User Group Associaton (c) 2003") ); case MLB_INFO_Description: return( _TL("Games")); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Garden|Recreations|Games") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Mine_Sweeper.h" #include "Sudoku.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { // Don't forget to continuously enumerate the case switches // when adding new modules! Also bear in mind that the // enumeration always has to start with [case 0:] and // that [default:] must return NULL!... CSG_Module *pModule; switch( i ) { case 0: pModule = new CMine_Sweeper; break; case 1: pModule = new CSudoku; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/garden/garden_games/Mine_Sweeper_Res.cpp0000744000175000017500000002173412737416157025623 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Mine_Sweeper_Res.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ unsigned char mine_res[] = { 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,8, 15,15,15,15,15,15,15,15,15,15,15,15,15,15,8,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,8, 15,15,15,15,15,15,15,15,15,15,15,15,15,15,8,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,9,9,8,8,8,8,8,7,7, 15,15,8,8,8,9,9,9,9,8,8,8,8,8,7,7, 15,15,8,8,9,9,9,9,9,8,8,8,8,8,7,7, 15,15,8,8,8,9,9,9,9,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,9,9,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,0,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,0,8,8,8,8,8,7,7, 15,15,8,8,8,8,0,0,0,0,8,8,8,8,7,7, 15,15,8,8,0,0,0,0,0,0,0,0,8,8,7,7, 15,15,8,8,0,0,0,0,0,0,0,0,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,8, 15,15,15,15,15,15,15,15,15,15,15,15,15,15,8,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,0,0,0,0,8,8,8,8,7,7, 15,15,8,8,8,0,0,8,8,0,0,8,8,8,7,7, 15,15,8,8,8,0,0,8,8,0,0,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,0,0,8,8,8,7,7, 15,15,8,8,8,8,8,8,0,0,8,8,8,8,7,7, 15,15,8,8,8,8,8,0,0,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,0,0,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,0,0,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,0,0,8,8,8,8,8,7,7, 15,15,8,8,8,8,8,8,8,8,8,8,8,8,7,7, 15,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 7,9,9,9,9,9,9,9,0,9,9,9,9,9,9,9, 7,9,9,9,9,9,9,9,0,9,9,9,9,9,9,9, 7,9,9,9,0,9,0,0,0,0,0,9,0,9,9,9, 7,9,9,9,9,0,0,0,0,0,0,0,9,9,9,9, 7,9,9,9,0,0,15,15,0,0,0,0,0,9,9,9, 7,9,9,9,0,0,15,15,0,0,0,0,0,9,9,9, 7,9,0,0,0,0,0,0,0,0,0,0,0,0,0,9, 7,9,9,9,0,0,0,0,0,0,0,0,0,9,9,9, 7,9,9,9,0,0,0,0,0,0,0,0,0,9,9,9, 7,9,9,9,9,0,0,0,0,0,0,0,9,9,9,9, 7,9,9,9,0,9,0,0,0,0,0,9,0,9,9,9, 7,9,9,9,9,9,9,9,0,9,9,9,9,9,9,9, 7,9,9,9,9,9,9,9,0,9,9,9,9,9,9,9, 7,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,0,8,8,8,8,8,8,8, 7,8,9,9,8,8,8,8,0,8,8,8,8,9,9,8, 7,8,8,9,9,8,0,0,0,0,0,8,9,9,8,8, 7,8,8,8,9,9,0,0,0,0,0,9,9,8,8,8, 7,8,8,8,0,9,9,15,0,0,9,9,0,8,8,8, 7,8,8,8,0,0,9,9,0,9,9,0,0,8,8,8, 7,8,0,0,0,0,0,9,9,9,0,0,0,0,0,8, 7,8,8,8,0,0,0,9,9,9,0,0,0,8,8,8, 7,8,8,8,0,0,9,9,0,9,9,0,0,8,8,8, 7,8,8,8,8,9,9,0,0,0,9,9,8,8,8,8, 7,8,8,8,9,9,0,0,0,0,0,9,9,8,8,8, 7,8,8,9,9,8,8,8,0,8,8,8,9,9,8,8, 7,8,9,9,8,8,8,8,0,8,8,8,8,9,9,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,0,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,0,8,8,8,8,8,8,8, 7,8,8,8,0,8,0,0,0,0,0,8,0,8,8,8, 7,8,8,8,8,0,0,0,0,0,0,0,8,8,8,8, 7,8,8,8,0,0,15,15,0,0,0,0,0,8,8,8, 7,8,8,8,0,0,15,15,0,0,0,0,0,8,8,8, 7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,8, 7,8,8,8,0,0,0,0,0,0,0,0,0,8,8,8, 7,8,8,8,0,0,0,0,0,0,0,0,0,8,8,8, 7,8,8,8,8,0,0,0,0,0,0,0,8,8,8,8, 7,8,8,8,0,8,0,0,0,0,0,8,0,8,8,8, 7,8,8,8,8,8,8,8,0,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,0,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,0,0,0,0,8,8,8,8,8, 7,8,8,8,8,8,0,0,8,8,0,0,8,8,8,8, 7,8,8,8,8,8,0,0,8,8,0,0,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,0,0,8,8,8,8, 7,8,8,8,8,8,8,8,8,0,0,8,8,8,8,8, 7,8,8,8,8,8,8,8,0,0,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,0,0,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,0,0,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,0,0,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,7,7,7,7,7,7,7,7,8,8,8,8, 7,8,8,7,7,7,7,7,7,7,7,7,7,8,8,8, 7,8,8,7,7,7,8,8,8,8,7,7,7,8,8,8, 7,8,8,7,7,7,8,8,8,8,7,7,7,8,8,8, 7,8,8,8,7,7,7,7,7,7,7,7,8,8,8,8, 7,8,8,8,7,7,7,7,7,7,7,7,8,8,8,8, 7,8,8,7,7,7,8,8,8,8,7,7,7,8,8,8, 7,8,8,7,7,7,8,8,8,8,7,7,7,8,8,8, 7,8,8,7,7,7,7,7,7,7,7,7,7,8,8,8, 7,8,8,8,7,7,7,7,7,7,7,7,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,0,0,0,0,0,0,0,0,0,0,8,8,8, 7,8,8,0,0,0,0,0,0,0,0,0,0,8,8,8, 7,8,8,8,8,8,8,8,8,8,0,0,0,8,8,8, 7,8,8,8,8,8,8,8,8,8,0,0,0,8,8,8, 7,8,8,8,8,8,8,8,8,0,0,0,8,8,8,8, 7,8,8,8,8,8,8,8,8,0,0,0,8,8,8,8, 7,8,8,8,8,8,8,8,0,0,0,8,8,8,8,8, 7,8,8,8,8,8,8,8,0,0,0,8,8,8,8,8, 7,8,8,8,8,8,8,0,0,0,8,8,8,8,8,8, 7,8,8,8,8,8,8,0,0,0,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,6,6,6,6,6,6,6,6,8,8,8,8, 7,8,8,6,6,6,6,6,6,6,6,6,8,8,8,8, 7,8,8,6,6,6,8,8,8,8,8,8,8,8,8,8, 7,8,8,6,6,6,8,8,8,8,8,8,8,8,8,8, 7,8,8,6,6,6,6,6,6,6,6,6,8,8,8,8, 7,8,8,6,6,6,6,6,6,6,6,6,6,8,8,8, 7,8,8,6,6,6,8,8,8,8,6,6,6,8,8,8, 7,8,8,6,6,6,8,8,8,8,6,6,6,8,8,8, 7,8,8,6,6,6,6,6,6,6,6,6,6,8,8,8, 7,8,8,8,6,6,6,6,6,6,6,6,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,1,1,1,1,1,1,1,1,1,1,8,8,8, 7,8,8,1,1,1,1,1,1,1,1,1,1,8,8,8, 7,8,8,1,1,1,8,8,8,8,8,8,8,8,8,8, 7,8,8,1,1,1,8,8,8,8,8,8,8,8,8,8, 7,8,8,1,1,1,1,1,1,1,1,1,8,8,8,8, 7,8,8,1,1,1,1,1,1,1,1,1,1,8,8,8, 7,8,8,8,8,8,8,8,8,8,1,1,1,8,8,8, 7,8,8,8,8,8,8,8,8,8,1,1,1,8,8,8, 7,8,8,1,1,1,1,1,1,1,1,1,1,8,8,8, 7,8,8,1,1,1,1,1,1,1,1,1,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,4,4,4,8,4,4,4,8,8,8,8, 7,8,8,8,8,4,4,4,8,4,4,4,8,8,8,8, 7,8,8,8,4,4,4,8,8,4,4,4,8,8,8,8, 7,8,8,8,4,4,4,8,8,4,4,4,8,8,8,8, 7,8,8,4,4,4,4,4,4,4,4,4,4,8,8,8, 7,8,8,4,4,4,4,4,4,4,4,4,4,8,8,8, 7,8,8,8,8,8,8,8,8,4,4,4,8,8,8,8, 7,8,8,8,8,8,8,8,8,4,4,4,8,8,8,8, 7,8,8,8,8,8,8,8,8,4,4,4,8,8,8,8, 7,8,8,8,8,8,8,8,8,4,4,4,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,9,9,9,9,9,9,9,9,9,8,8,8,8, 7,8,8,9,9,9,9,9,9,9,9,9,9,8,8,8, 7,8,8,8,8,8,8,8,8,8,9,9,9,8,8,8, 7,8,8,8,8,8,8,8,8,8,9,9,9,8,8,8, 7,8,8,8,8,8,9,9,9,9,9,9,8,8,8,8, 7,8,8,8,8,8,9,9,9,9,9,9,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,9,9,9,8,8,8, 7,8,8,8,8,8,8,8,8,8,9,9,9,8,8,8, 7,8,8,9,9,9,9,9,9,9,9,9,9,8,8,8, 7,8,8,9,9,9,9,9,9,9,9,9,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,2,2,2,2,2,2,2,2,8,8,8,8, 7,8,8,2,2,2,2,2,2,2,2,2,2,8,8,8, 7,8,8,2,2,2,8,8,8,8,2,2,2,8,8,8, 7,8,8,8,8,8,8,8,8,8,2,2,2,8,8,8, 7,8,8,8,8,8,8,8,2,2,2,2,8,8,8,8, 7,8,8,8,8,8,2,2,2,2,2,8,8,8,8,8, 7,8,8,8,2,2,2,2,2,8,8,8,8,8,8,8, 7,8,8,2,2,2,2,8,8,8,8,8,8,8,8,8, 7,8,8,2,2,2,2,2,2,2,2,2,2,8,8,8, 7,8,8,2,2,2,2,2,2,2,2,2,2,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,12,12,8,8,8,8,8,8, 7,8,8,8,8,8,8,12,12,12,8,8,8,8,8,8, 7,8,8,8,8,8,12,12,12,12,8,8,8,8,8,8, 7,8,8,8,8,12,12,12,12,12,8,8,8,8,8,8, 7,8,8,8,8,8,8,12,12,12,8,8,8,8,8,8, 7,8,8,8,8,8,8,12,12,12,8,8,8,8,8,8, 7,8,8,8,8,8,8,12,12,12,8,8,8,8,8,8, 7,8,8,8,8,8,8,12,12,12,8,8,8,8,8,8, 7,8,8,8,8,12,12,12,12,12,12,12,8,8,8,8, 7,8,8,8,8,12,12,12,12,12,12,12,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 }; unsigned char mine_res_color[] = { 0, 0, 0, 128, 0, 0, 0,128, 0, 0, 0, 0, 0, 0,128, 0, 0, 0, 0,128,128, 128,128,128, 192,192,192, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,255, 0, 0, 0, 0, 0, 0, 255,255,255 }; unsigned int SPRITE_SIZE = 16; saga-2.3.1/src/modules/garden/garden_games/Sudoku.cpp0000744000175000017500000001572012737416157023700 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Sudoku.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ #include "Sudoku.h" //#include "Sudoku_res.h" int numbers[10][36][36]; #define BOARD_SIZE 354 #define BLOCK_SIZE 119 #define CELL_SIZE 38 #define CELL_COLOR_BLACK 0 #define CELL_COLOR_WHITE 1 #define CELL_COLOR_YELLOW 2 #define CELL_COLOR_BROWN 3 #define CELL_COLOR_GREEN 4 #define CELL_COLOR_RED 5 unsigned int cell_color[] = { SG_GET_RGB(0, 0, 0), // 0 = black SG_GET_RGB(255, 255, 255), // 1 = white SG_GET_RGB(250, 250, 150), // 2 = yellow SG_GET_RGB(200, 150, 100), // 3 = browm SG_GET_RGB(0, 220, 0), // 4 = green SG_GET_RGB(200, 0 ,0) // 5 = red }; CSudoku::CSudoku(void) { Set_Name (_TL("Sudoku")); Set_Author (_TL("Copyrights (c) 2006 by Victor Olaya")); Set_Description(_TL("")); Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); int i, j; CSG_Table *pBoard; CSG_Table_Record *pRecord; pBoard = Parameters.Add_FixedTable( NULL , "BOARD" , _TL("Board"), _TL("") )->asTable(); for (i = 0; i < 9; i++){ pBoard->Add_Field(_TL(""), SG_DATATYPE_Int); } for (i = 0; i < 9; i++){ pRecord = pBoard->Add_Record(); for (j = 0; j < 9; j++){ pRecord->Set_Value(j, 0.); } } } CSudoku::~CSudoku(void) {} bool CSudoku::On_Execute(void) { int i; CSG_Colors Colors; m_pSudoku = new int * [9]; m_pFixedCells = new bool * [9]; for (i = 0; i < 9; i++){ m_pSudoku[i] = new int [9]; m_pFixedCells[i] = new bool[9]; } m_pBoard = SG_Create_Grid(SG_DATATYPE_Int, BOARD_SIZE, BOARD_SIZE, 1); m_pBoard->Set_Name(_TL("Sudoku")); Parameters("GRID")->Set_Value(m_pBoard); Colors.Set_Count(6); for (i = 0; i < 6; i++){ Colors.Set_Color(i, cell_color[i]); } DataObject_Set_Colors(m_pBoard, Colors); DataObject_Update(m_pBoard, true); CreateSudoku(); DrawBoard(); return true; } bool CSudoku::On_Execute_Finish(void) { for (int i = 0; i < 9; i++){ delete [] m_pSudoku[i]; delete [] m_pFixedCells[i]; } delete [] m_pSudoku; delete [] m_pFixedCells; return( true ); } void CSudoku::CreateSudoku() { CSG_Table *pTable; int i,j; int iValue; pTable = Parameters("BOARD")->asTable(); for (i = 0; i < 9; i++){ for (j = 0; j < 9; j++){ iValue = pTable->Get_Record(i)->asInt(j); if (iValue > 0 && iValue < 10){ m_pSudoku[i][j] = iValue; m_pFixedCells[i][j] = true; } else{ m_pSudoku[i][j] = 0; m_pFixedCells[i][j] = false; } } } } bool CSudoku::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { int iXGrid, iYGrid; int iXSudoku, iYSudoku; int iBlock, iCell; bool pIsPossible[10]; if( Mode != MODULE_INTERACTIVE_LDOWN && Mode != MODULE_INTERACTIVE_RDOWN) { return false; } if (!Get_Grid_Pos(iXGrid, iYGrid) ){ return false; } iBlock = (int)floor((double)iXGrid / (double)BLOCK_SIZE); iCell = (int)floor((double)iXGrid - (iBlock * BLOCK_SIZE)) / CELL_SIZE; iXSudoku = iBlock * 3 + iCell; iBlock = (int)floor((double)iYGrid / (double)BLOCK_SIZE); iCell = (int)floor((double)iYGrid - (iBlock * BLOCK_SIZE)) / CELL_SIZE; iYSudoku = iBlock * 3 + iCell; if (iXSudoku < 0 || iXSudoku > 8 || iYSudoku < 0 || iYSudoku > 8){ return false; } if (m_pFixedCells[iYSudoku][iXSudoku]){ return false; } GetPossibleValues(iXSudoku, iYSudoku, pIsPossible); if( Mode == MODULE_INTERACTIVE_LDOWN ){ do{ m_pSudoku[iYSudoku][iXSudoku]++; if (m_pSudoku[iYSudoku][iXSudoku] > 9){ m_pSudoku[iYSudoku][iXSudoku] = 0; } }while(!pIsPossible[m_pSudoku[iYSudoku][iXSudoku]]); } else{ do{ m_pSudoku[iYSudoku][iXSudoku]--; if (m_pSudoku[iYSudoku][iXSudoku] < 0){ m_pSudoku[iYSudoku][iXSudoku] = 9; } }while(!pIsPossible[m_pSudoku[iYSudoku][iXSudoku]]); } DrawBoard(); DataObject_Update(m_pBoard); return true; } void CSudoku::DrawBoard() { int i,j; int iX, iY; bool pIsPossible[10]; m_pBoard->Assign(CELL_COLOR_WHITE); for (i = 0; i < 3; i++){ for (j = 0; j < 3; j++){ iX = (116 + 3) * i; iY = (116 + 3) * j; DrawSquare(iX, iY, CELL_COLOR_BROWN, 116); } } for (i = 0; i < 9; i++){ for (j = 0; j < 9; j++){ GetPossibleValues(i, j, pIsPossible); DrawCell(i, j, pIsPossible); } } m_pBoard->Set_Value(0,0, CELL_COLOR_RED); m_pBoard->Set_Value(0,1, CELL_COLOR_BLACK); } void CSudoku::DrawCell(int iXCell, int iYCell, bool *pIsPossible) { int i,j; int iX, iY; int iXBlock, iYBlock; int iXCellInBlock, iYCellInBlock; int iInnerX, iInnerY; int iInnerXCell, iInnerYCell; int iValue; int iNumberColor;//, iColor; iXBlock = (iXCell - (iXCell % 3)) / 3; iYBlock = (iYCell - (iYCell % 3)) / 3; iXCellInBlock = iXCell % 3; iYCellInBlock = iYCell % 3; iX = (116 + 3) * iXBlock + 38 * iXCellInBlock + 2; iY = (116 + 3) * iYBlock + 38 * iYCellInBlock + 2; DrawSquare(iX, iY, CELL_COLOR_YELLOW, 36); if (iValue = m_pSudoku[iYCell][iXCell]){ if (m_pFixedCells[iYCell][iXCell]){ iNumberColor = CELL_COLOR_RED; } else{ iNumberColor = CELL_COLOR_BLACK; } for (i = 0; i < 36; i++){ for (j = 0; j < 36; j++){ if (numbers[iValue - 1][j][i]){ m_pBoard->Set_Value(iX + i, iY + 36 - j - 1, CELL_COLOR_WHITE); } else{ m_pBoard->Set_Value(iX + i, iY + 36 - j - 1, iNumberColor); } } } } else{ for (i = 0; i < 9; i++){ iInnerXCell = i % 3; iInnerYCell = (i - iInnerXCell ) / 3; iInnerX = iX + iInnerXCell * 12 + 1; iInnerY = iY + iInnerYCell * 12 + 1; if (pIsPossible[i + 1]){ DrawSquare(iInnerX, iInnerY, CELL_COLOR_GREEN, 10); } else{ DrawSquare(iInnerX, iInnerY, CELL_COLOR_RED, 10); } } } } void CSudoku::DrawSquare(int iX, int iY, int iColor, int iSize) { int i, j; for (i = 0; i < iSize; i++){ for (j = 0; j < iSize; j++){ m_pBoard->Set_Value(iX + i, iY + j, iColor); } } } void CSudoku::GetPossibleValues(int iX, int iY, bool *pIsPossible) { int i,j; int iInitX, iInitY; iInitX = (int)floor((double)iX / 3.) * 3; iInitY = (int)floor((double)iY / 3.) * 3; for (i = 0; i < 10; i++){ pIsPossible[i] = true; } for (i = 0; i < 9; i++){ pIsPossible[m_pSudoku[iY][i]] = false; } for (i = 0; i < 9; i++){ pIsPossible[m_pSudoku[i][iX]] = false; } for (i = 0; i < 3; i++){ for (j = 0; j < 3; j++){ pIsPossible[m_pSudoku[iInitY + i][iInitX + j]] = false; } } pIsPossible[0] = true; } bool CSudoku::Get_Grid_Pos(int &x, int &y) { bool bResult; if( m_pBoard && m_pBoard->is_Valid() ) { bResult = true; x = (int)(0.5 + (Get_xPosition() - m_pBoard->Get_XMin()) / m_pBoard->Get_Cellsize()); if( x < 0 ) { bResult = false; x = 0; } else if( x >= m_pBoard->Get_NX() ) { bResult = false; x = m_pBoard->Get_NX() - 1; } y = (int)(0.5 + (Get_yPosition() - m_pBoard->Get_YMin()) / m_pBoard->Get_Cellsize()); if( y < 0 ) { bResult = false; y = 0; } else if( y >= m_pBoard->Get_NY() ) { bResult = false; y = m_pBoard->Get_NY() - 1; } return( bResult ); } x = 0; y = 0; return( false ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/0000775000175000017500000000000012737740003024142 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_11.cpp0000744000175000017500000002164212737416157026734 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_11.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_11.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_11.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_11::CExercise_11(void) { Set_Name (_TL("11: Dynamic Simulation - Soil Nitrogen Dynamics")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Spatially Distributed Simulation of Soil Nitrogen Dynamics. " "\nReference:" "\nHugget, R.J. (1993): 'Modelling the Human Impact on Nature', Oxford University Press.\n" "\n(c) 2003 by Olaf Conrad, Goettingen\nemail: oconrad@gwdg.de") ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "NSTORE" , _TL("Soil Nitrogen"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- Parameters.Add_Value( NULL , "TIME_SPAN" , _TL("Time Span [a]"), _TL(""), PARAMETER_TYPE_Double , 100.0, 0.0, true ); Parameters.Add_Value( NULL , "TIME_STEP" , _TL("Time Interval [a]"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( NULL , "UPDATE" , _TL("Update View"), _TL(""), PARAMETER_TYPE_Bool , true ); //----------------------------------------------------- Parameters.Add_Value( NULL , "NINIT" , _TL("Initial Nitrogen Content [kg/ha]"), _TL(""), PARAMETER_TYPE_Double , 5000.0, 0.0, true ); Parameters.Add_Value( NULL , "NRAIN" , _TL("Nitrogen in Rainfall [kg/ha/a]"), _TL(""), PARAMETER_TYPE_Double , 16.0, 0.0, true ); } //--------------------------------------------------------- CExercise_11::~CExercise_11(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_11::On_Execute(void) { bool bUpdate; int iStep, nSteps; double sTime, dTime, N_Init, N_Rain; CSG_Grid *pDEM; //----------------------------------------------------- sTime = Parameters("TIME_SPAN") ->asDouble(); dTime = Parameters("TIME_STEP") ->asDouble(); nSteps = (int)(sTime / dTime); bUpdate = Parameters("UPDATE") ->asBool(); N_Init = Parameters("NINIT") ->asDouble(); N_Rain = Parameters("NRAIN") ->asDouble(); pDEM = Parameters("DEM") ->asGrid(); m_pN = Parameters("NSTORE") ->asGrid(); m_pN->Assign(N_Init); DataObject_Set_Colors(m_pN, 100, SG_COLORS_YELLOW_GREEN); Initialize(pDEM); //----------------------------------------------------- for(iStep=0; iStep<=nSteps && Set_Progress(iStep, nSteps); iStep++) { Process_Set_Text(CSG_String::Format(SG_T("Time [a]: %f (%f)"), dTime * iStep, sTime)); if( bUpdate ) { DataObject_Update(m_pN, m_pN->Get_ZMin(), m_pN->Get_ZMax(), true); } Next_Step(N_Rain, dTime); } //----------------------------------------------------- Finalize(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_11::Initialize(CSG_Grid *pDEM) { int x, y, i, ix, iy; double z, dz, dzSum; //----------------------------------------------------- m_Next .Create(pDEM, SG_DATATYPE_Float); m_dzSum .Create(pDEM, SG_DATATYPE_Float); for(i=0; i<8; i++) { m_dz[i].Create(pDEM, SG_DATATYPE_Float); } //----------------------------------------------------- for(y=0; yis_NoData(x, y) ) { z = pDEM->asDouble(x, y); for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( pDEM->is_InGrid(ix, iy) && (dz = (z - pDEM->asDouble(ix, iy)) / Get_Length(i)) > 0.0 ) { m_dz[i].Set_Value(x, y, dz); dzSum += dz; } else { m_dz[i].Set_Value(x, y, 0.0); } } if( dzSum > 0.0 ) { for(i=0; i<8; i++) { m_dz[i].Mul_Value(x, y, 1.0 / dzSum); } } } m_dzSum.Set_Value(x, y, dzSum); } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_11::Finalize(void) { int i; m_Next .Destroy(); m_dzSum .Destroy(); for(i=0; i<8; i++) { m_dz[i].Destroy(); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_11::Next_Step(double N_Rain, double dTime) { int x, y, i; double dz, dzSum, N, dN; m_Next.Assign(0.0); N_Rain *= dTime; //----------------------------------------------------- for(y=0; yasDouble(x, y); if( (dzSum = m_dzSum.asDouble(x, y)) > 0.0 ) { dN = N * dzSum * dTime; if( dN > N ) { dN = N; } for(i=0; i<8; i++) { if( (dz = m_dz[i].asDouble(x, y)) > 0.0 ) { m_Next.Add_Value(Get_xTo(i, x), Get_yTo(i, y), dz * dN); } } } else { dN = 0.0; } m_Next.Add_Value(x, y, N - dN + N_Rain); } } if( is_Progress() ) { m_pN->Assign(&m_Next); } //----------------------------------------------------- return( true ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_06.h0000744000175000017500000001043412737416157026402 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_06.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_06.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_06_H #define HEADER_INCLUDED__Exercise_06_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_06 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CExercise_06(void); // constructor virtual ~CExercise_06(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// CSG_Grid *m_pInput, *m_pOutput; bool Method_01(int Radius); bool Method_02(int Radius); bool Method_03(int Radius); }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_06_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_02.cpp0000744000175000017500000001456512737416157026742 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_02.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_02.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_02.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_02::CExercise_02(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("02: Pixel by pixel operations with two grids")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Pixel by pixel operations with two grids.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT_A" , _TL("First input grid"), _TL("This must be your input data of type grid."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT_B" , _TL("Second input grid"), _TL("This must be your input data of type grid."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "OUTPUT" , _TL("Output"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL, "METHOD" , _TL("Method"), _TL("Choose a method"), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Addition|"), _TL("Subtraction"), _TL("Multiplication"), _TL("Division") ) ); } //--------------------------------------------------------- CExercise_02::~CExercise_02(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_02::On_Execute(void) { int x, y, Method; double a, b; CSG_Grid *pInput_A, *pInput_B, *pOutput; //----------------------------------------------------- // Get parameter settings... pInput_A = Parameters("INPUT_A")->asGrid(); pInput_B = Parameters("INPUT_B")->asGrid(); pOutput = Parameters("OUTPUT")->asGrid(); Method = Parameters("METHOD")->asInt(); //----------------------------------------------------- // Execute calculation... for(y=0; yis_NoData(x, y) || pInput_B->is_NoData(x, y) ) // don't work with 'no data'... { pOutput->Set_NoData(x, y); } else { a = pInput_A->asDouble(x, y); b = pInput_B->asDouble(x, y); switch( Method ) { case 0: // Addition... pOutput->Set_Value(x, y, a + b); break; case 1: // Subtraction... pOutput->Set_Value(x, y, a - b); break; case 2: // Multiplication... pOutput->Set_Value(x, y, a * b); break; case 3: // Division... if( b != 0.0 ) // prevent division by zero... { pOutput->Set_Value(x, y, a / b); } else { pOutput->Set_NoData(x, y); } break; } } } } //----------------------------------------------------- // Return 'true' if everything went okay... return( true ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_11.h0000744000175000017500000000762112737416157026402 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_11.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_11.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_11_H #define HEADER_INCLUDED__Exercise_11_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_11 : public CSG_Module_Grid { public: CExercise_11(void); virtual ~CExercise_11(void); protected: virtual bool On_Execute(void); private: CSG_Grid *m_pN, m_Next, m_dz[8], m_dzSum; bool Initialize(CSG_Grid *pDEM); bool Finalize(void); bool Next_Step(double N_Rain, double dTime); }; #endif // #ifndef HEADER_INCLUDED__Exercise_11_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_06.cpp0000744000175000017500000002147412737416157026743 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_06.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_06.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_06.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_06::CExercise_06(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("06: Extended neighbourhoods")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Extended neigbourhoods for grids.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT" , _TL("Input grid"), _TL("This must be your input data of type grid."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "OUTPUT" , _TL("Output grid"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL, "RADIUS" , _TL("Radius"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Choice( NULL, "METHOD" , _TL("Method"), _TL("Choose a method"), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Quadratic"), _TL("Circle"), _TL("Distance Weighted (inverse distance)") ) ); } //--------------------------------------------------------- CExercise_06::~CExercise_06(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_06::On_Execute(void) { int Radius; //----------------------------------------------------- // Get parameter settings... m_pInput = Parameters("INPUT" )->asGrid(); m_pOutput = Parameters("OUTPUT")->asGrid(); Radius = Parameters("RADIUS")->asInt(); //----------------------------------------------------- // Execute calculation... switch( Parameters("METHOD")->asInt() ) { case 0: return( Method_01(Radius) ); case 1: return( Method_02(Radius) ); case 2: return( Method_03(Radius) ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_06::Method_01(int Radius) { int x, y, ix, iy, n; double s; //----------------------------------------------------- for(y=0; yis_NoData(ix, iy) ) { n++; s += m_pInput->asDouble(ix, iy); } } } if( n > 0 ) { m_pOutput->Set_Value(x, y, s / n); } else { m_pOutput->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_06::Method_02(int Radius) { int x, y, ix, iy, xMask, yMask, nMask, n; double s, Distance; CSG_Grid gMask; //----------------------------------------------------- nMask = 1 + 2 * Radius; gMask.Create(SG_DATATYPE_Byte, nMask, nMask); for(iy=-Radius, yMask=0; yMaskis_NoData(ix, iy) && gMask.asByte(xMask, yMask) ) { n++; s += m_pInput->asDouble(ix, iy); } } } if( n > 0 ) { m_pOutput->Set_Value(x, y, s / n); } else { m_pOutput->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_06::Method_03(int Radius) { int x, y, ix, iy, xMask, yMask, nMask; double s, n, Distance, Weight; CSG_Grid gMask; //----------------------------------------------------- nMask = 1 + 2 * Radius; gMask.Create(SG_DATATYPE_Double, nMask, nMask); for(iy=-Radius, yMask=0; yMask 0.0 && Distance <= Radius ? 1.0 / Distance : 0.0); } } //----------------------------------------------------- for(y=0; yis_NoData(ix, iy) && (Weight = gMask.asDouble(xMask, yMask)) > 0.0 ) { n += Weight; s += Weight * m_pInput->asDouble(ix, iy); } } } if( n > 0 ) { m_pOutput->Set_Value(x, y, s / n); } else { m_pOutput->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_08.h0000744000175000017500000001027012737416157026402 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_08.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_08.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_08_H #define HEADER_INCLUDED__Exercise_08_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_08 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CExercise_08(void); // constructor virtual ~CExercise_08(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// CSG_Grid *m_pDTM, *m_pArea; bool Method_01(void); bool Method_02(void); }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_08_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_03.h0000744000175000017500000001044412737416157026400 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_03.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_03.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_03_H #define HEADER_INCLUDED__Exercise_03_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_03 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CExercise_03(void); // constructor virtual ~CExercise_03(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// CSG_Grid *m_pInput, *m_pOutput; bool Method_01(void); bool Method_02(void); bool Method_03(void); bool Method_04(void); }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_03_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_09.cpp0000744000175000017500000001600112737416157026734 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_09.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_09.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_09.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_09::CExercise_09(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("09: Extended neighbourhoods - catchment areas (recursive)")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Extended Neighbourhoods - Use recursive function calls for catchment area calculations.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "ELEVATION" , _TL("Elevation grid"), _TL("This must be your input data of type grid."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "AREA" , _TL("Catchment area"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); } //--------------------------------------------------------- CExercise_09::~CExercise_09(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_09::On_Execute(void) { int x, y; CSG_Grid *pDTM; //----------------------------------------------------- // Get parameter settings... pDTM = Parameters("ELEVATION")->asGrid(); m_pArea = Parameters("AREA" )->asGrid(); //----------------------------------------------------- // Initialisations... m_pArea ->Assign(0.0); m_pArea ->Set_Unit(SG_T("m\xc2\xb2")); DataObject_Set_Colors(m_pArea, 100, SG_COLORS_WHITE_BLUE); //----------------------------------------------------- // Save flow directions to temporary grid... m_pDir = new CSG_Grid(pDTM, SG_DATATYPE_Char); // this object has to be deleted later... for(y=0; ySet_Value(x, y, pDTM->Get_Gradient_NeighborDir(x, y) % 8); } } //------------------------------------------------- // Execute calculation... for(y=0; yasDouble(x, y); if( area <= 0.0 ) // cell has not been processed yet... { m_pArea->Set_Value(x, y, 1.0); // Very important: mark this cell as processed to prevent endless loops... area = Get_Cellsize() * Get_Cellsize(); // initialize the cell's area with its own cell size... for(i=0; i<8; i++) { ix = Get_xFrom(i, x); iy = Get_yFrom(i, y); if( is_InGrid(ix, iy) && i == m_pDir->asInt(ix, iy) ) // drains ith neigbour into this cell ???... { area += Get_Area(ix, iy); // ...then add its area (recursive call of this function!)... } } m_pArea->Set_Value(x, y, area); } //----------------------------------------------------- return( area ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_13.h0000744000175000017500000001044512737416160026374 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_13.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures_Shapes // // // //-------------------------------------------------------// // // // Exercise_13.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_13_H #define HEADER_INCLUDED__Exercise_13_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_13 : public CSG_Module { public: ////// public members and functions: ////////////// CExercise_13(void); // constructor virtual ~CExercise_13(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// void Transformation(CSG_Shapes *pShapes_A, CSG_Shapes *pShapes_B, double m[3][3]); void Multiply_Matrices(double A[3][3], double B[3][3]); }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_13_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_01.h0000744000175000017500000001022612737416157026374 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_01.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_01.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_01_H #define HEADER_INCLUDED__Exercise_01_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_01 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CExercise_01(void); // constructor virtual ~CExercise_01(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_01_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_13.cpp0000744000175000017500000002505312737416157026736 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_13.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures_Shapes // // // //-------------------------------------------------------// // // // Exercise_13.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_13.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_13::CExercise_13(void) { CSG_Parameter *pNode; //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("13: Reprojecting a shapes layer")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Copy a shapes layer and move it to a new position.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Shapes input and output... Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL("This must be your input data of type shapes."), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL("This will contain your output data of type shapes."), PARAMETER_OUTPUT ); //----------------------------------------------------- // Transformation parameters... Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("Translation"), _TL("Scaling"), _TL("Shearing"), _TL("Rotation"), _TL("Combination A"), _TL("Combination B") ) ); //----------------------------------------------------- // Transformation parameters... pNode = Parameters.Add_Node(NULL, "NODE_TRANS", _TL("Translation"), _TL("")); Parameters.Add_Value( pNode , "TRANS_X" , SG_T("X"), _TL(""), PARAMETER_TYPE_Double, 10.0 ); Parameters.Add_Value( pNode , "TRANS_Y" , SG_T("Y"), _TL(""), PARAMETER_TYPE_Double, 10.0 ); pNode = Parameters.Add_Node(NULL, "NODE_SCALE", _TL("Scale factors") , _TL("")); Parameters.Add_Value( pNode , "SCALE_X" , SG_T("X"), _TL(""), PARAMETER_TYPE_Double, 10.0 ); Parameters.Add_Value( pNode , "SCALE_Y" , SG_T("Y"), _TL(""), PARAMETER_TYPE_Double, 10.0 ); pNode = Parameters.Add_Node(NULL, "NODE_SHEAR", _TL("Shear factors") , _TL("")); Parameters.Add_Value( pNode , "SHEAR_X" , SG_T("X"), _TL(""), PARAMETER_TYPE_Double, 0.5 ); Parameters.Add_Value( pNode , "SHEAR_Y" , SG_T("Y"), _TL(""), PARAMETER_TYPE_Double, 0.5 ); Parameters.Add_Value( NULL , "ROTAT" , _TL("Rotation angle [Degree]"), _TL(""), PARAMETER_TYPE_Double, 45.0 ); } //--------------------------------------------------------- CExercise_13::~CExercise_13(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SET_MATRIX(M, a1, a2, a3, b1, b2, b3, c1, c2, c3) M[0][0]=a1; M[1][0]=b1; M[2][0]=c1;\ M[0][1]=a2; M[1][1]=b2; M[2][1]=c2;\ M[0][2]=a3; M[1][2]=b3; M[2][2]=c3; //--------------------------------------------------------- bool CExercise_13::On_Execute(void) { int Method; double trn_x, trn_y, scl_x, scl_y, shr_x, shr_y, rot, m_trn[3][3], m_scl[3][3], m_shr[3][3], m_rot[3][3], m[3][3]; CSG_Shapes *pShapes_A, *pShapes_B; //----------------------------------------------------- // Get parameter settings... pShapes_A = Parameters("INPUT") ->asShapes(); pShapes_B = Parameters("OUTPUT") ->asShapes(); pShapes_B->Create(pShapes_A->Get_Type(), _TL("Transformation"), pShapes_A); Method = Parameters("METHOD") ->asInt(); trn_x = Parameters("TRANS_X") ->asDouble(); trn_y = Parameters("TRANS_Y") ->asDouble(); scl_x = Parameters("SCALE_X") ->asDouble(); scl_y = Parameters("SCALE_Y") ->asDouble(); shr_x = Parameters("SHEAR_X") ->asDouble(); shr_y = Parameters("SHEAR_Y") ->asDouble(); rot = Parameters("ROTAT") ->asDouble() * M_DEG_TO_RAD; //----------------------------------------------------- // Initialise transformation matrices... // Translation... SET_MATRIX(m_trn, 1.0 , 0.0 , trn_x , 0.0 , 1.0 , trn_y , 0.0 , 0.0 , 1.0 ); // Scaling... SET_MATRIX(m_scl, scl_x , 0.0 , 0.0 , 0.0 , scl_y , 0.0 , 0.0 , 0.0 , 1.0 ); // Shearing... SET_MATRIX(m_shr, 1.0 , shr_x , 0.0 , shr_y , 1.0 , 0.0 , 0.0 , 0.0 , 1.0 ); // Rotation... SET_MATRIX(m_rot, cos(rot) , sin(rot) , 0.0 , -sin(rot) , cos(rot) , 0.0 , 0.0 , 0.0 , 1.0 ); // Initialise m as matrix, that does nothing... SET_MATRIX(m, 1.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 1.0 ); //----------------------------------------------------- // Set final transformation matrix m... switch( Method ) { case 0: // Translation... Multiply_Matrices(m, m_trn); break; case 1: // Scaling... Multiply_Matrices(m, m_scl); break; case 2: // Shearing... Multiply_Matrices(m, m_shr); break; case 3: // Rotation... Multiply_Matrices(m, m_rot); break; case 4: // Combination A... Multiply_Matrices(m, m_trn); Multiply_Matrices(m, m_scl); Multiply_Matrices(m, m_shr); Multiply_Matrices(m, m_rot); break; case 5: // Combination B... Multiply_Matrices(m, m_rot); Multiply_Matrices(m, m_shr); Multiply_Matrices(m, m_scl); Multiply_Matrices(m, m_trn); break; } //----------------------------------------------------- // Execute transformation... Transformation(pShapes_A, pShapes_B, m); //----------------------------------------------------- // Return 'true' if everything went okay... return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CExercise_13::Transformation(CSG_Shapes *pShapes_A, CSG_Shapes *pShapes_B, double m[3][3]) { int iShape, iPart, iPoint; double x; TSG_Point p; CSG_Shape *pShape_A, *pShape_B; //----------------------------------------------------- // Copy shapes layer A to B and reproject each point's position using matrix m... for(iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes_A->Get_Count()); iShape++) { pShape_A = pShapes_A->Get_Shape(iShape); pShape_B = pShapes_B->Add_Shape(pShape_A, SHAPE_COPY_ATTR); for(iPart=0; iPartGet_Part_Count(); iPart++) { for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { p = pShape_A->Get_Point(iPoint, iPart); x = m[0][0] * p.x + m[0][1] * p.y + m[0][2]; p.y = m[1][0] * p.x + m[1][1] * p.y + m[1][2]; p.x = x; pShape_B->Add_Point(p, iPart); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CExercise_13::Multiply_Matrices(double A[3][3], double B[3][3]) { int x, y, k; double C[3][3]; //----------------------------------------------------- for(x=0; x<3; x++) { for(y=0; y<3; y++) { C[x][y] = 0.0; for(k=0; k<3; k++) { C[x][y] += A[x][k] * B[k][y]; } } } //----------------------------------------------------- for(x=0; x<3; x++) { for(y=0; y<3; y++) { A[x][y] = C[x][y]; } } } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_14.h0000744000175000017500000001054612737416160026377 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_14.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_14.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_14_H #define HEADER_INCLUDED__Exercise_14_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_14 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CExercise_14(void); // constructor virtual ~CExercise_14(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// CSG_Grid *m_pDTM, *m_pChnl, *m_pDir; CSG_Shapes *m_pShapes; bool Initialise(int Threshold); void Find_Channels(void); void Find_Channels(int x, int y); void Vectorise(void); double Vectorise(int x, int y, CSG_Shape *pSegment); }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_14_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_01.cpp0000744000175000017500000001460412737416157026733 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_01.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_01.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_01.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_01::CExercise_01(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("01: My first module")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT" , _TL("Input"), _TL("This must be your input data of type grid."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "OUTPUT" , _TL("Output"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL, "FACTOR" , _TL("Factor"), _TL("Type in a value that shall be used for the chosen mathematical operation."), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Choice( NULL, "METHOD" , _TL("Method"), _TL("Choose a method"), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Addition"), _TL("Subtraction"), _TL("Multiplication"), _TL("Division") ) ); } //--------------------------------------------------------- CExercise_01::~CExercise_01(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_01::On_Execute(void) { int x, y, Method; double Factor, Value_Input, Value_Output; CSG_Grid *pInput, *pOutput; //----------------------------------------------------- // Get parameter settings... pInput = Parameters("INPUT" )->asGrid(); pOutput = Parameters("OUTPUT")->asGrid(); Factor = Parameters("FACTOR")->asDouble(); Method = Parameters("METHOD")->asInt(); //----------------------------------------------------- // Check for valid parameter settings... if( Method == 3 && Factor == 0.0 ) { Message_Add(_TL("Division by zero is not allowed !!!")); Message_Dlg(_TL("Division by zero is not allowed !!!")); return( false ); // prevent a division by zero!!! } //----------------------------------------------------- // Execute calculation... for(y=0; yasDouble(x, y); switch( Method ) { case 0: // Addition... Value_Output = Value_Input + Factor; break; case 1: // Subtraction... Value_Output = Value_Input - Factor; break; case 2: // Multiplication... Value_Output = Value_Input * Factor; break; case 3: // Division... Value_Output = Value_Input / Factor; break; } pOutput->Set_Value(x, y, Value_Output); } } //----------------------------------------------------- // Return 'true' if everything went okay... return( true ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_10.cpp0000744000175000017500000001635512737416157026740 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_10.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_10.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_10.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_10::CExercise_10(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("10: Dynamic Simulation - Life")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Conway's game of life. A cellular automate.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // 2. Grids... Parameters.Add_Grid( NULL, "RESULT" , _TL("Life"), _TL(""), PARAMETER_OUTPUT, true, SG_DATATYPE_Byte ); Parameters.Add_Value( NULL, "REFRESH" , _TL("Refresh"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL, "COLORS" , _TL("Fade Color Count"), _TL(""), PARAMETER_TYPE_Int, 64, 3, true, 255, true ); } //--------------------------------------------------------- CExercise_10::~CExercise_10(void) {} /////////////////////////////////////////////////////////// // // // Run // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_10::On_Execute(void) { bool bAlive; int x, y, i; CSG_Colors Colors; //----------------------------------------------------- // General initialisations... m_pLife = Parameters("RESULT")->asGrid(); m_nColors = Parameters("COLORS")->asInt(); Colors.Set_Count(m_nColors + 1); Colors.Set_Ramp(SG_GET_RGB(127, 127, 127), SG_GET_RGB(0, 0, 0)); Colors.Set_Color(0, SG_GET_RGB(255, 255, 255)); DataObject_Set_Colors(m_pLife, Colors); //----------------------------------------------------- // Initialise life's world... if( Parameters("REFRESH")->asBool() ) { srand((unsigned)time(NULL)); for(y=0; ySet_Value(x, y, rand() > RAND_MAX / 2 ? 0 : 1); } } } //----------------------------------------------------- // Execution... m_pTemp = SG_Create_Grid(m_pLife, SG_DATATYPE_Byte); for(i=1, bAlive=true; bAlive && Process_Get_Okay(true); i++) { Process_Set_Text(CSG_String::Format(SG_T("%d %s"), i, _TL("Life Cycle"))); if( (bAlive = Next_Step()) == false ) { Message_Add(CSG_String::Format(SG_T("%s %d %s\n"), _TL("Dead after"), i, _TL("Life Cycles"))); } } delete(m_pTemp); //----------------------------------------------------- // Finish... return( true ); } //--------------------------------------------------------- bool CExercise_10::Next_Step(void) { bool bAlive; int x, y, i, ix, iy, n; bAlive = false; //----------------------------------------------------- for(y=0; y= Get_NX() ) ix = 0; iy = Get_yTo(i, y); if( iy < 0 ) iy = Get_NY() - 1; else if( iy >= Get_NY() ) iy = 0; if( m_pLife->asByte(ix, iy) == 0 ) { n++; } } //--------------------------------------------- // Dead or alive... i = m_pLife->asByte(x, y); switch( n ) { case 2: // keep status... if( i > 0 && i < m_nColors ) // color fading... { i++; } break; case 3: // Birth... i = 0; break; default: // Dead... if( i < m_nColors ) // color fading... { i++; } } if( i > 1 && i < m_nColors ) { bAlive = true; } m_pTemp->Set_Value(x, y, i); } } //----------------------------------------------------- m_pLife->Assign(m_pTemp); DataObject_Update(m_pLife, 0, m_nColors, true); return( bAlive ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_12.cpp0000744000175000017500000001424312737416157026734 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_12.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures_Shapes // // // //-------------------------------------------------------// // // // Exercise_12.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_12.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_12::CExercise_12(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("12: First steps with shapes")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Copy a shapes layer and move it to a new position.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Shapes( NULL , "INPUT" , _TL("Input"), _TL("This must be your input data of type shapes."), PARAMETER_INPUT ); Parameters.Add_Shapes( NULL , "OUTPUT" , _TL("Output"), _TL("This will contain your output data of type shapes."), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "DX" , _TL("Translation: X"), _TL(""), PARAMETER_TYPE_Double, 10.0 ); Parameters.Add_Value( NULL , "DY" , _TL("Translation: Y"), _TL(""), PARAMETER_TYPE_Double, 10.0 ); } //--------------------------------------------------------- CExercise_12::~CExercise_12(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_12::On_Execute(void) { int iShape, iPart, iPoint; double dx, dy; TSG_Point Point; CSG_Shapes *pShapes_A, *pShapes_B; CSG_Shape *pShape_A, *pShape_B; //----------------------------------------------------- // Get parameter settings... pShapes_A = Parameters("INPUT") ->asShapes(); pShapes_B = Parameters("OUTPUT") ->asShapes(); dx = Parameters("DX") ->asDouble(); dy = Parameters("DY") ->asDouble(); pShapes_B->Create(pShapes_A->Get_Type(), _TL("Translation"), pShapes_A); //----------------------------------------------------- // Copy shapes layer A to B and translate each point's position... for(iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes_A->Get_Count()); iShape++) { pShape_A = pShapes_A->Get_Shape(iShape); pShape_B = pShapes_B->Add_Shape(pShape_A, SHAPE_COPY_ATTR); for(iPart=0; iPartGet_Part_Count(); iPart++) { for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Point = pShape_A->Get_Point(iPoint, iPart); Point.x += dx; // perform the translation before Point.y += dy; // you add the point to the new shape... pShape_B->Add_Point(Point, iPart); } } } //----------------------------------------------------- // Return 'true' if everything went okay... return( true ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_05.h0000744000175000017500000001042312737416157026377 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_05.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_05.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_05_H #define HEADER_INCLUDED__Exercise_05_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_05 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CExercise_05(void); // constructor virtual ~CExercise_05(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// CSG_Grid *m_pDTM, *m_pSlope, *m_pAspect; bool Method_01(void); bool Method_02(void); bool Method_03(void); }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_05_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_07.h0000744000175000017500000001041512737416157026402 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_07.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_07.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_07_H #define HEADER_INCLUDED__Exercise_07_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_07 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CExercise_07(void); // constructor virtual ~CExercise_07(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// int m_Method; double m_Area_of_Cell; CSG_Grid *m_pDTM, *m_pArea, *m_pDir; int Get_FlowDirection(int x, int y); double Trace_Flow(int x, int y); }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_07_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_04.h0000744000175000017500000001053012737416157026375 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_04.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_04.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_04_H #define HEADER_INCLUDED__Exercise_04_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_04 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CExercise_04(void); // constructor virtual ~CExercise_04(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// CSG_Grid *m_pInput, *m_pOutput; bool Method_01(void); bool Method_02(void); bool Method_03(void); bool Method_04(void); bool Method_05(void); bool Method_06(void); }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_04_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Makefile.in0000664000175000017500000006062412737447615026234 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/garden/garden_learn_to_program ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libgarden_learn_to_program_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libgarden_learn_to_program_la_OBJECTS = Exercise_01.lo \ Exercise_02.lo Exercise_03.lo Exercise_04.lo Exercise_05.lo \ Exercise_06.lo Exercise_07.lo Exercise_08.lo Exercise_09.lo \ Exercise_10.lo Exercise_11.lo Exercise_12.lo Exercise_13.lo \ Exercise_14.lo MLB_Interface.lo libgarden_learn_to_program_la_OBJECTS = \ $(am_libgarden_learn_to_program_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libgarden_learn_to_program_la_SOURCES) DIST_SOURCES = $(libgarden_learn_to_program_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libgarden_learn_to_program.la libgarden_learn_to_program_la_SOURCES = \ Exercise_01.cpp\ Exercise_02.cpp\ Exercise_03.cpp\ Exercise_04.cpp\ Exercise_05.cpp\ Exercise_06.cpp\ Exercise_07.cpp\ Exercise_08.cpp\ Exercise_09.cpp\ Exercise_10.cpp\ Exercise_11.cpp\ Exercise_12.cpp\ Exercise_13.cpp\ Exercise_14.cpp\ MLB_Interface.cpp\ Exercise_01.h\ Exercise_02.h\ Exercise_03.h\ Exercise_04.h\ Exercise_05.h\ Exercise_06.h\ Exercise_07.h\ Exercise_08.h\ Exercise_09.h\ Exercise_10.h\ Exercise_11.h\ Exercise_12.h\ Exercise_13.h\ Exercise_14.h\ MLB_Interface.h libgarden_learn_to_program_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/garden/garden_learn_to_program/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/garden/garden_learn_to_program/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libgarden_learn_to_program.la: $(libgarden_learn_to_program_la_OBJECTS) $(libgarden_learn_to_program_la_DEPENDENCIES) $(EXTRA_libgarden_learn_to_program_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libgarden_learn_to_program_la_OBJECTS) $(libgarden_learn_to_program_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_01.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_02.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_03.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_04.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_05.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_06.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_07.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_08.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_09.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_10.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_11.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_12.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_13.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exercise_14.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_03.cpp0000744000175000017500000002161512737416157026735 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_03.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_03.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_03.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_03::CExercise_03(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("03: Direct neighbours")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Simple neighbourhood analysis for grid cells.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT" , _TL("Input grid"), _TL("This must be your input data of type grid."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "OUTPUT" , _TL("Output"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL, "METHOD" , _TL("Method"), _TL("Choose a method"), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Difference to left neighbour"), _TL("Difference to left neighbour (using a while loop)"), _TL("Slope gradient to left neighbour [%%]"), _TL("Slope gradient to left neighbour [Degree]") ) ); } //--------------------------------------------------------- CExercise_03::~CExercise_03(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_03::On_Execute(void) { bool bResult; int Method; //----------------------------------------------------- // Get parameter settings... m_pInput = Parameters("INPUT" )->asGrid(); m_pOutput = Parameters("OUTPUT")->asGrid(); Method = Parameters("METHOD")->asInt(); //----------------------------------------------------- // Execute calculation... switch( Method ) { case 0: bResult = Method_01(); break; case 1: bResult = Method_02(); break; case 2: bResult = Method_03(); break; case 3: bResult = Method_04(); break; default: bResult = false; } //----------------------------------------------------- // Return 'true' if everything went okay... return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_03::Method_01(void) { int x, y, ix; double a, b, c; //----------------------------------------------------- for(y=0; yis_NoData(x, y) || m_pInput->is_NoData(ix, y) ) // don't work with 'no data'... { m_pOutput->Set_NoData(x, y); } else { a = m_pInput->asDouble( x, y); b = m_pInput->asDouble(ix, y); c = a - b; m_pOutput->Set_Value(x, y, c); } } m_pOutput->Set_NoData(Get_NX() - 1, y); // what shall we do with the last cell in a row ??!! } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_03::Method_02(void) { int x, y, ix; double a, b, c; //----------------------------------------------------- for(y=0; yis_NoData(x, y) || m_pInput->is_NoData(ix, y) ) // don't work with 'no data'... { m_pOutput->Set_NoData(x, y); } else { a = m_pInput->asDouble( x, y); b = m_pInput->asDouble(ix, y); c = a - b; m_pOutput->Set_Value(x, y, c); } x++; // increment x... } m_pOutput->Set_NoData(Get_NX() - 1, y); // what shall we do with the last cell in a row ??!! } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_03::Method_03(void) { int x, y, ix; double a, b, c; //----------------------------------------------------- for(y=0; yis_NoData(x, y) || m_pInput->is_NoData(ix, y) ) // don't work with 'no data'... { m_pOutput->Set_NoData(x, y); } else { a = m_pInput->asDouble( x, y); b = m_pInput->asDouble(ix, y); c = 100.0 * (a - b) / Get_Cellsize(); m_pOutput->Set_Value(x, y, c); } } m_pOutput->Set_NoData(x, y); // what shall we do with the last cell in a row ??!! } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_03::Method_04(void) { int x, y, ix; double a, b, c; //----------------------------------------------------- for(y=0; yis_NoData(x, y) || m_pInput->is_NoData(ix, y) ) // don't work with 'no data'... { m_pOutput->Set_NoData(x, y); } else { a = m_pInput->asDouble( x, y); b = m_pInput->asDouble(ix, y); c = atan((a - b) / Get_Cellsize()) * 180.0 / M_PI; m_pOutput->Set_Value(x, y, c); } } m_pOutput->Set_NoData(x, y); // what shall we do with the last cell in a row ??!! } //----------------------------------------------------- return( true ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_05.cpp0000744000175000017500000002341312737416157026735 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_05.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_05.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_05.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_05::CExercise_05(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("05: Direct neighbours - slope and aspect")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Simple neighbourhood analysis for grid cells.\n" "- Zevenbergen, L.W. / Thorne, C.R. (1987):\n" " 'Quantitative analysis of land surface topography',\n" " Earth Surface Processes and Landforms, 12: 47-56.\n\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "ELEVATION" , _TL("Input grid"), _TL("This must be your input data of type grid."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "SLOPE" , _TL("Slope"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "ASPECT" , _TL("Aspect"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL, "METHOD" , _TL("Method"), _TL("Choose a method"), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Steepest gradient (first version)"), _TL("Steepest gradient (second version)"), _TL("Zevenbergen & Thorne") ) ); } //--------------------------------------------------------- CExercise_05::~CExercise_05(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_05::On_Execute(void) { bool bResult; int Method; //----------------------------------------------------- // Get parameter settings... m_pDTM = Parameters("ELEVATION")->asGrid(); m_pSlope = Parameters("SLOPE" )->asGrid(); m_pAspect = Parameters("ASPECT" )->asGrid(); Method = Parameters("METHOD")->asInt(); m_pSlope ->Set_Unit(_TL("radians")); m_pAspect ->Set_Unit(_TL("radians")); //----------------------------------------------------- // Execute calculation... switch( Method ) { case 0: bResult = Method_01(); break; case 1: bResult = Method_02(); break; default: bResult = false; } //----------------------------------------------------- // Return 'true' if everything went okay... return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_05::Method_01(void) { int x, y, i, ix, iy, iMax; double z, dz, dzMax, dx[2] = { Get_Cellsize(), sqrt(2.0) * Get_Cellsize() }; //----------------------------------------------------- for(y=0; yis_NoData(x, y) ) { m_pSlope ->Set_NoData(x, y); m_pAspect ->Set_NoData(x, y); } else { z = m_pDTM->asDouble(x, y); iMax = -1; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !m_pDTM->is_NoData(ix, iy) ) { dz = (z - m_pDTM->asDouble(ix, iy)) / dx[i % 2]; if( dz > 0.0 && (iMax < 0 || (iMax >= 0 && dzMax < dz)) ) { iMax = i; dzMax = dz; } } } if( iMax < 0 ) { m_pSlope ->Set_NoData(x, y); m_pAspect ->Set_NoData(x, y); } else { m_pSlope ->Set_Value(x, y, atan(dzMax)); m_pAspect ->Set_Value(x, y, M_PI_045 * iMax); } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_05::Method_02(void) { int x, y, i, ix, iy, iMax; double z, dz, dzMax; //----------------------------------------------------- for(y=0; yis_NoData(x, y) ) { m_pSlope ->Set_NoData(x, y); m_pAspect ->Set_NoData(x, y); } else { z = m_pDTM->asDouble(x, y); iMax = -1; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !m_pDTM->is_NoData(ix, iy) ) { dz = (z - m_pDTM->asDouble(ix, iy)) / Get_Length(i); if( dz > 0.0 && (iMax < 0 || (iMax >= 0 && dzMax < dz)) ) { iMax = i; dzMax = dz; } } } if( iMax < 0 ) { m_pSlope ->Set_NoData(x, y); m_pAspect ->Set_NoData(x, y); } else { m_pSlope ->Set_Value(x, y, atan(dzMax)); m_pAspect ->Set_Value(x, y, M_PI_045 * iMax); } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_05::Method_03(void) { static int x_To[] = { 0, 1, 0, -1 }, y_To[] = { 1, 0, -1, 0 }; int x, y, i, ix, iy; double z, dz[4], G, H, dx2; //----------------------------------------------------- dx2 = 2.0 * Get_Cellsize(); //----------------------------------------------------- for(y=0; yis_NoData(x, y) ) { m_pSlope ->Set_NoData(x, y); m_pAspect ->Set_NoData(x, y); } //--------------------------------------------- else { z = m_pDTM->asDouble(x, y); for(i=0; i<4; i++) { ix = x + x_To[i]; iy = y + y_To[i]; if( m_pDTM->is_NoData(ix, iy) ) { dz[i] = 0.0; } else { dz[i] = m_pDTM->asDouble(ix, iy) - z; } } //----------------------------------------- G = (dz[0] - dz[2]) / dx2; H = (dz[1] - dz[3]) / dx2; m_pSlope ->Set_Value(x, y, atan(sqrt(G*G + H*H))); if( G != 0.0 ) { m_pAspect ->Set_Value(x, y, M_PI_180 + atan2(H, G)); } else if( H > 0.0 ) { m_pAspect ->Set_Value(x, y, M_PI_270); } else if( H < 0.0 ) { m_pAspect ->Set_Value(x, y, M_PI_090); } else { m_pAspect ->Set_NoData(x, y); } } } } //----------------------------------------------------- return( true ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_12.h0000744000175000017500000001022112737416157026371 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_12.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures_Shapes // // // //-------------------------------------------------------// // // // Exercise_12.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_12_H #define HEADER_INCLUDED__Exercise_12_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_12 : public CSG_Module { public: ////// public members and functions: ////////////// CExercise_12(void); // constructor virtual ~CExercise_12(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_12_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Makefile.am0000744000175000017500000000200312737416160026174 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libgarden_learn_to_program.la libgarden_learn_to_program_la_SOURCES =\ Exercise_01.cpp\ Exercise_02.cpp\ Exercise_03.cpp\ Exercise_04.cpp\ Exercise_05.cpp\ Exercise_06.cpp\ Exercise_07.cpp\ Exercise_08.cpp\ Exercise_09.cpp\ Exercise_10.cpp\ Exercise_11.cpp\ Exercise_12.cpp\ Exercise_13.cpp\ Exercise_14.cpp\ MLB_Interface.cpp\ Exercise_01.h\ Exercise_02.h\ Exercise_03.h\ Exercise_04.h\ Exercise_05.h\ Exercise_06.h\ Exercise_07.h\ Exercise_08.h\ Exercise_09.h\ Exercise_10.h\ Exercise_11.h\ Exercise_12.h\ Exercise_13.h\ Exercise_14.h\ MLB_Interface.h libgarden_learn_to_program_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_08.cpp0000744000175000017500000002001412737416157026732 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_08.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_08.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_08.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_08::CExercise_08(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("08: Extended neighbourhoods - catchment areas (parallel)")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Extended Neighbourhoods - Catchment areas.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "ELEVATION" , _TL("Elevation grid"), _TL("This must be your input data of type grid."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "AREA" , _TL("Catchment area"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL, "METHOD" , _TL("Method"), _TL("Choose a method"), CSG_String::Format(SG_T("%s|%s|"), _TL("D8"), _TL("MFD") ) ); } //--------------------------------------------------------- CExercise_08::~CExercise_08(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_08::On_Execute(void) { bool bResult; int Method; //----------------------------------------------------- // Get parameter settings... m_pDTM = Parameters("ELEVATION")->asGrid(); m_pArea = Parameters("AREA" )->asGrid(); Method = Parameters("METHOD")->asInt(); m_pArea ->Assign(0.0); m_pArea ->Set_Unit(SG_T("m\xc2\xb2")); DataObject_Set_Colors(m_pArea, 100, SG_COLORS_WHITE_BLUE); //----------------------------------------------------- // Execute calculation... switch( Method ) { case 0: bResult = Method_01(); break; case 1: bResult = Method_02(); break; default: bResult = false; } //----------------------------------------------------- // Return 'true' if everything went okay... return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_08::Method_01(void) { int x, y, i, ix, iy, iMax; double z, dz, dzMax, Area_of_Cell = Get_Cellsize() * Get_Cellsize(); //----------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y, true, false); if( m_pDTM->is_NoData(x, y) ) { m_pArea->Set_NoData(x, y); } else { m_pArea->Add_Value(x, y, Area_of_Cell); z = m_pDTM->asDouble(x, y); iMax = -1; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !m_pDTM->is_NoData(ix, iy) ) { dz = (z - m_pDTM->asDouble(ix, iy)) / Get_Length(i); if( dz > 0.0 && (iMax < 0 || (iMax >= 0 && dzMax < dz)) ) { iMax = i; dzMax = dz; } } } if( iMax >= 0 ) { ix = Get_xTo(iMax, x); iy = Get_yTo(iMax, y); m_pArea->Add_Value(ix, iy, m_pArea->asDouble(x, y)); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_08::Method_02(void) { int x, y, i, ix, iy; double z, d, dz[8], dzSum, Area_of_Cell = Get_Cellsize() * Get_Cellsize(), MFD_Converge = 1.1; //----------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y, true, false); if( m_pDTM->is_NoData(x, y) ) { m_pArea->Set_NoData(x, y); } else { m_pArea->Add_Value(x, y, Area_of_Cell); z = m_pDTM->asDouble(x, y); dzSum = 0.0; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !m_pDTM->is_NoData(ix, iy) && (d = z - m_pDTM->asDouble(ix, iy)) > 0.0 ) { dz[i] = pow(d / Get_Length(i), MFD_Converge); dzSum += dz[i]; } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { d = m_pArea->asDouble(x, y) / dzSum; for(i=0; i<8; i++) { if( dz[i] > 0.0 ) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); m_pArea->Add_Value(ix, iy, dz[i] * d); } } } } } //----------------------------------------------------- return( true ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_14.cpp0000744000175000017500000002376712737416160026743 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_14.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures_Shapes // // // //-------------------------------------------------------// // // // Exercise_14.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_14.h" /////////////////////////////////////////////////////////// // // // Defines // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define NOCHANNEL 0 #define SPRING 1 #define CHANNEL 2 #define MOUTH 3 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_14::CExercise_14(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("14: Vectorising channel lines")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Vectorising channel lines.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CHANNELS" , _TL("Channels (Raster)"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Channels (Vector)"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "THRESHOLD" , _TL("Threshold"), _TL(""), PARAMETER_TYPE_Int , 4, 0, true, 8, true ); } //--------------------------------------------------------- CExercise_14::~CExercise_14(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_14::On_Execute(void) { int Threshold; //----------------------------------------------------- m_pDTM = Parameters("ELEVATION") ->asGrid(); m_pChnl = Parameters("CHANNELS") ->asGrid(); m_pShapes = Parameters("SHAPES") ->asShapes(); Threshold = Parameters("THRESHOLD") ->asInt(); //----------------------------------------------------- m_pDir = NULL; if( Initialise(Threshold) ) { Find_Channels(); Vectorise(); } //----------------------------------------------------- if( m_pDir ) { delete(m_pDir); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_14::Initialise(int Threshold) { int x, y, i, ix, iy, Dir; double z, dz, dzMax; CSG_Colors Colors; //----------------------------------------------------- m_pDir = new CSG_Grid(m_pDTM, SG_DATATYPE_Char); m_pChnl->Assign(); Colors.Set_Count(4); Colors.Set_Color(0, 192, 192, 192); // NOCHANNEL Colors.Set_Color(1, 0, 255, 0); // SPRING Colors.Set_Color(2, 0, 0, 255); // CHANNEL Colors.Set_Color(3, 255, 0, 0); // MOUTH DataObject_Set_Colors(m_pChnl, Colors); //----------------------------------------------------- for(y=0; yis_NoData(x, y) ) { z = m_pDTM->asDouble(x, y); dzMax = 0.0; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !m_pDTM->is_NoData(ix, iy) ) { dz = (z - m_pDTM->asDouble(ix, iy)) / Get_Length(i); if( dz > dzMax ) { dzMax = dz; Dir = i; } } } } //--------------------------------------------- m_pDir->Set_Value(x, y, Dir); if( Dir >= 0 ) { m_pChnl->Add_Value(Get_xTo(Dir, x), Get_yTo(Dir, y), 1); } } } //----------------------------------------------------- for(y=0; ySet_Value(x, y, m_pChnl->asInt(x, y) >= Threshold ? SPRING : NOCHANNEL); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CExercise_14::Find_Channels(void) { int x, y; for(sLong n=0; nGet_Sorted(n, x, y, true) && m_pChnl->asInt(x, y) == SPRING ) { m_pChnl ->Set_Value(x, y, SPRING); Find_Channels(x, y); } } } //--------------------------------------------------------- void CExercise_14::Find_Channels(int x, int y) { int Dir, ix, iy; if( (Dir = m_pDir->asInt(x, y)) >= 0 ) { ix = Get_xTo(Dir, x); iy = Get_yTo(Dir, y); switch( m_pChnl->asInt(ix, iy) ) { case NOCHANNEL: case SPRING: m_pChnl ->Set_Value(ix, iy, CHANNEL); Find_Channels(ix, iy); // recursive function call... break; case CHANNEL: m_pChnl ->Set_Value(ix, iy, MOUTH); break; } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CExercise_14::Vectorise(void) { int x, y, Segment_ID; double Length; CSG_Shape *pSegment; m_pShapes->Create(SHAPE_TYPE_Line, _TL("Channels")); m_pShapes->Add_Field("SEGMENT_ID" , SG_DATATYPE_Int); m_pShapes->Add_Field("LENGTH" , SG_DATATYPE_Double); //----------------------------------------------------- for(y=0, Segment_ID=0; yasInt(x, y) ) { case SPRING: case MOUTH: pSegment = m_pShapes->Add_Shape(); Length = Vectorise(x, y, pSegment); if( Length > 0.0 ) { pSegment->Set_Value(0, ++Segment_ID); pSegment->Set_Value(1, Length); } else { m_pShapes->Del_Shape(pSegment); } break; } } } } //--------------------------------------------------------- double CExercise_14::Vectorise(int x, int y, CSG_Shape *pSegment) { int Dir, ix, iy; double Length; Length = 0.0; pSegment->Add_Point(Get_XMin() + x * Get_Cellsize(), Get_YMin() + y * Get_Cellsize()); if( (Dir = m_pDir->asInt(x, y)) >= 0 ) { Length = Get_Length(Dir); ix = Get_xTo(Dir, x); iy = Get_yTo(Dir, y); switch( m_pChnl->asInt(ix, iy) ) { case CHANNEL: Length += Vectorise(ix, iy, pSegment); // recursive function call... break; case MOUTH: Length += Get_Length(Dir); pSegment->Add_Point(Get_XMin() + ix * Get_Cellsize(), Get_YMin() + iy * Get_Cellsize()); break; } } return( Length ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_02.h0000744000175000017500000001022612737416157026375 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_02.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_02.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_02_H #define HEADER_INCLUDED__Exercise_02_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_02 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CExercise_02(void); // constructor virtual ~CExercise_02(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_02_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_10.h0000744000175000017500000001005312737416157026372 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_10.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_10.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_10_H #define HEADER_INCLUDED__Exercise_10_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CExercise_10 : public CSG_Module_Grid { public: CExercise_10(void); virtual ~CExercise_10(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual bool On_Execute(void); private: int m_nColors; CSG_Grid *m_pLife, *m_pTemp; bool Next_Step(void); }; #endif // #ifndef HEADER_INCLUDED__Exercise_10_H saga-2.3.1/src/modules/garden/garden_learn_to_program/MLB_Interface.h0000744000175000017500000000740512737416160026716 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__lectures_H #define HEADER_INCLUDED__lectures_H //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__lectures_H saga-2.3.1/src/modules/garden/garden_learn_to_program/MLB_Interface.cpp0000744000175000017500000001353612737416160027253 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Introducing Module Programming" )); case MLB_INFO_Category: return( _TL("Garden") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2003" )); case MLB_INFO_Description: return( _TL("A set of basic SAGA module programming examples." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Garden|Introducing Module Programming" )); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Exercise_01.h" #include "Exercise_02.h" #include "Exercise_03.h" #include "Exercise_04.h" #include "Exercise_05.h" #include "Exercise_06.h" #include "Exercise_07.h" #include "Exercise_08.h" #include "Exercise_09.h" #include "Exercise_10.h" #include "Exercise_11.h" #include "Exercise_12.h" #include "Exercise_13.h" #include "Exercise_14.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { // Don't forget to continuously enumerate the case switches // when adding new modules! Also bear in mind that the // enumeration always has to start with [case 0:] and // that [default:] must return NULL!... CSG_Module *pModule; switch( i ) { case 0: pModule = new CExercise_01; break; case 1: pModule = new CExercise_02; break; case 2: pModule = new CExercise_03; break; case 3: pModule = new CExercise_04; break; case 4: pModule = new CExercise_05; break; case 5: pModule = new CExercise_06; break; case 6: pModule = new CExercise_07; break; case 7: pModule = new CExercise_08; break; case 8: pModule = new CExercise_09; break; case 9: pModule = new CExercise_10; break; case 10: pModule = new CExercise_11; break; case 11: pModule = new CExercise_12; break; case 12: pModule = new CExercise_13; break; case 13: pModule = new CExercise_14; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_04.cpp0000744000175000017500000002455412737416157026743 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_04.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_04.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_04.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_04::CExercise_04(void) { //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("04: Direct neighbours - more...")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Simple neighbourhood analysis for grid cells.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT" , _TL("Input grid"), _TL("This must be your input data of type grid."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "OUTPUT" , _TL("Output"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL, "METHOD" , _TL("Method"), _TL("Choose a method"), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("Arithmetic mean (version 1)"), _TL("Arithmetic mean (version 2)"), _TL("Difference from all neighbour's mean"), _TL("Variance (version 1)"), _TL("Variance (version 2)"), _TL("Standard deviation") ) ); } //--------------------------------------------------------- CExercise_04::~CExercise_04(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_04::On_Execute(void) { bool bResult; int Method; //----------------------------------------------------- // Get parameter settings... m_pInput = Parameters("INPUT" )->asGrid(); m_pOutput = Parameters("OUTPUT")->asGrid(); Method = Parameters("METHOD")->asInt(); //----------------------------------------------------- // Execute calculation... switch( Method ) { case 0: bResult = Method_01(); break; case 1: bResult = Method_02(); break; case 2: bResult = Method_03(); break; case 3: bResult = Method_04(); break; case 4: bResult = Method_05(); break; case 5: bResult = Method_06(); break; default: bResult = false; } //----------------------------------------------------- // Return 'true' if everything went okay... return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_04::Method_01(void) { int x, y, ix, iy, n; double s; //----------------------------------------------------- for(y=0; yis_NoData(ix, iy) ) { s += m_pInput->asDouble(ix, iy); n++; } } } if( n > 0 ) { m_pOutput->Set_Value(x, y, s / n); } else { m_pOutput->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_04::Method_02(void) { int x, y, i, ix, iy, n; double s; //----------------------------------------------------- for(y=0; yis_NoData(x, y) ) { m_pOutput->Set_NoData(x, y); } else { s = m_pInput->asDouble(x, y); n = 1; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !m_pInput->is_NoData(ix, iy) ) { s += m_pInput->asDouble(ix, iy); n++; } } m_pOutput->Set_Value(x, y, s / n); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_04::Method_03(void) { int x, y, i, ix, iy, n; double s; //----------------------------------------------------- for(y=0; yis_NoData(x, y) ) { m_pOutput->Set_NoData(x, y); } else { s = 0.0; n = 0; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !m_pInput->is_NoData(ix, iy) ) { s += m_pInput->asDouble(ix, iy); n++; } } if( n > 0 ) { m_pOutput->Set_Value(x, y, m_pInput->asDouble(x, y) - s / n); } else { m_pOutput->Set_NoData(x, y); } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_04::Method_04(void) { int x, y, i, ix, iy, n; double m, v, z[9], dz; //----------------------------------------------------- for(y=0; yis_NoData(ix, iy) ) { z[n++] = m_pInput->asDouble(ix, iy); } } } if( n > 0 ) { for(m=0.0, i=0; iSet_Value(x, y, v); } else { m_pOutput->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_04::Method_05(void) { int x, y, ix, iy, n; double m, v, z; //----------------------------------------------------- for(y=0; yis_NoData(ix, iy) ) { n++; z = m_pInput->asDouble(ix, iy); m += z; v += z * z; } } } if( n > 0 ) { m = m / n; v = v / n - m * m; m_pOutput->Set_Value(x, y, v); } else { m_pOutput->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CExercise_04::Method_06(void) { //----------------------------------------------------- if( Method_05() == false ) { return( false ); } //----------------------------------------------------- for(sLong n=0; nis_NoData(n) == false ) { double v = m_pOutput->asDouble(n); m_pOutput->Set_Value(n, sqrt(v)); } } //----------------------------------------------------- return( true ); } saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_09.h0000744000175000017500000001024712737416157026407 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_09.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_09.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Exercise_09_H #define HEADER_INCLUDED__Exercise_09_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CExercise_09 : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CExercise_09(void); // constructor virtual ~CExercise_09(void); // destructor protected: /// protected members and functions: /////////// virtual bool On_Execute(void); // always override this function private: ///// private members and functions: ///////////// CSG_Grid *m_pArea, *m_pDir; double Get_Area(int x, int y); }; //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Exercise_09_H saga-2.3.1/src/modules/garden/garden_learn_to_program/Exercise_07.cpp0000744000175000017500000002157412737416157026745 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Exercise_07.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // Exercise_07.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Exercise_07.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CExercise_07::CExercise_07(void) { CSG_Parameter *pNode; //----------------------------------------------------- // Give some information about your module... Set_Name (_TL("07: Extended neighbourhoods - catchment areas (trace flow)")); Set_Author (_TL("Copyrights (c) 2003 by Olaf Conrad")); Set_Description (_TW( "Extended Neighbourhoods - Catchment areas.\n" "(c) 2003 by Olaf Conrad, Goettingen\n" "email: oconrad@gwdg.de") ); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL , "ELEVATION" , _TL("Elevation grid"), _TL("This must be your input data of type grid."), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "AREA" , _TL("Catchment area"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "LENGTH" , _TL("Flow Path Length"), _TL("This will contain your output data of type grid."), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "STEP" , _TL("Step"), _TL("Skip cells (step value)."), PARAMETER_TYPE_Int , 1, 1, true ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Method"), _TL("Choose a method"), CSG_String::Format(SG_T("%s|%s|"), _TL("Needs less memory, but is slow"), _TL("Needs more memory, but is quicker") ) ); pNode = Parameters.Add_Value( NULL , "ONECELL" , _TL("Single Cell"), _TL("Set \'false\' to execute the calculation for each point in grid. Set \'true\' tu calculate the flow of one single cell."), PARAMETER_TYPE_Bool , false ); Parameters.Add_Value( pNode , "XCELL" , _TL("X Position"), _TL(""), PARAMETER_TYPE_Int ); Parameters.Add_Value( pNode , "YCELL" , _TL("Y Position"), _TL(""), PARAMETER_TYPE_Int ); } //--------------------------------------------------------- CExercise_07::~CExercise_07(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CExercise_07::On_Execute(void) { bool bCell; int x, y, Step, xCell, yCell; CSG_Grid *pLength; //----------------------------------------------------- // Get parameter settings... m_pDTM = Parameters("ELEVATION")->asGrid(); m_pArea = Parameters("AREA" )->asGrid(); pLength = Parameters("LENGTH" )->asGrid(); Step = Parameters("STEP" )->asInt(); m_Method = Parameters("METHOD" )->asInt(); bCell = Parameters("ONECELL" )->asBool(); xCell = Parameters("XCELL" )->asInt(); yCell = Parameters("YCELL" )->asInt(); //----------------------------------------------------- // General initialisations... m_pArea ->Assign(0.0); m_pArea ->Set_Unit(SG_T("m\xc2\xb2")); DataObject_Set_Colors(m_pArea, 100, SG_COLORS_WHITE_BLUE); pLength ->Assign(0.0); pLength ->Set_Unit(SG_T("m")); m_Area_of_Cell = Get_Cellsize() * Get_Cellsize(); //----------------------------------------------------- // Special initialisations... switch( m_Method ) { case 0: default: // Needs less memory, but is slow... m_pDir = NULL; break; case 1: // Needs more memory, but is quicker... m_pDir = new CSG_Grid(m_pDTM, SG_DATATYPE_Char); for(y=0; ySet_Value(x, y, Get_FlowDirection(x, y)); } } break; } //----------------------------------------------------- // Execute calculation... if( bCell ) { pLength->Set_Value(xCell, yCell, Trace_Flow(xCell, yCell)); } else { for(y=0; ySet_Value(x, y, Trace_Flow(x, y)); } } } //----------------------------------------------------- // Special finalisations... if( m_pDir != NULL ) { delete(m_pDir); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CExercise_07::Get_FlowDirection(int x, int y) { int i, ix, iy, iMax; double z, dz, dzMax; iMax = -1; if( is_InGrid(x, y) && !m_pDTM->is_NoData(x, y) ) { z = m_pDTM->asDouble(x, y); dzMax = 0.0; for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && !m_pDTM->is_NoData(ix, iy) ) { dz = (z - m_pDTM->asDouble(ix, iy)) / Get_Length(i); if( dz > dzMax ) { dzMax = dz; iMax = i; } } } } return( iMax ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CExercise_07::Trace_Flow(int x, int y) { int Direction; double Length; Length = 0.0; if( is_InGrid(x, y) && !m_pDTM->is_NoData(x, y) ) { do { m_pArea->Add_Value(x, y, m_Area_of_Cell); Direction = m_pDir != NULL ? m_pDir->asInt(x, y) : Get_FlowDirection(x, y); if( Direction >= 0 ) { x = Get_xTo(Direction, x); y = Get_yTo(Direction, y); Length += Get_Length(Direction); } } while( Direction >= 0 ); } return( Length ); } saga-2.3.1/src/modules/garden/garden_webservices/0000775000175000017500000000000012737740003023131 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/garden/garden_webservices/osm_import.cpp0000744000175000017500000003111212737416160026026 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // garden_webservices // // // //-------------------------------------------------------// // // // osm_import.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include #include "osm_import.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- COSM_Import::COSM_Import(void) { Set_Name (_TL("Import from Open Street Map")); Set_Author (SG_T("O. Conrad (c) 2010")); Set_Description (_TW( "This module works as Web Map Service (WMS) client. " "More information on the WMS specifications can be obtained from the " "Open Geospatial Consortium (OGC) at " "http://www.opengeospatial.org/. " )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "POINTS" , _TL("OSM Locations"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Shapes( NULL , "WAYS" , _TL("OSM Ways"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "RELATIONS" , _TL("OSM Relations"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Line ); Parameters.Add_Shapes( NULL , "AREAS" , _TL("OSM Areas"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); //----------------------------------------------------- Parameters.Add_String( NULL , "USERNAME" , _TL("User Name"), _TL(""), SG_T("") ); Parameters.Add_String( NULL , "PASSWORD" , _TL("Password"), _TL(""), SG_T(""), false, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool COSM_Import::On_Execute(void) { //----------------------------------------------------- m_pPoints = Parameters("POINTS") ->asShapes(); m_pWays = Parameters("WAYS") ->asShapes(); m_pAreas = Parameters("AREAS") ->asShapes(); m_bDown = false; //----------------------------------------------------- wxHTTP Server; Server.SetUser (Parameters("USERNAME")->asString()); Server.SetPassword (Parameters("PASSWORD")->asString()); if( Server.Connect(SG_T("api.openstreetmap.org")) == false ) { Message_Add(_TL("Unable to connect to server.")); return( false ); } //----------------------------------------------------- //----------------------------------------------------- // // Request.Set_Name(SG_T("osm")); // Request.Add_Property(SG_T("version") , SG_T("0.6")); // Request.Add_Property(SG_T("generator") , SG_T("OpenStreetMap server")); // SG_T("api/capabilities"); // http://api.openstreetmap.org/api/0.6/map?bbox=10.0,53.0,10.1,53.1 return( true ); } //--------------------------------------------------------- bool COSM_Import::On_Execute_Finish(void) { return( true ); } //--------------------------------------------------------- bool COSM_Import::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { switch( Mode ) { //----------------------------------------------------- case MODULE_INTERACTIVE_LDOWN: if( m_bDown == false ) { m_bDown = true; m_ptDown = ptWorld; } break; //----------------------------------------------------- case MODULE_INTERACTIVE_LUP: if( m_bDown == true ) { m_bDown = false; wxHTTP Server; // Server.SetUser (Parameters("USERNAME")->asString()); // Server.SetPassword (Parameters("PASSWORD")->asString()); Server.SetUser (SG_T("")); Server.SetPassword (SG_T("")); if( Server.Connect(SG_T("api.openstreetmap.org")) == false ) { Message_Add(_TL("Unable to connect to server.")); return( false ); } CSG_Rect r(m_ptDown, ptWorld); wxInputStream *pStream = Server.GetInputStream(wxString::Format(SG_T("/api/0.6/map?bbox=%f,%f,%f,%f"), r.Get_XMin(), r.Get_YMin(), r.Get_XMax(), r.Get_YMax()) ); if( (pStream ) == NULL ) { Message_Add(_TL("received empty stream.")); return( false ); } Process_Set_Text(_TL("loading OSM data")); wxXmlDocument XML; if( !XML.Load(*pStream) ) { return( false ); } Process_Set_Text(_TL("ready")); if( !Load_Nodes(XML.GetRoot()) ) { return( false ); } Load_Ways(XML.GetRoot()); DataObject_Update(m_pPoints); DataObject_Update(m_pWays); DataObject_Update(m_pAreas); m_Nodes.Destroy(); } break; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool COSM_Import::Load_Nodes(wxXmlNode *pRoot) { long id; double lon, lat; wxString sValue; //----------------------------------------------------- m_Nodes.Destroy(); m_Nodes.Add_Field(SG_T("ID") , SG_DATATYPE_DWord); m_Nodes.Add_Field(SG_T("LON") , SG_DATATYPE_Double); m_Nodes.Add_Field(SG_T("LAT") , SG_DATATYPE_Double); m_pPoints->Create(SHAPE_TYPE_Point, SG_T("OSM Locations")); m_pPoints->Add_Field(SG_T("ID"), SG_DATATYPE_DWord); //----------------------------------------------------- wxXmlNode *pNode = pRoot->GetChildren(); while( pNode ) { if( !pNode->GetName().CmpNoCase(SG_T("node")) ) { if( pNode->GetAttribute(SG_T("id" ), &sValue) && sValue.ToLong (&id) && pNode->GetAttribute(SG_T("lon"), &sValue) && sValue.ToDouble(&lon) && pNode->GetAttribute(SG_T("lat"), &sValue) && sValue.ToDouble(&lat) ) { wxXmlNode *pTag = pNode->GetChildren(); if( !pTag || !pTag->GetName().CmpNoCase(SG_T("created_by")) ) { CSG_Table_Record *pRecord = m_Nodes.Add_Record(); pRecord->Set_Value(0, id); pRecord->Set_Value(1, lon); pRecord->Set_Value(2, lat); } else { CSG_Shape *pShape = m_pPoints->Add_Shape(); pShape->Add_Point(lon, lat); pShape->Set_Value(0, id); } } } pNode = pNode->GetNext(); } m_Nodes.Set_Index(0, TABLE_INDEX_Ascending); //----------------------------------------------------- return( m_Nodes.Get_Count() > 0 ); } //--------------------------------------------------------- bool COSM_Import::Find_Node(long id, double &lon, double &lat) { CSG_Table_Record *pRecord = Find_Node(id); if( pRecord ) { lon = pRecord->asDouble(1); lat = pRecord->asDouble(2); return( true ); } return( false ); } //--------------------------------------------------------- CSG_Table_Record * COSM_Import::Find_Node(long id) { int a, b, d, i; if( m_Nodes.Get_Count() == 1 ) { if( m_Nodes.Get_Record_byIndex(0)->asInt(0) == id ) { return( m_Nodes.Get_Record_byIndex(0) ); } } else if( m_Nodes.Get_Count() > 1 ) { a = 0; if( id < (d = m_Nodes.Get_Record_byIndex(a)->asInt(0)) ) return( NULL ); if( id == d ) return( m_Nodes.Get_Record_byIndex(a) ); b = m_Nodes.Get_Count() - 1; if( id > (d = m_Nodes.Get_Record_byIndex(b)->asInt(0)) ) return( NULL ); if( id == d ) return( m_Nodes.Get_Record_byIndex(b) ); for( ; b - a > 1; ) { i = a + (b - a) / 2; d = m_Nodes.Get_Record_byIndex(i)->asInt(0); if( id > d ) { a = i; } else if( id < d ) { b = i; } else { return( m_Nodes.Get_Record_byIndex(i) ); } } } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool COSM_Import::Load_Ways(wxXmlNode *pRoot) { long id, idnode, Nodes[2000], nNodes; wxString sValue; //----------------------------------------------------- m_pWays ->Create(SHAPE_TYPE_Line , SG_T("OSM Ways")); m_pWays ->Add_Field(SG_T("ID"), SG_DATATYPE_DWord); m_pAreas ->Create(SHAPE_TYPE_Polygon , SG_T("OSM Areas")); m_pAreas ->Add_Field(SG_T("ID"), SG_DATATYPE_DWord); //----------------------------------------------------- wxXmlNode *pNode = pRoot->GetChildren(); while( pNode ) { if( !pNode->GetName().CmpNoCase(SG_T("way")) ) { if( pNode->GetAttribute(SG_T("id" ), &sValue) && sValue.ToLong (&id) ) { wxXmlNode *pChild = pNode->GetChildren(); nNodes = 0; while( pChild ) { if( !pChild->GetName().CmpNoCase(SG_T("nd")) && pChild->GetAttribute(SG_T("ref"), &sValue) && sValue.ToLong(&idnode) ) { Nodes[nNodes++] = idnode; } pChild = pChild->GetNext(); } if( nNodes > 1 ) { CSG_Shape *pShape = Nodes[0] == Nodes[nNodes - 1] ? m_pAreas->Add_Shape() : m_pWays->Add_Shape(); for(int i=0; iAdd_Point(lon, lat); } } } } } pNode = pNode->GetNext(); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_webservices/osm_import.h0000744000175000017500000001134712737416160025503 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // garden_webservices // // // //-------------------------------------------------------// // // // osm_import.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__OSM_Import_H #define HEADER_INCLUDED__OSM_Import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class COSM_Import : public CSG_Module_Interactive { public: COSM_Import(void); protected: virtual bool On_Execute (void); virtual bool On_Execute_Finish (void); virtual bool On_Execute_Position (CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: bool m_bDown; CSG_Point m_ptDown; CSG_Table m_Nodes; CSG_Shapes *m_pPoints, *m_pWays, *m_pAreas; bool Load_Nodes (class wxXmlNode *pRoot); bool Find_Node (long id, double &lon, double &lat); CSG_Table_Record * Find_Node (long id); bool Load_Ways (class wxXmlNode *pRoot); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__OSM_Import_H saga-2.3.1/src/modules/garden/garden_webservices/wms_import.h0000744000175000017500000001245112737416160025510 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // garden_webservices // // // //-------------------------------------------------------// // // // wms_import.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__WMS_Import_H #define HEADER_INCLUDED__WMS_Import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWMS_Capabilities { public: CWMS_Capabilities(void); CWMS_Capabilities(const CSG_String &Server, const CSG_String &Version); virtual ~CWMS_Capabilities(void); bool Create (const CSG_String &Server, const CSG_String &Version); void Destroy (void); TSG_Rect m_Extent; int m_MaxWidth, m_MaxHeight, m_LayerLimit; CSG_String m_Name, m_Version, m_Title, m_Abstract, m_Formats, m_Projections; CSG_Strings m_Layers_Name, m_Layers_Title; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWMS_Import : public CSG_Module { public: CWMS_Import(void); protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool Do_Dialog (CWMS_Capabilities &Cap); bool Get_Map (class wxHTTP *pServer, const CSG_String &Version, CWMS_Capabilities &Cap); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__WMS_Import_H saga-2.3.1/src/modules/garden/garden_webservices/Makefile.in0000664000175000017500000005566312737447615025232 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/garden/garden_webservices ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libgarden_webservices_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libgarden_webservices_la_OBJECTS = MLB_Interface.lo osm_import.lo \ wms_import.lo libgarden_webservices_la_OBJECTS = \ $(am_libgarden_webservices_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libgarden_webservices_la_SOURCES) DIST_SOURCES = $(libgarden_webservices_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libgarden_webservices.la libgarden_webservices_la_SOURCES = \ MLB_Interface.cpp\ osm_import.cpp\ wms_import.cpp\ MLB_Interface.h\ osm_import.h\ wms_import.h libgarden_webservices_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/garden/garden_webservices/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/garden/garden_webservices/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libgarden_webservices.la: $(libgarden_webservices_la_OBJECTS) $(libgarden_webservices_la_DEPENDENCIES) $(EXTRA_libgarden_webservices_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libgarden_webservices_la_OBJECTS) $(libgarden_webservices_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/osm_import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wms_import.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/garden/garden_webservices/Makefile.am0000744000175000017500000000127712737416160025177 0ustar00oconradoconrad00000000000000if DEBUG DBGFLAGS = -g -DDEBUG endif DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = $(DEP_LFLG) -avoid-version pkglib_LTLIBRARIES = libgarden_webservices.la libgarden_webservices_la_SOURCES =\ MLB_Interface.cpp\ osm_import.cpp\ wms_import.cpp\ MLB_Interface.h\ osm_import.h\ wms_import.h libgarden_webservices_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/garden/garden_webservices/MLB_Interface.h0000744000175000017500000000674112737416160025707 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // garden_webservices // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__MLB_INTERFACE_H #define HEADER_INCLUDED__MLB_INTERFACE_H //--------------------------------------------------------- #include //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__MLB_INTERFACE_H saga-2.3.1/src/modules/garden/garden_webservices/wms_import.cpp0000744000175000017500000004630612737416160026051 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // garden_webservices // // // //-------------------------------------------------------// // // // wms_import.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include #include "wms_import.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWMS_Capabilities::CWMS_Capabilities(void) {} CWMS_Capabilities::CWMS_Capabilities(const CSG_String &Server, const CSG_String &Version) { Create(Server, Version); } //--------------------------------------------------------- CWMS_Capabilities::~CWMS_Capabilities(void) { Destroy(); } //--------------------------------------------------------- void CWMS_Capabilities::Destroy(void) { m_Name .Clear(); m_Title .Clear(); m_Abstract .Clear(); m_Formats .Clear(); m_Projections .Clear(); m_Layers_Name .Clear(); m_Layers_Title.Clear(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define V_SRS(Version) (Version.Find("1.3" ) == 0 ? "CRS" : "SRS" ) #define S_SRS(Version) (Version.Cmp ("1.3.0") == 0 ? "&CRS=" : "&SRS=" ) #define V_MAP(Version) (Version.Cmp ("1.0.0") == 0 ? "Map" : "GetMap") //--------------------------------------------------------- #define CAP_GET_STRING(GROUP, ID, VALUE, MUSTEXIST) if( GROUP(ID) ) VALUE = GROUP[ID].Get_Content(); else if( !MUSTEXIST ) VALUE = SG_T(""); else return( false ); #define CAP_GET_DOUBLE(GROUP, ID, VALUE, MUSTEXIST) if( GROUP(ID) ) VALUE = GROUP[ID].Get_Content().asDouble(); else if( !MUSTEXIST ) VALUE = 0.0; else return( false ); #define CAP_GET____INT(GROUP, ID, VALUE, MUSTEXIST) if( GROUP(ID) ) VALUE = GROUP[ID].Get_Content().asInt (); else if( !MUSTEXIST ) VALUE = 0; else return( false ); //--------------------------------------------------------- bool CWMS_Capabilities::Create(const CSG_String &Server, const CSG_String &Version) { Destroy(); int i; CSG_String s = "http://" + Server; s += "?SERVICE=WMS"; s += "&VERSION=" + Version; s += "&REQUEST=GetCapabilities"; CSG_MetaData Capabilities; if( !Capabilities.Create(s) ) { return( false ); } //----------------------------------------------------- if( !Capabilities.Get_Property("version", m_Version) || !Capabilities("Service") || !Capabilities("Capability") ) { return( false ); } const CSG_MetaData &Service = Capabilities["Service"]; CAP_GET_STRING(Service, "Name" , m_Name , true); CAP_GET_STRING(Service, "Title" , m_Title , true); CAP_GET_STRING(Service, "Abstract" , m_Abstract , true); CAP_GET____INT(Service, "LayerLimit", m_LayerLimit, false); CAP_GET____INT(Service, "MaxWidth" , m_MaxWidth , false); CAP_GET____INT(Service, "MaxHeight" , m_MaxHeight , false); //----------------------------------------------------- if( !Capabilities["Capability"]("Request") || !Capabilities["Capability"]["Request"](V_MAP(m_Version)) ) { return( false ); } const CSG_MetaData &GetMap = Capabilities["Capability"]["Request"][V_MAP(m_Version)]; for(i=0; ihttp://www.opengeospatial.org/. " )); //----------------------------------------------------- Parameters.Add_Grid_Output( NULL , "MAP" , _TL("WMS Map"), _TL("") ); //----------------------------------------------------- Parameters.Add_String( NULL , "SERVER" , _TL("Server"), _TL(""), // SG_T("www.gaia-mv.de/dienste/DTK10f") // 260000.0x, 5950000.0y Cellsize 1.0 // SG_T("www.gis2.nrw.de/wmsconnector/wms/stobo") // SG_T("www2.demis.nl/mapserver/request.asp") // SG_T("www.geoserver.nrw.de/GeoOgcWms1.3/servlet/TK25") // SG_T("www.geographynetwork.com/servlet/com.esri.wms.Esrimap") SG_T("ogc.bgs.ac.uk/cgi-bin/BGS_Bedrock_and_Superficial_Geology/wms") // WGS84: Center -3.5x 55.0y Cellsize 0.005 ); Parameters.Add_String(NULL, "USERNAME", _TL("User Name"), _TL(""), ""); Parameters.Add_String(NULL, "PASSWORD", _TL("Password" ), _TL(""), "", false, true); //----------------------------------------------------- Parameters.Add_Info_String(NULL, "ABSTRACT", _TL("Abstract"), _TL(""), "", true); Parameters.Add_Value (NULL, "GCS_XMIN", _TL("Left" ), _TL(""), PARAMETER_TYPE_Double); Parameters.Add_Value (NULL, "GCS_XMAX", _TL("Right" ), _TL(""), PARAMETER_TYPE_Double); Parameters.Add_Value (NULL, "GCS_YMIN", _TL("Bottom" ), _TL(""), PARAMETER_TYPE_Double); Parameters.Add_Value (NULL, "GCS_YMAX", _TL("Top" ), _TL(""), PARAMETER_TYPE_Double); Parameters.Add_Choice (NULL, "LAYER" , _TL("Layer" ), _TL(""), ""); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CWMS_Import::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "SERVER") ) { CWMS_Capabilities Capabilities; if( Capabilities.Create(pParameter->asString(), "1.1.1") ) { pParameters->Set_Parameter("ABSTRACT", Capabilities.m_Abstract ); pParameters->Set_Parameter("GCS_XMIN", Capabilities.m_Extent.xMin); pParameters->Set_Parameter("GCS_XMAX", Capabilities.m_Extent.xMax); pParameters->Set_Parameter("GCS_YMIN", Capabilities.m_Extent.yMin); pParameters->Set_Parameter("GCS_YMAX", Capabilities.m_Extent.yMax); CSG_String Items; for(int i=0; iGet_Parameter("LAYER")->asChoice()->Set_Items(Items); } } return( CSG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CWMS_Import::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWMS_Import::On_Execute(void) { CSG_String sServer = Parameters("SERVER")->asString(); //----------------------------------------------------- CWMS_Capabilities Capabilities; if( Capabilities.Create(sServer, "1.1.1") == false ) { Message_Add(_TL("Unable to get capabilities.")); return( false ); } //----------------------------------------------------- if( sServer.Find("http://") == 0 ) { sServer = Parameters("SERVER")->asString() + 7; } CSG_String sPath = "/" + sServer.AfterFirst('/'); sServer = sServer.BeforeFirst('/'); wxHTTP Server; Server.SetUser (Parameters("USERNAME")->asString()); Server.SetPassword(Parameters("PASSWORD")->asString()); if( Server.Connect(sServer.c_str()) == false ) { Message_Add(_TL("Unable to connect to server.")); return( false ); } //----------------------------------------------------- if( Get_Map(&Server, sPath, Capabilities) == false ) { Message_Add(_TL("Unable to get map.")); return( false ); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWMS_Import::Do_Dialog(CWMS_Capabilities &Cap) { return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWMS_Import::Get_Map(wxHTTP *pServer, const CSG_String &Directory, CWMS_Capabilities &Cap) { bool bResult = false; int i, n; CSG_Rect r(Cap.m_Extent); CSG_Parameters p; //----------------------------------------------------- // if( Cap.m_MaxWidth > 2 && NX > Cap.m_MaxWidth ) NX = Cap.m_MaxWidth; // if( Cap.m_MaxHeight > 2 && NY > Cap.m_MaxHeight ) NY = Cap.m_MaxHeight; p.Add_Range (NULL , "X_RANGE" , _TL("X Range") , _TL(""), r.Get_XMin(), r.Get_XMax(), r.Get_XMin(), r.Get_XRange() > 0.0, r.Get_XMax(), r.Get_XRange() > 0.0); p.Add_Range (NULL , "Y_RANGE" , _TL("Y Range") , _TL(""), r.Get_YMin(), r.Get_YMax(), r.Get_YMin(), r.Get_YRange() > 0.0, r.Get_YMax(), r.Get_YRange() > 0.0); p.Add_Value (NULL , "CELLSIZE", _TL("Cellsize") , _TL(""), PARAMETER_TYPE_Double, r.Get_XRange() / 2001.0, 0.0, true); p.Add_Choice(NULL , "FORMAT" , _TL("Format") , _TL(""), Cap.m_Formats); p.Add_Choice(NULL , "PROJ" , _TL("Projections"), _TL(""), Cap.m_Projections); CSG_Parameter *pNode = p("FORMAT"); for(i=0; iasChoice()->Get_Count(); i++) { CSG_String s(pNode->asChoice()->Get_Item(i)); if( !s.CmpNoCase(SG_T("image/png")) ) pNode->Set_Value(i); } for(i=0; iasRange()->Get_LoVal(), p("Y_RANGE")->asRange()->Get_LoVal(), p("X_RANGE")->asRange()->Get_HiVal(), p("Y_RANGE")->asRange()->Get_HiVal() ); Cellsize = p("CELLSIZE") ->asDouble(); NX = 1 + (int)(r.Get_XRange() / Cellsize); NY = 1 + (int)(r.Get_YRange() / Cellsize); //------------------------------------------------- Layers.Clear(); for(i=0, n=0; iasBool() ) { if( n++ > 0 ) Layers += ","; Layers += Cap.m_Layers_Name[i]; } } if( n == 0 ) { return( false ); } //------------------------------------------------- wxBitmapType tFormat; Format = p("FORMAT")->asString(); if( Format.Contains(SG_T("image/gif" )) ) tFormat = wxBITMAP_TYPE_GIF ; else if( Format.Contains(SG_T("image/jpeg")) ) tFormat = wxBITMAP_TYPE_JPEG; else if( Format.Contains(SG_T("image/png" )) ) tFormat = wxBITMAP_TYPE_PNG ; else if( Format.Contains(SG_T("image/wbmp")) ) tFormat = wxBITMAP_TYPE_BMP ; else if( Format.Contains(SG_T("image/bmp" )) ) tFormat = wxBITMAP_TYPE_BMP ; else if( Format.Contains(SG_T("image/tiff")) ) tFormat = wxBITMAP_TYPE_TIF ; else if( Format.Contains(SG_T("GIF" )) ) tFormat = wxBITMAP_TYPE_GIF ; else if( Format.Contains(SG_T("JPEG" )) ) tFormat = wxBITMAP_TYPE_JPEG; else if( Format.Contains(SG_T("PNG" )) ) tFormat = wxBITMAP_TYPE_PNG ; else { return( false ); } //------------------------------------------------- CSG_String sRequest(Directory); sRequest += SG_T("?SERVICE=WMS"); sRequest += SG_T("&VERSION=") + Cap.m_Version; sRequest += SG_T("&REQUEST=GetMap"); sRequest += SG_T("&LAYERS=") + Layers; if( Cap.m_Projections.Length() > 0 ) sRequest += CSG_String(S_SRS(Cap.m_Version)) + p("PROJ")->asString(); sRequest += SG_T("&FORMAT=") + Format; sRequest += CSG_String::Format(SG_T("&WIDTH=%d&HEIGHT=%d"), NX, NY); sRequest += CSG_String::Format(SG_T("&BBOX=%f,%f,%f,%f"), r.m_rect.xMin, r.m_rect.yMin, r.m_rect.xMax, r.m_rect.yMax); Message_Add(sRequest, true); //------------------------------------------------- wxInputStream *pStream; if( (pStream = pServer->GetInputStream(sRequest.c_str())) == NULL ) { Message_Add(_TL("could not open GetMap stream")); } else { wxImage Image; if( Image.LoadFile(*pStream, tFormat) == false ) { Message_Add(_TL("could not read image")); CSG_String s = SG_T("\n"); pStream->SeekI(0, wxFromStart); while( !pStream->Eof() ) { s += (char)pStream->GetC(); } Message_Add(s); } else { CSG_Grid *pGrid = SG_Create_Grid(SG_DATATYPE_Int, Image.GetWidth(), Image.GetHeight(), Cellsize, r.m_rect.xMin, r.m_rect.yMin); for(int y=0, yy=pGrid->Get_NY()-1; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++, yy--) { for(int x=0; xGet_NX(); x++) { pGrid->Set_Value(x, y, SG_GET_RGB(Image.GetRed(x, yy), Image.GetGreen(x, yy), Image.GetBlue(x, yy))); } } //----------------------------------------- pGrid->Set_Name(Cap.m_Title); Parameters("MAP")->Set_Value(pGrid); DataObject_Set_Colors(pGrid, 100, SG_COLORS_BLACK_WHITE); CSG_Parameters Parms; if( DataObject_Get_Parameters(pGrid, Parms) && Parms("COLORS_TYPE") ) { Parms("COLORS_TYPE")->Set_Value(3); // Color Classification Type: RGB DataObject_Set_Parameters(pGrid, Parms); } bResult = true; } delete(pStream); } } return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/garden/garden_webservices/MLB_Interface.cpp0000744000175000017500000001103512737416160026232 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: table.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // garden_webservices // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Web Service Data Access" )); case MLB_INFO_Category: return( _TL("Garden") ); case MLB_INFO_Author: return( SG_T("SAGA User Group Associaton (c) 2011" )); case MLB_INFO_Description: return( _TW("Web Service Data Access" )); case MLB_INFO_Version: return( SG_T("1.0" )); case MLB_INFO_Menu_Path: return( _TL("Garden|Web Service Data Access" )); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "wms_import.h" #include "osm_import.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CWMS_Import ); case 1: return( new COSM_Import ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/garden/Makefile.in0000664000175000017500000004712112737447615021357 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/garden ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = garden_fractals garden_games garden_learn_to_program \ garden_3d_viewer garden_webservices am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @WITH_GUI_FALSE@SUBDIRS = garden_fractals garden_games garden_learn_to_program @WITH_GUI_TRUE@SUBDIRS = garden_3d_viewer garden_fractals garden_games garden_learn_to_program garden_webservices all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/garden/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/garden/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/garden/Makefile.am0000744000175000017500000000027612737416156021341 0ustar00oconradoconrad00000000000000if WITH_GUI SUBDIRS = garden_3d_viewer garden_fractals garden_games garden_learn_to_program garden_webservices else SUBDIRS = garden_fractals garden_games garden_learn_to_program endif saga-2.3.1/src/modules/simulation/0000775000175000017500000000000012737740007020220 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/simulation/sim_ihacres/0000775000175000017500000000000012737740007022506 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_v1.h0000744000175000017500000001351512737416210024703 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_v1.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // IHACRES // // // //-------------------------------------------------------// // // // ihacres_v1.h // // // // Copyright (C) 2006 by // // Stefan Liersch // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // // // 2006-08-31 // // // /////////////////////////////////////////////////////////// //*******************************************************// // ToDo // //-------------------------------------------------------// // - stürzt ab, wenn im zweiten Dialog auf Cancel gedrückt wird // // - add NSE_highflow to output table // - wenn SingleStore, dann wird IHACRES_Sim output table nicht korrekt geschrieben // (Spalte Streamflow sim) // - implement 2 or n storages in series // - number of simulations for linear module // - choosing the number of Top simulations from non-linear module calibration // - Gültigkeitsbereiche auf Sinn prüfen // - WriteTable1Storage // - Streamflow simulation function using n, m values // - if (bTMP) = false ??? //*******************************************************// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ihacres_v1_H #define HEADER_INCLUDED__ihacres_v1_H //--------------------------------------------------------- #include "MLB_Interface.h" #include "ihacres_eq.h" #include // used for storing date string values in array using namespace std; typedef std::vector date_array; typedef vector vector_d; //--------------------------------------------------------- class Cihacres_v1 : public CSG_Module { public: // constructor Cihacres_v1(void); // destructor virtual ~Cihacres_v1(void); virtual bool needs_GUI (void) { return( true ); } protected: // execute module virtual bool On_Execute (void); private: //-------------------------------------------------------- // Private Member Variables //-------------------------------------------------------- int sizeAll; // number of selected records date_array date; vector_d m_Q_obs_m3s; vector_d m_Q_obs_mmday; vector_d precipitation; vector_d temperature; // Field numbers int dateField; // table field numbers int dischargeField; int pcpField; int tmpField; int first; // number of the record (index) of first date int last; // number of the record (index) of last date CSG_String date1, date2; // first and last date of selected period double m_area; // area of the watershed in [km2] // Non-Linear Module Parameters double TwConst; // Tw is approximately the time constant, or inversely, // the rate at which the catchment wetness declines // in the absence of rainfall. double f; // temperature modulation factor which double c; // Parameter c is chosen so that the volume // of excess rainfall is equal to the total // streamflow over the calibration period double l; // Croke et al. (2005) double p; // Croke et al. (2005) // Linear Module Parameters double a; // linear module (single storage) double b; double aq; // linear module (two storages) double as; double bq; double bs; int delay; // The delay after the start of rainfall, // before the discharge starts to rise. int IHAC_version; // Different versions of IHACRES exist, corresponding // to the version... bool bSnowModule; // snow module parameters CSnowModule *m_pSnowModule; double *m_pMeltRate; double T_Rain; double T_Melt; double DD_FAC; //vector_d SnowStorage; //vector_d MeltRate; //CSnowModule_alt *m_pSnowModule; //-------------------------------------------------------- // Private Member Functions //-------------------------------------------------------- void CreateTableSim (CSG_Table *pTable, date_array date, vector_d strfl_obs, vector_d strfl_sim); void CreateTableParms (CSG_Table *pTable, date_array date, vector_d strfl_obs, vector_d precipitation, vector_d temperature, vector_d strfl_sim, vector_d excessRain, vector_d wi, vector_d Tw); void CreateTableSettings (CSG_Table *pTable, double Tw, double c, double f, double aq, double as, double bq, double bs, double vq, double vs, bool bSnowModule, double T_Rain, double T_Melt, double DD_FAC, int delay, double RRCoef, double NSE, double area); void CreateDialog1 (); bool CreateDialog2 (bool bTMP, int storconf, int IHAC_version, CSG_Table *pTable, int dateField, int dischargeField); // Class ihacres_eq Cihacres_eq *ihacres; }; #endif /* #ifndef HEADER_INCLUDED__ihacres_v1_H */saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_eq.cpp0000744000175000017500000011505212737416210025314 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_eq.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // ihacres_eq.cpp // // // // Copyright (C) 2006 by // // Stefan Liersch // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // // // 2006-08-27 // // // //-------------------------------------------------------// #include // used for textfile output (test only) #include // used for textfile output (test only) #include "ihacres_eq.h" #include // exp() //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // COMMENTS // //--------------------------------------------------------- // 2007-11-08 // added to function CalcWetnessIndex() // if (WetnessIndex[i] > 1.0) WetnessIndex[i] = 1.0; //--------------------------------------------------------- /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // // CONSTRUCTORS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // DEFAULT CONSTRUCTOR //--------------------------------------------------------------------- Cihacres_eq::Cihacres_eq() {}; //--------------------------------------------------------------------- // two storages // using vector as input // if no temperature data are available Cihacres_eq::Cihacres_eq(date_array date_in, vector_d streamflow, vector_d pcp, double TwConst, double f, double c, double l, double p, double aq, double as, double bq, double bs) { sizeAll = (int)streamflow.size(); date = date_in; streamflow_obs = streamflow; precipitation = pcp; this->TwConst = TwConst; this->f = f; this->c = c; this->l = l; this->p = p; this->aq = aq; this->as = as; this->bq = bq; this->bs = bs; // Initialize Vectors _InitVectorsStart((int)streamflow_obs.size()); } //--------------------------------------------------------------------- // two storages // using vector as input // if temperature data are available Cihacres_eq::Cihacres_eq(date_array date_in, vector_d streamflow, vector_d pcp, vector_d tmp, double TwConst, double f, double c, double l, double p, double aq, double as, double bq, double bs, double area, bool TMP_data_exist, int IHAC_vers, int storconf, bool bSnowModule, CSnowModule *SnowMod, //double T_Rain, double T_Melt, double DD_FAC, int delay) { // Initialize Parameters and Vectors sizeAll = (int)streamflow.size(); date = date_in; streamflow_obs = streamflow; precipitation = pcp; temperature = tmp; this->TwConst = TwConst; this->f = f; this->c = c; this->l = l; this->p = p; this->aq = aq; this->as = as; this->bq = bq; this->bs = bs; this->delay = delay; this->area = area; IHAC_version = IHAC_vers; this->bSnowModule = bSnowModule; m_pSnowMod = SnowMod; // Initialize Vectors containing calculated values _InitVectorsStart(sizeAll); // Convert Streamflow vector from m3/s*day-1 to mm/day streamflowMM_obs = model_tools::m3s_to_mmday(streamflow_obs, streamflowMM_obs, area); // perform simulation if (bSnowModule) { RunNonLinearModule(TMP_data_exist, bSnowModule, m_pSnowMod->Get_T_Rain()); } else { RunNonLinearModule(TMP_data_exist, bSnowModule, 0.0); } //switch (IHAC_version) //{ //case 0: // Jakeman & Hornberger (1993) // if (bSnowModule) // { // RunNonLinearModule(TMP_data_exist, bSnowModule, m_pSnowMod->Get_T_Rain()); // } else { // RunNonLinearModule(TMP_data_exist, bSnowModule, 0.0); // } // break; //case 1: // Croke et al. (2005) Redesign // //RunNonLinearModule5Parms(); // break; //} switch(storconf) { case 0: // single storage this->a = aq; this->b = bq; SimStreamflowSingle(excessRain, streamflowMM_obs[0], streamflow_sim, delay, a, b); break; case 1: // two storages in parallel SimStreamflow2Parallel(excessRain, streamflow_sim, streamflowMM_obs[0], aq, as, bq, bs, vq, vs, IHAC_vers, delay); break; } // end switch(storconf) NSE = model_tools::CalcEfficiency(streamflowMM_obs, streamflow_sim); } //--------------------------------------------------------------------- // two storages // using double arrays as input // if no temperature data are available Cihacres_eq::Cihacres_eq(int size, // array size date_array date_in, double *streamflow, double *pcp, double TwConst, double f, double c, double aq, double as, double bq, double bs) { // assign values to global parameters sizeAll = size; date = date_in; streamflow_obs.resize(sizeAll); precipitation.resize(sizeAll); for (int i = 0; i < sizeAll; i++) { streamflow_obs[i] = streamflow[i]; precipitation[i] = pcp[i]; } this->TwConst = TwConst; this->f = f; this->c = c; this->aq = aq; this->as = as; this->bq = bq; this->bs = bs; // Initialize Vectors _InitVectorsStart(sizeAll); } //--------------------------------------------------------------------- // two storages // using double arrays as input // if temperature data are available Cihacres_eq::Cihacres_eq(int size, // array size date_array date_in, double *streamflow, double *pcp, double *tmp, double TwConst, double f, double c, double aq, double as, double bq, double bs) { sizeAll = size; date = date_in; streamflow_obs.resize(size); precipitation.resize(size); temperature.resize(size); for (int i = 0; i < size; i++) { streamflow_obs[i] = streamflow[i]; precipitation[i] = pcp[i]; temperature[i] = tmp[i]; } this->TwConst = TwConst; this->f = f; this->c = c; this->aq = aq; this->as = as; this->bq = bq; this->bs = bs; // Initialize Vectors _InitVectorsStart((int)streamflow_obs.size()); } //--------------------------------------------------------------------- // end constructors /////////////////////////////////////////////////// // destructor Cihacres_eq::~Cihacres_eq(void) { _ZeroAllVectors(); } /////////////////////////////////////////////////////////////////////// // // PUBLIC MEMBER FUNCTIONS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Run Non-Linear Module //--------------------------------------------------------------------- void Cihacres_eq::RunNonLinearModule(bool TMP_data_exist, bool bSnowModule, double T_Rain) { double WI_init = 0.5; double eR_init = 0.0; switch (IHAC_version) { case 0: // Jakeman & Hornberger (1993) // if temperature data are available (TMP_data_exist = true), then adjust the rate // at which the catchment wetness declines in the absence of rainfall // to daily temperature if (TMP_data_exist){ CalcWetnessTimeConst(temperature, Tw, TwConst, f); } if (bSnowModule) { // calculate the catchment wetness index CalcWetnessIndex(Tw, precipitation, temperature, WetnessIndex, WI_init, c, bSnowModule, m_pSnowMod->Get_T_Rain()); // calculate effective rainfall sum_eRainMM = CalcExcessRain(precipitation, temperature, WetnessIndex, excessRain, eR_init, sum_eRainGTpcp, bSnowModule, m_pSnowMod); } else { CalcWetnessIndex(Tw, precipitation, temperature, WetnessIndex, WI_init, c, bSnowModule, 0.0); sum_eRainMM = CalcExcessRain(precipitation, temperature, WetnessIndex, excessRain, eR_init, sum_eRainGTpcp, bSnowModule, m_pSnowMod); } break; case 1: // Croke et al. (2005) if (TMP_data_exist) { CalcWetnessTimeConst_Redesign(temperature, Tw, TwConst, f); } if (bSnowModule) { // calculate the catchment wetness index CalcWetnessIndex_Redesign(Tw, precipitation, WetnessIndex, bSnowModule, m_pSnowMod->Get_T_Rain()); // calculate effective rainfall sum_eRainMM = CalcExcessRain_Redesign(precipitation, temperature, WetnessIndex, excessRain, eR_init, sum_eRainGTpcp, c, l, p, bSnowModule, m_pSnowMod); } else { // calculate the catchment wetness index CalcWetnessIndex_Redesign(Tw, precipitation, WetnessIndex, bSnowModule, 0.0); // calculate effective rainfall sum_eRainMM = CalcExcessRain_Redesign(precipitation, temperature, WetnessIndex, excessRain, eR_init, sum_eRainGTpcp, c, l, p, bSnowModule, m_pSnowMod); } break; } } //--------------------------------------------------------------------- // Simulate Streamflow (single storage) //--------------------------------------------------------------------- void Cihacres_eq::SimStreamflowSingle(vector_d &excessRain, double initVal, vector_d &streamflow_sim, int delay, double a, double b) { int i; int size = (int)streamflow_sim.size(); // using the first observed streamflow value as initial simulation value for (i = 0; i < delay; i++) streamflow_sim[i] = initVal; // start calculation with second value for (i = delay; i < size; i++) { streamflow_sim[i] = -a * streamflow_sim[i-1] + b * excessRain[i-delay]; } } //--------------------------------------------------------------------- // Simulate Streamflow (single storage) //--------------------------------------------------------------------- void Cihacres_eq::SimStreamflowSingle(double *excessRain, double initVal, double *streamflow_sim, int delay, double a, double b, int size) { int i; // using the first observed streamflow value as initial simulation value for (i = 0; i < delay; i++) streamflow_sim[i] = initVal; // start calculation with second value for (i = delay; i < size; i++) { streamflow_sim[i] = -a * streamflow_sim[i-1] + b * excessRain[i-delay]; } } //--------------------------------------------------------------------- // Simulate Streamflow (2 parallel storages) //--------------------------------------------------------------------- void Cihacres_eq::SimStreamflow2Parallel(vector_d &excessRain, vector_d &streamflow_sim, double initVal, double aq, double as, double bq, double bs, double &vq, double &vs, int IHAC_vers, int delay) { int i; int size = (int)streamflow_sim.size(); double *sf_q = new double[size]; // quick streamflow component double *sf_s = new double[size]; // slow streamflow component // calculate the dependent b-value // after Jakeman etc. vq = bq / (1 + aq); vs = 1 - vq; // using the first observed streamflow value as initial simulation value for (i = 0; i < delay; i++) { streamflow_sim[i] = initVal; sf_q[i] = initVal * vq; sf_s[i] = initVal * vs; } // using the first observed streamflow value as initial simulation value //for (i = 0; i < delay; i++) //{ // streamflow_sim[i] = initVal; // sf_q[i] = initVal / 2; // sf_s[i] = initVal / 2; //} //// calculate the dependent b-value //if (IHAC_vers == 1) // after Kokkonen //{ // vq = bq / (bq + bs); // vs = 1 - vq; //} else { // after Jakeman etc. // vq = bq / (1 + aq); // vs = 1 - vq; //} // calculate streamflow for (i = delay; i < size; i++) { sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay]; sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } /* switch(IHAC_vers) { case 0 : // after Jakeman & Hornberger (1993) vq = bq / (1 + aq); vs = 1 - vq; if (!b_freebee) bs = vs * (1 + as); // calculate quick and slow components for (i = delay; i < size; i++) { sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay]; sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } break; case 1 : // after Kokkonen et al. (2003) vq = bq / (bq + bs); vs = 1 - vq; if (!b_freebee) bs = vs * (1 + as); // calculate quick and slow components for (i = delay; i < size; i++) { sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay]; sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } break; case 2: // Ahandere Mahn vq = bq / (1 + aq); vs = 1 - vq; if (!b_freebee) bs = vs * (1 + as); // calculate quick and slow components for (i = delay; i < size; i++) { sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay]; sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } break; case 3 : // after Croke et al. (2005) vq = bq / (1 + aq); vs = 1 - vq; if (!b_freebee) bs = vs * (1 + as); // calculate quick and slow components for (i = delay; i < size; i++) { sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay]; sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } break; } */ delete[] sf_q; delete[] sf_s; } //--------------------------------------------------------------------- // Simulate Streamflow (2 parallel storages) //--------------------------------------------------------------------- void Cihacres_eq::SimStreamflow2Parallel(double *excessRain, double *streamflow_sim, double initVal, double aq, double as, double bq, double bs, double &vq, double &vs, int IHAC_vers, int size, int delay) { int i; double *sf_q = new double[size]; // quick streamflow component double *sf_s = new double[size]; // slow streamflow component // calculate the dependent b-value // after Jakeman etc. vq = bq / (1 + aq); vs = 1 - vq; // using the first observed streamflow value as initial simulation value for (i = 0; i < delay; i++) { streamflow_sim[i] = initVal; sf_q[i] = initVal * vq; sf_s[i] = initVal * vs; } //// using the first observed streamflow value as initial simulation value //for (i = 0; i < delay; i++) //{ // streamflow_sim[i] = initVal; // sf_q[i] = initVal / 2; // sf_s[i] = initVal / 2; //} //// calculate the dependent b-value //if (IHAC_vers == 1) // after Kokkonen //{ // vq = bq / (bq + bs); // vs = 1 - vq; //} else { // after Jakeman etc. // vq = bq / (1 + aq); // vs = 1 - vq; //} // calculate streamflow for (i = delay; i < size; i++) { sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay]; sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } /* switch(IHAC_vers) { case 0 : // after Jakeman & Hornberger (1993) vq = bq / (1 + aq); vs = 1 - vq; if (!b_freebee) bs = vs * (1 + as); // calculate quick and slow components for (i = delay; i < size; i++) { sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay]; sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } break; case 1 : // after Kokkonen et al. (2003) vq = bq / (bq + bs); vs = 1 - vq; if (!b_freebee) bs = vs * (1 + as); // calculate quick and slow components for (i = delay; i < size; i++) { sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay]; sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } break; case 2: // Jakeman & SnowModule vq = bq / (1 + aq); vs = 1 - vq; if (!b_freebee) bs = vs * (1 + as); // calculate quick and slow components for (i = delay; i < size; i++) { sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay]; sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } break; case 3 : // after Croke et al. (2005) vq = bq / (1 + aq); vs = 1 - vq; if (!b_freebee) bs = vs * (1 + as); // calculate quick and slow components for (i = delay; i < size; i++) { sf_q[i] = -aq * sf_q[i-1] + bq * excessRain[i-delay]; sf_s[i] = -as * sf_s[i-1] + bs * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } break; } */ delete[] sf_q; delete[] sf_s; } //--------------------------------------------------------------------- // Simulate Streamflow (2 parallel storages) //--------------------------------------------------------------------- void Cihacres_eq::SimStreamflow2Parallel(double *excessRain, double *streamflow_sim, double initVal, // first observed streamflow value C_IHAC_LinearParms* linparms, int index, double &vq, double &vs, int size, int delay) { int i; double *sf_q = new double[size]; // quick streamflow component double *sf_s = new double[size]; // slow streamflow component // calculate the dependent b-value // after Jakeman etc. vq = linparms->bq[index] / (1 + linparms->aq[index]); vs = 1 - vq; // using the first observed streamflow value as initial simulation value for (i = 0; i < delay; i++) { streamflow_sim[i] = initVal; sf_q[i] = initVal * vq; sf_s[i] = initVal * vs; } // calculate streamflow for (i = delay; i < size; i++) { sf_q[i] = -linparms->aq[index] * sf_q[i-1] + linparms->bq[index] * excessRain[i-delay]; sf_s[i] = -linparms->as[index] * sf_s[i-1] + linparms->bs[index] * excessRain[i-delay]; streamflow_sim[i] = sf_q[i] + sf_s[i]; } delete[] sf_q; delete[] sf_s; } //--------------------------------------------------------------------- // Calculate Parameter b(q) //--------------------------------------------------------------------- double Cihacres_eq::Calc_Parm_BS(double aq, double as, double bq) { return( (1 - (bq / (1 + aq))) * (1 + as) ); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Calculate time of decay (quick or slow) //--------------------------------------------------------------------- double Cihacres_eq::Calc_TimeOfDecay(double a) { return( -1 / log(-a) ); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Calculate Wetness Time Constant //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessTimeConst(vector_d &temperature, vector_d &Tw, double TwConst, double f) { for (unsigned int i = 0; i < Tw.size(); i++) { Tw[i] = TwConst * exp((20.0 - temperature[i]) * f); } } //--------------------------------------------------------------------- // Calculate Wetness Time Constant //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessTimeConst(double *temperature, double *Tw, double TwConst, double f, int size) { for (int i = 0; i < size; i++) { Tw[i] = TwConst * exp((20.0 - temperature[i]) * f); } } //--------------------------------------------------------------------- // Calculate Wetness Time Constant //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessTimeConst(double *temperature, double *Tw, C_IHAC_NonLinearParms* nonlinparms, int index, int size) { for (int i = 0; i < size; i++) { Tw[i] = nonlinparms->mp_tw[index] * exp((20.0 - temperature[i]) * nonlinparms->mp_f[index]); } } //--------------------------------------------------------------------- // Calculate Wetness Time Constant // For ihacres_climate_scen //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessTimeConst_scen(double *temperature, double *Tw, C_IHAC_NonLinearParms* nonlinparms, int index, int size) { Tw[0] = 0.0; for (int i = 1; i < size; i++) { Tw[i] = nonlinparms->mp_tw[index] * exp((20.0 - temperature[i]) * nonlinparms->mp_f[index]); } } //--------------------------------------------------------------------- // Calculate Wetness Time Constant (Croke et al. 2005) //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessTimeConst_Redesign(vector_d &temperature, vector_d &Tw, double TwConst, double f) { double Tr = 20.0; // reference temperature for (unsigned int i = 0; i < Tw.size(); i++) { Tw[i] = TwConst * exp(0.062 * f * (Tr - temperature[i])); } } //--------------------------------------------------------------------- // Calculate Wetness Time Constant (Croke et al. 2005) //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessTimeConst_Redesign(double *temperature, double *Tw, double TwConst, double f, int size) { double Tr = 20.0; // reference temperature for (int i = 0; i < size; i++) { Tw[i] = TwConst * exp(0.062 * f * (Tr - temperature[i])); } } //--------------------------------------------------------------------- // Calculate Wetness Time Constant (Croke et al. 2005) //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessTimeConst_Redesign(double *temperature, double *Tw, C_IHAC_NonLinearParms* nonlinparms, int index, int size) { double Tr = 20.0; // reference temperature for (int i = 0; i < size; i++) { Tw[i] = nonlinparms->mp_tw[index] * exp(0.062 * nonlinparms->mp_f[index] * (Tr - temperature[i])); } } //--------------------------------------------------------------------- // Calculate Wetness Index //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessIndex(vector_d &Tw, vector_d &precipitation, vector_d &temperature, vector_d &WetnessIndex, double WI_init, double c, bool bSnowModule, double T_Rain) { WetnessIndex[0] = WI_init; // starting at the second value (i=1) for (unsigned int i = 1; i < WetnessIndex.size(); i++) { if (bSnowModule && temperature[i] < T_Rain) { WetnessIndex[i] = (1 - (1 / Tw[i])) * WetnessIndex[i-1]; } else { WetnessIndex[i] = c * precipitation[i] + (1 - (1 / Tw[i])) * WetnessIndex[i-1]; } // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // if (WetnessIndex[i] > 1.0) WetnessIndex[i] = 1.0; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } } //--------------------------------------------------------------------- // Calculate Wetness Index //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessIndex(double *Tw, double *precipitation, double *temperature, double *WetnessIndex, double WI_init, double c, bool bSnowModule, double T_Rain, int size) { //WetnessIndex[0] = 0.5; WetnessIndex[0] = WI_init; // starting at the second value (i=1) for (int i = 1; i < size; i++) { if (bSnowModule && temperature[i] < T_Rain) { WetnessIndex[i] = (1 - (1 / Tw[i])) * WetnessIndex[i-1]; } else { WetnessIndex[i] = c * precipitation[i] + (1 - (1 / Tw[i])) * WetnessIndex[i-1]; } // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // if (WetnessIndex[i] > 1.0) WetnessIndex[i] = 1.0; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } } //--------------------------------------------------------------------- // Calculate Wetness Index after Croke et al. (2005) //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessIndex_Redesign(vector_d &Tw, vector_d &precipitation, vector_d &WetnessIndex, bool bSnowModule,double T_Rain) { WetnessIndex[0] = 0.5; // starting at the second value (i=1) for (unsigned int i = 1; i < WetnessIndex.size(); i++) { WetnessIndex[i] = precipitation[i] + (1 - (1 / Tw[i])) * WetnessIndex[i-1]; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // if (WetnessIndex[i] > 1.0) WetnessIndex[i] = 1.0; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } } //--------------------------------------------------------------------- // Calculate Wetness Index after Croke et al. (2005) //--------------------------------------------------------------------- void Cihacres_eq::CalcWetnessIndex_Redesign(double *Tw, double *precipitation,double *WetnessIndex, double WI_init, bool bSnowModule,double T_Rain, int size) { //WetnessIndex[0] = 0.5; WetnessIndex[0] = WI_init; // starting at the second value (i=1) for (int i = 1; i < size; i++) { WetnessIndex[i] = precipitation[i] + (1 - (1 / Tw[i])) * WetnessIndex[i-1]; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // if (WetnessIndex[i] > 1.0) WetnessIndex[i] = 1.0; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } } //--------------------------------------------------------------------- // Calculate Effective or Excess Rainfall //--------------------------------------------------------------------- double Cihacres_eq::CalcExcessRain(vector_d &precipitation, vector_d &temperature, vector_d &WetnessIndex, vector_d &excessRain, double eR_init, double &sum_eRainGTpcp, bool bSnowModule, CSnowModule* pSnowModule) //double T_Rain, double T_Melt, double* MeltRate) { double sum = 0.0; // sum of total ExcessRain of the period sum_eRainGTpcp = 0.0; excessRain[0] = eR_init; if (precipitation[0] > 0.0) excessRain[0] = precipitation[0] / 2; // starting at the second value (i=1) for (unsigned int i = 1; i < excessRain.size(); i++) { // "excess" rainfall after Jakeman & Hornberger (1993) // ExcessRain[i] = pcp[i] * WetnessIndex[i]; // "excess" rainfall after Croke et al. (2004) excessRain[i] = precipitation[i] * ((WetnessIndex[i] + WetnessIndex[i-1]) / 2); if (excessRain[i] > precipitation[i]) { // if calculated excess rain volume is greater than observed precipitation, // then summarize volume differences and set to current pcp value sum_eRainGTpcp += excessRain[i] - precipitation[i]; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // if excess rainfall is greater than observed precip, then // it is reduced to precip! //excessRain[i] = precipitation[i]; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } if (excessRain[i] < 0.0) excessRain[i] = 0.0; // snow module ******************************************** if (bSnowModule) { if (temperature[i] < pSnowModule->Get_T_Rain()) excessRain[i] = 0.0; if (temperature[i] > pSnowModule->Get_T_Melt()) excessRain[i] += pSnowModule->Get_MeltRate(i); if ((temperature[i] < pSnowModule->Get_T_Melt()) && (temperature[i] > pSnowModule->Get_T_Rain())) excessRain[i] += pSnowModule->Get_MeltRate(i); } // end snow module **************************************** sum += excessRain[i]; } sum += excessRain[0]; // add the initial value return sum; } //--------------------------------------------------------------------- // Calculate Effective or Excess Rainfall //--------------------------------------------------------------------- double Cihacres_eq::CalcExcessRain(double *precipitation, double* temperature, double *WetnessIndex, double *excessRain, double eR_init, double &sum_eRainGTpcp, int size, bool bSnowModule, double T_Rain, double T_Melt, double* MeltRate) { double sum = 0.0; // sum of total ExcessRain of the period sum_eRainGTpcp = 0.0; //excessRain[0] = 0.0; excessRain[0] = eR_init; //if (precipitation[0] > 0.0) excessRain[0] = precipitation[0] / 2; // starting at the second value (i=1) for (int i = 1; i < size; i++) { // "excess" rainfall after Jakeman & Hornberger (1993) // ExcessRain[i] = pcp[i] * WetnessIndex[i]; // "excess" rainfall after Croke et al. (2004) excessRain[i] = precipitation[i] * ((WetnessIndex[i] + WetnessIndex[i-1]) / 2); if (excessRain[i] > precipitation[i]) { // if calculated excess rain volume is greater than observed precipitation, // then summarize volume differences and set to current pcp value sum_eRainGTpcp += excessRain[i] - precipitation[i]; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // if excess rainfall is greater than observed precip, then // it is reduced to precip! //excessRain[i] = precipitation[i]; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } if (excessRain[i] < 0.0) excessRain[i] = 0.0; // snow module ******************************************** if (bSnowModule) { if (temperature[i] < T_Rain) excessRain[i] = 0.0; if (temperature[i] > T_Melt) excessRain[i] += MeltRate[i]; if ((temperature[i] < T_Melt) && (temperature[i] > T_Rain)) excessRain[i] += MeltRate[i]; } // end snow module **************************************** sum += excessRain[i]; } sum += excessRain[0]; // add the initial value return sum; } //--------------------------------------------------------------------- // Calculate Effective or Excess Rainfall after Croke et al. (2005) //--------------------------------------------------------------------- double Cihacres_eq::CalcExcessRain_Redesign(vector_d &precipitation, vector_d& temperature, vector_d &WetnessIndex, vector_d &excessRain, double eR_init, double &sum_eRainGTpcp, double c, double l, double p, bool bSnowModule, CSnowModule* pSnowMod) { double sum = 0.0; // sum of total ExcessRain of the period sum_eRainGTpcp = 0.0; excessRain[0] = eR_init; if (precipitation[0] > 0.0) excessRain[0] = precipitation[0] / 2; // starting at the second value (i=1) for (unsigned int i = 1; i < excessRain.size(); i++) { // "excess" rainfall after Jakeman & Hornberger (1993) // ExcessRain[i] = pcp[i] * WetnessIndex[i]; // "excess" rainfall after Croke et al. (2004) // excessRain[i] = precipitation[i] * ((WetnessIndex[i] + WetnessIndex[i-1]) / 2); // excess rainfall after Croke et al. (2005) // The first equation is as described in the paper, // but Barry Croke told me that parameter "c" must be outside the brackets !!! // excessRain[i] = pow((c *(WetnessIndex[i] - l)),p) * precipitation[i]; if ( WetnessIndex[i] - l < 0.0 ) { excessRain[i] = 0.0; } else { excessRain[i] = c * pow((WetnessIndex[i] - l),p) * precipitation[i]; } if (excessRain[i] > precipitation[i]) { // if calculated excess rain volume is greater than observed precipitation, // then summarize volume differences and set to current pcp value sum_eRainGTpcp += excessRain[i] - precipitation[i]; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // if excess rainfall is greater than observed precip, then // it is reduced to precip! //excessRain[i] = precipitation[i]; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! } if (excessRain[i] < 0.0) excessRain[i] = 0.0; // snow module ******************************************** if (bSnowModule) { if (temperature[i] < pSnowMod->Get_T_Rain()) excessRain[i] = 0.0; if (temperature[i] > pSnowMod->Get_T_Melt()) excessRain[i] += pSnowMod->Get_MeltRate(i); if ((temperature[i] < pSnowMod->Get_T_Melt()) && (temperature[i] > pSnowMod->Get_T_Rain())) excessRain[i] += pSnowMod->Get_MeltRate(i); } // end snow module **************************************** sum += excessRain[i]; } sum += excessRain[0]; // add the initial value return sum; } //--------------------------------------------------------------------- // Calculate Effective or Excess Rainfall after Croke et al. (2005) //--------------------------------------------------------------------- double Cihacres_eq::CalcExcessRain_Redesign(double *precipitation, double* temperature, double *WetnessIndex, double *excessRain, double eR_init, double &sum_eRainGTpcp, int size, double c, double l, double p, bool bSnowModule, double T_Rain, double T_Melt, double* MeltRate) { double sum = 0.0; // sum of total ExcessRain of the period sum_eRainGTpcp = 0.0; //excessRain[0] = 0.0; excessRain[0] = eR_init; //if (precipitation[0] > 0.0) excessRain[0] = precipitation[0] / 2; // starting at the second value (i=1) for (int i = 1; i < size; i++) { // excess rainfall after Croke et al. (2005) // The first equation is as described in the paper, // but Barry Croke told me that parameter "c" must be outside the brackets !!! // excessRain[i] = pow((c *(WetnessIndex[i] - l)),p) * precipitation[i]; excessRain[i] = c * pow((WetnessIndex[i] - l),p) * precipitation[i]; if (excessRain[i] > precipitation[i]) { // if calculated excess rain volume is greater than observed precipitation, // then summarize volume differences and set to current pcp value sum_eRainGTpcp += excessRain[i] - precipitation[i]; excessRain[i] = precipitation[i]; } if (excessRain[i] < 0.0) excessRain[i] = 0.0; // snow module ******************************************** if (bSnowModule) { if (temperature[i] < T_Rain) excessRain[i] = 0.0; if (temperature[i] > T_Melt) excessRain[i] += MeltRate[i]; if ((temperature[i] < T_Melt) && (temperature[i] > T_Rain)) excessRain[i] += MeltRate[i]; } // end snow module **************************************** sum += excessRain[i]; } sum += excessRain[0]; // add the initial value return sum; } //--------------------------------------------------------------------- // Assign first and last record (user selection) //--------------------------------------------------------------------- void Cihacres_eq::AssignFirstLastRec(CSG_Table &pTable, int &first, int &last, CSG_String date1, CSG_String date2, int dateField) { int j; /////////////////////////////////////////////////////////////// // searching the first and the last record of the time range /////////////////////////////////////////////////////////////// for (j = 0; j < pTable.Get_Record_Count(); j++) { if (!date1.Cmp(pTable.Get_Record(j)->asString(dateField))) { first = j; } else if (!date2.Cmp(pTable.Get_Record(j)->asString(dateField))) { last = j; } } } //--------------------------------------------------------------------- int Cihacres_eq::Assign_nStorages(int storconf) { switch(storconf) { case 0: return(1); break; case 1: return(2); break; case 2: return(2); break; default : return(1); } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Summarize all Values in a Vector //--------------------------------------------------------------------- double Cihacres_eq::SumVector(vector_d &input) { double sum = 0; for (unsigned int j = 0; j < input.size(); j++) { sum += input[j]; } return sum; } //--------------------------------------------------------------------- // Summarize all Values in an Array //--------------------------------------------------------------------- double Cihacres_eq::SumVector(double *input, int size) { double sum = 0; for (int j = 0; j < size; j++) { sum += input[j]; } return sum; } //--------------------------------------------------------------------- // Assign temporary Nash-Sutcliffe efficiency according to // objective function (NSE, NSE_highflow, NSE_lowflow) //--------------------------------------------------------------------- double Cihacres_eq::_Assign_NSE_temp(int obj_func, double NSE, double NSE_highflow, double NSE_lowflow) { switch(obj_func) { case 0: // NSE return(NSE); case 1: // NSE high flow return(NSE_highflow); case 2: // NSE low flow (not yet implemented!) return(NSE_lowflow); break; default: return(NSE); } // end switch(m_obj_func) } //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // GET FUNCTIONS // /////////////////////////////////////////////////////////////////////// double Cihacres_eq::get_vq() { // return (bq / (bq + bs)); return(vq); } //--------------------------------------------------------------------- double Cihacres_eq::get_vs() { // return (1 - get_vq()); return(vs); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- double Cihacres_eq::get_sum_streamflowMM_obs(int size) { double sum_streamflowMM_obs = 0.0; // calculate sum of observed streamflow in [mm] for (int j = 0; j < size; j++) { sum_streamflowMM_obs += streamflowMM_obs[j]; } return(sum_streamflowMM_obs); } //--------------------------------------------------------------------- double Cihacres_eq::get_sum_precipitation(int size) { double sum_pcp = 0.0; for (int i = 0; i < size; i++) { sum_pcp += precipitation[i]; } return(sum_pcp); } //--------------------------------------------------------------------- double Cihacres_eq::get_NSE() { return(NSE); } //--------------------------------------------------------------------- vector_d Cihacres_eq::get_streamflow_sim() { return(streamflow_sim); } //--------------------------------------------------------------------- vector_d Cihacres_eq::get_excessRain() { return(excessRain); } //--------------------------------------------------------------------- vector_d Cihacres_eq::get_WetnessIndex() { return(WetnessIndex); } //--------------------------------------------------------------------- vector_d Cihacres_eq::get_Tw() { return(Tw); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // PRIVATE MEMBER FUNCTIONS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Initialize (Resize) global Vectors //--------------------------------------------------------------------- void Cihacres_eq::_InitVectorsStart(int size) { streamflow_sim.resize(size); excessRain.resize(size); WetnessIndex.resize(size); Tw.resize(size); streamflowMM_obs.resize(size); //if (IHAC_version == 2) //{ // m_pSnowMod->SnowStorage = new double[size]; // m_pSnowMod->MeltRate = new double[size]; // for (int i = 0; i < size; i++) // { // m_pSnowMod->SnowStorage[i] = 0.0; // m_pSnowMod->MeltRate[i] = 0.0; // } // //SnowModule(m_pSnowMod->SnowStorage,m_pSnowMod->MeltRate,temperature,precipitation, m_pSnowMod->T_Rain,m_pSnowMod->T_Melt,m_pSnowMod->DD_FAC, size); //} } //--------------------------------------------------------------------- // Zero all Vectors //--------------------------------------------------------------------- void Cihacres_eq::_ZeroAllVectors() { // Resize all Vectors to Zero streamflow_sim.resize(0); excessRain.resize(0); WetnessIndex.resize(0); Tw.resize(0); date.resize(0); streamflow_obs.resize(0); precipitation.resize(0); temperature.resize(0); } saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_elev_bands.cpp0000744000175000017500000000145212737416207027015 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev_bands.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ #define NULL 0 #include "ihacres_elev_bands.h" Cihacres_elev_bands::Cihacres_elev_bands() { m_p_pcp = NULL; m_p_tmp = NULL; m_p_ER = NULL; m_p_streamflow_sim = NULL; m_p_Tw = NULL; m_p_WI = NULL; m_p_MeltRate = NULL; m_p_SnowStorage = NULL; } Cihacres_elev_bands::~Cihacres_elev_bands() { //if (m_p_pcp) delete[] m_p_pcp; //if (m_p_tmp) delete[] m_p_tmp; //if (m_p_ER) delete[] m_p_ER; //if (m_p_streamflow_sim) delete[] m_p_streamflow_sim; //if (m_p_Tw) delete[] m_p_Tw; //if (m_p_WI) delete[] m_p_WI; //if (m_p_MeltRate) delete[] m_p_MeltRate; //if (m_p_SnowStorage) delete[] m_p_SnowStorage; }saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_cal2.h0000744000175000017500000002170112737416207025200 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_cal2.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // IHACRES // // // //-------------------------------------------------------// // // // ihacres_cal2.h // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // // // 2008-01-15 // // // /////////////////////////////////////////////////////////// //*******************************************************// // ToDo // //-------------------------------------------------------// // - //*******************************************************// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ihacres_cal2_H #define HEADER_INCLUDED__ihacres_cal2_H //--------------------------------------------------------- #include "MLB_Interface.h" #include "ihacres_eq.h" #include // used for storing date string values in array //using namespace std; typedef std::vector date_array; //typedef std::vector vector_d; //typedef std::vector vector_i; //typedef std::vector vector_b; //--------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // CLASS Cihacres_cal2 // /////////////////////////////////////////////////////////////////////// class Cihacres_cal2 : public CSG_Module { public: // constructor Cihacres_cal2(void); // destructor virtual ~Cihacres_cal2(void); virtual bool needs_GUI (void) { return( true ); } protected: /////////////////////////////////////////////////////////////////// // // PROTECTED FUNCTIONS // /////////////////////////////////////////////////////////////////// // execute module virtual bool On_Execute (void); private: /////////////////////////////////////////////////////////////////// // // PRIVATE PARAMETERS // /////////////////////////////////////////////////////////////////// //----------------------------------------------------------------- // EXTERNAL CLASSES //----------------------------------------------------------------- Cihacres_eq ihacres; // all IHACRES equations are defined here CSnowModule* m_pSnowModule; // (snow_module.h/.cpp) CSnowParms m_SnowParms; //----------------------------------------------------------------- //----------------------------------------------------------------- // TIME SERIES PARAMETERS //----------------------------------------------------------------- int m_nValues; // number of values / time steps in simulation date_array m_vec_date; // Vector containing date values double* m_p_Q_Inflow_m3s; double* m_p_Q_dif_m3s; double* m_p_Q_obs_m3s; // Array containing observed discharge values in [m3/s] double* m_p_Q_obs_mmday;// Array containing observed discharge values in [mm] double* m_p_Q_sim_mmday; // simulated streamflow [mm/day] double* m_pPCP; // Array containing observed precipitation values double* m_pTMP; // Array containing temperature values // non-linear module time series double* m_pExcessRain; // "excess" or effective rainfall [mm] double* m_pTw; // Tw is approximately the time constant, or inversely, // the rate at which the catchment wetness declines // in the absence of rainfall. double* m_pWI; // catchment wetness index double* m_pMeltRate; // if snow module is active double m_sum_obsDisMM; double m_sum_eRainGTpcp; //----------------------------------------------------------------- //----------------------------------------------------------------- // MODEL PARAMETERS / Cihacres_eq //----------------------------------------------------------------- // NON-LINEAR MODULE double m_Tw; double m_f; double m_c; double m_l; double m_p; // LINEAR MODULE double m_a; double m_b; double m_aq; double m_as; double m_bq; double m_bs; double m_vq; double m_vs; //----------------------------------------------------------------- //----------------------------------------------------------------- // PARAMETERS DIALOG 1 //----------------------------------------------------------------- CSG_Table* m_pTable; int m_dateField; int m_dischargeField; int m_pcpField; int m_tmpField; int m_inflowField; bool m_bUpstream; // true = upstream, false = downstream bool m_bTMP; int m_nsim; // number of simulations double m_area; // area of the watershed in [km2] //double m_dev_eRainDis; //double m_dev_eRainPCP; int m_storconf; int m_IHAC_version; bool m_bSnowModule; //----------------------------------------------------------------- //----------------------------------------------------------------- // PARAMETERS DIALOG 2 //----------------------------------------------------------------- CSG_String m_date1, m_date2; //----------------------------------------------------------------- // CALIBRATION PARAMETERS //----------------------------------------------------------------- // non linear module parameters double m_TwConst_ub; // Tw is approximately the time constant, or inversely, double m_TwConst_lb; // the rate at which the catchment wetness declines // in the absence of rainfall. double m_f_lb; // temperature modulation factor which double m_f_ub; // determines how Tw changes with temperature double m_c_lb; // Parameter c is chosen so that the volume double m_c_ub; // of excess rainfall is equal to the total // streamflow over the calibration period // Croke et al. (2005) Redesign of non-linear module double m_l_lb; // soil moisture index threshold double m_l_ub; double m_p_lb; // power on soil moisture double m_p_ub; // linear module parameters (single storage) double m_a_lb; double m_a_ub; double m_b_lb; double m_b_ub; // linear module parameters (2 storages) double m_aq_lb; double m_aq_ub; double m_as_lb; double m_as_ub; double m_bq_lb; double m_bq_ub; // SnowModule calibration parameters double m_T_Rain_lb; double m_T_Rain_ub; double m_T_Melt_lb; double m_T_Melt_ub; double m_DD_FAC_lb; double m_DD_FAC_ub; int m_delay; int m_obj_func; double m_NSEmin; double m_NSE; double m_NSE_highflow; double m_NSE_lowflow; double m_PBIAS; // percent bias int m_counter; // used by writing output table //----------------------------------------------------------------- /////////////////////////////////////////////////////////////////// // // PRIVATE FUNCTIONS // /////////////////////////////////////////////////////////////////// //----------------------------------------------------------------- void _InitPointers(); void _DeletePointers(); void _ReadInputTable(int first, int last); void _Calc_ObsMinInflow(); //----------------------------------------------------------------- //----------------------------------------------------------------- // Simulation //----------------------------------------------------------------- void _CalcNonLinearModule(); void _CalcLinearModule(); void _CalcEfficiency(); //----------------------------------------------------------------- //----------------------------------------------------------------- // Output //----------------------------------------------------------------- void _CreateOutputTable(); //void _CreateTable2Storages(); void _WriteOutputTable(); //void _WriteTable2Storages(); //----------------------------------------------------------------- //----------------------------------------------------------------- // Dialogs //----------------------------------------------------------------- void _CreateDialog1(); bool _CreateDialog2(); //----------------------------------------------------------------- }; #endif /* HEADER_INCLUDED__ihacres_cal2_H */ saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_basin.h0000744000175000017500000001652212737416207025460 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_basin.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_basin.h // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-01-30 // //-------------------------------------------------------// //*******************************************************// // ToDo // //-------------------------------------------------------// // - //*******************************************************// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ihacres_basin_H #define HEADER_INCLUDED__ihacres_basin_H //--------------------------------------------------------- #include "MLB_Interface.h" #include "ihacres_eq.h" //--------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // CLASS Cihacres_sub_basin // /////////////////////////////////////////////////////////////////////// class Cihacres_subbasin { public: /////////////////////////////////////////////////////////////////// // // CONSTRUCTORS // /////////////////////////////////////////////////////////////////// // default Cihacres_subbasin(void) { m_pPCP = NULL; m_pTMP = NULL; m_pER = NULL; m_p_Q_sim_mmday = NULL; m_pTw = NULL; m_pWI = NULL; m_pMeltRate = NULL; m_pSnowStorage = NULL; } Cihacres_subbasin(int nvals) { Initialize(nvals); } // destructor ~Cihacres_subbasin(void) { if (m_pPCP) delete[] m_pPCP; if (m_pTMP) delete[] m_pTMP; if (m_pER) delete[] m_pER; if (m_p_Q_sim_mmday) delete[] m_p_Q_sim_mmday; if (m_pTw) delete[] m_pTw; if (m_pWI) delete[] m_pWI; if (m_pMeltRate) delete[] m_pMeltRate; if (m_pSnowStorage) delete[] m_pSnowStorage; } void Initialize(int nvals) { m_nValues = nvals; m_pPCP = new double[nvals]; m_pTMP = new double[nvals]; m_pER = new double[nvals]; m_p_Q_sim_mmday = new double[nvals]; m_pTw = new double[nvals]; m_pWI = new double[nvals]; m_pMeltRate = new double[nvals]; m_pSnowStorage = new double[nvals]; } /////////////////////////////////////////////////////////////////// // // PARAMETERS // /////////////////////////////////////////////////////////////////// //----------------------------------------------------------------- // TIME SERIES //----------------------------------------------------------------- int m_nValues; double* m_pPCP; // precipitation time series double* m_pTMP; // temperature time series double* m_pER; // excess rainfall time series double* m_p_Q_sim_mmday; // simulated streamflow time series [mm] !!! double* m_pTw; // double* m_pWI; // Wetness Index double* m_pMeltRate; double* m_pSnowStorage; //----------------------------------------------------------------- // //----------------------------------------------------------------- // lag coefficient // this parameter is to account for the time lag between the streamflow signal // at the subbasin outlet and the time of this signal at // the catchment/bain outlet int m_lag; int m_delay; double m_area; // sub-catchment area [km2] double m_sum_eRainGTpcp; private: }; //------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // CLASS Cihacres_basin // /////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------- class Cihacres_basin : public CSG_Module { public: /////////////////////////////////////////////////////////////////// // // CONSTRUCTORS // /////////////////////////////////////////////////////////////////// // default Cihacres_basin(void); // destructor ~Cihacres_basin(void); virtual bool needs_GUI (void) { return( true ); } protected: /////////////////////////////////////////////////////////////////// // // PROTECTED FUNCTIONS // /////////////////////////////////////////////////////////////////// // execute module virtual bool On_Execute (void); private: /////////////////////////////////////////////////////////////////// // // PRIVATE PARAMETERS // /////////////////////////////////////////////////////////////////// //----------------------------------------------------------------- //---------------------------------- // parameters of first module dialog //---------------------------------- int m_nSubbasins; // number of sub-basins //double m_Area_tot; // total catchment area [km2] int m_IHAC_version; // Different versions of IHACRES exist, corresponding // to the version... int m_StorConf; // Storage configuration // 0 = single, 1 = two in parallel, 2 = two in series bool m_bSnowModule; // true if snow module is active int m_nStorages; // number of storages //---------------------------------- // parameters of second module dialog //---------------------------------- // time series variables CSG_Table* m_p_InputTable; // IHACRES input table int m_nValues; // number of selected records date_array m_vec_date; double* m_p_Q_obs_m3s; // pointer containing observed streamflow in [m3/s] double* m_p_Q_obs_mmday; // pointer containing observed streamflow in [mm] Cihacres_subbasin* m_pSubbasin; // Class Cihacres_elev_bands // Field numbers int m_dateField; // table field numbers int m_streamflowField; // subbasin band parameters int* m_p_pcpField; int* m_p_tmpField; //double* m_p_mean_elev; //---------------------------------- // parameters of third module dialog //---------------------------------- CSG_String m_date1; // first day of time series YYYYMMDD CSG_String m_date2; // last day int m_first; int m_last; //---------------------------------- // Model parameter (in: ihacres_eq.h) //---------------------------------- C_IHAC_LinearParms* m_p_linparms; // parameters of the linear storage module C_IHAC_NonLinearParms* m_p_nonlinparms; // parameters of the non-linear rainfall loss module CSnowParms* m_pSnowparms; // 3 snow module parameters CSnowModule* m_p_SnowModule; //int m_delay; double m_vq; double m_vs; CSG_Table* m_pTable; //-------------------------------------------------------- // PRIVATE MEMBER FUNCTIONS //-------------------------------------------------------- void _Init_Subbasins(int n); // n = m_nElevBands void _Init_Pointers(int nvals); void _CreateDialog1(); bool _CreateDialog2(); bool _CreateDialog3(); void _ReadInputFile(); void _CalcSnowModule(int nSubbasins); void _Simulate_NonLinearModule(int nSubbasins); void _Simulate_Streamflow(int nSubbasins, double Q_init); void _CreateTableSim(); // Class ihacres_eq Cihacres_eq ihacres; }; #endif /* HEADER_INCLUDED__ihacres_basin_H */ saga-2.3.1/src/modules/simulation/sim_ihacres/snow_module.cpp0000744000175000017500000002245212737416210025545 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snow_module.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ //////////////////////////////////////////////////////////////// // File: // snow_module.cpp // // A class to calculate a time series of // snow melt and snow storage. // // Author: // Stefan Liersch: stefan.liersch@gmail.com, stefan.liersch@ufz.de // // Date: 2007-10-05 // last modified: 2007-10-05 // //-------------------------------------------------------------- // DESCRIPTION //-------------------------------------------------------------- // This class provides functions to calculate snow melt processes, // based on the simple degree-day method. // INPUT: // - Daily temperature and precipitation time series // This could be double* pointers or double vectors. // In both cases the output (snow storage and melt rate) will be double* !!! // - T_Rain : temperature threshold, T < T_Rain precip = snow (range: -10 to +10�C) // - T_Melt : temperature threshold, T > T_Melt = Snow storage starts melting (range: -5 to +10�C) // - DD_FAC : day-degree factor (range: 0.7 to 9.2) // OUTPUT: // - double* m_pSnowStorage[i] // - double* m_pMeltRate[i] //-------------------------------------------------------------- // REFERENCES //-------------------------------------------------------------- // - The Encyclopedia of Water // http://www.wileywater.com/Contributor/Sample_3.htm // - Chang, A. T. C., J. L. Foster, P. Gloersen, W. J. Campbell, E. G. Josberger, A. Rango and Z. F. Danes (1987) // Estimating snowpack parameters in the Colorado River basin. // In: Proc. Large Scale Effects of Seasonal Snow Cover, // IAHS Publ. No. 166, 343-353. // - Singh, P. and Singh, V.P. (2001) // Snow and Glacier Hydrology. // Kluwer Academic Publishers, Dordrecht, The Netherlands, p. 221 //-------------------------------------------------------------- // ToDo //-------------------------------------------------------------- // - implementation for vector instead of double* //-------------------------------------------------------------- //-------------------------------------------------------------- #include #include "snow_module.h" //-------------------------------------------------------------- //-------------------------------------------------------------- #define max(a, b) (((a) > (b)) ? (a) : (b)) //-------------------------------------------------------------- //-------------------------------------------------------------- // CONSTRUCTORS //-------------------------------------------------------------- CSnowModule::CSnowModule(int size) { InitParms(size); } //-------------------------------------------------------------- // double* INPUT // CSnowModule::CSnowModule(double *temperature, double *precipitation, int size, double T_Rain, double T_Melt, double DD_FAC) { m_T_Rain = T_Rain; m_T_Melt = T_Melt; m_DD_FAC = DD_FAC; m_size = size; InitParms(m_size); // perform snow storage and snow melt calculations Calc_SnowModule(temperature, precipitation, m_size, T_Rain, T_Melt, DD_FAC); } //-------------------------------------------------------------- // vector INPUT // CSnowModule::CSnowModule(vector_d temperature, vector_d precipitation, double T_Rain, double T_Melt, double DD_FAC) { m_T_Rain = T_Rain; m_T_Melt = T_Melt; m_DD_FAC = DD_FAC; m_size = temperature.size(); InitParms(m_size); // perform snow storage and snow melt calculations Calc_SnowModule(temperature, precipitation, T_Rain, T_Melt, DD_FAC); } //-------------------------------------------------------------- // DESTRUCTOR //-------------------------------------------------------------- CSnowModule::~CSnowModule() { if (m_pSnowStorage) delete[] m_pSnowStorage; if (m_pMeltRate) delete[] m_pMeltRate; } //-------------------------------------------------------------- // // PUBLIC FUNCTIONS // //-------------------------------------------------------------- void CSnowModule::InitParms(int size) { m_size = size; m_pSnowStorage = new double[m_size]; m_pMeltRate = new double[m_size]; _ZeroPointers(); } //-------------------------------------------------------------- double *CSnowModule::Get_SnowStorage(double *snow_storage, int size) { for (int i = 0; i < size; i++) snow_storage[i] = m_pSnowStorage[i]; return(snow_storage); } //-------------------------------------------------------------- double *CSnowModule::Get_MeltRate(double *melt_rate, int size) { for (int i = 0; i < size; i++) melt_rate[i] = m_pMeltRate[i]; return(melt_rate); } //-------------------------------------------------------------- // // SET FUNCTIONS // //-------------------------------------------------------------- bool CSnowModule::Set_T_Rain(double value) { if (value >= -10.0 && value <= 10.0) { m_T_Rain = value; return(true); } else { return(false); } } //-------------------------------------------------------------- bool CSnowModule::Set_T_Melt(double value) { if (value >= -5.0 && value <= 10.0) { m_T_Melt = value; return(true); } else { return(false); } } //-------------------------------------------------------------- bool CSnowModule::Set_DD_FAC(double value) { if (value >= 0.7 && value <= 9.2) { m_DD_FAC = value; return(true); } else { return(false); } } //-------------------------------------------------------------- // // CALCULATE Snow storage and melt rate // //-------------------------------------------------------------- //-------------------------------------------------------------- // double* INPUT //-------------------------------------------------------------- bool CSnowModule::Calc_SnowModule(double *temperature, double *precipitation, unsigned int size, double T_Rain, double T_Melt, double DD_FAC) { // still missing!!! // what happens with precipitation at the same day as // snowmelt is calculated? // is it correct to handle this in excess rainfall function only? if (size != m_size) return(false); _ZeroPointers(); m_T_Rain = T_Rain; m_T_Melt = T_Melt; m_DD_FAC = DD_FAC; double T_diff; for (unsigned int i = 1; i < size; i++) { // calculate snow accumulation if (temperature[i] < T_Rain) { m_pSnowStorage[i] = m_pSnowStorage[i-1] + precipitation[i]; m_pMeltRate[i] = 0.0; } // calculate snowmelt if (temperature[i] > T_Melt) { T_diff = temperature[i] - T_Melt; m_pMeltRate[i] = DD_FAC * max(0.0,T_diff); if (m_pMeltRate[i] > m_pSnowStorage[i-1]) { m_pMeltRate[i] = m_pSnowStorage[i-1]; m_pSnowStorage[i] = 0.0; } m_pSnowStorage[i] = m_pSnowStorage[i-1] - m_pMeltRate[i]; } // if temperature between T_Rain and T_Melt if ((temperature[i] > T_Rain) && (temperature[i] < T_Melt)) { /* T_diff = temperature[i] - T_Melt; m_pMeltRate[i] = (DD_FAC * max(0.0, T_diff)) / 2; */ m_pMeltRate[i] = 0.0; if (precipitation[i] > 0.0) m_pMeltRate[i] = precipitation[i] / 2; if (m_pMeltRate[i] > m_pSnowStorage[i-1]) { m_pMeltRate[i] = m_pSnowStorage[i-1]; m_pSnowStorage[i] = 0.0; } m_pSnowStorage[i] = m_pSnowStorage[i-1] - m_pMeltRate[i]; } if (m_pSnowStorage[i] < 0.0) m_pSnowStorage[i] = 0.0; } return(true); } //-------------------------------------------------------------- // vector INPUT //-------------------------------------------------------------- bool CSnowModule::Calc_SnowModule(vector_d temperature, vector_d precipitation, double T_Rain, double T_Melt, double DD_FAC) { // still missing!!! // what happens with precipitation at the same day as // snowmelt is calculated? // is it correct to handle this in excess rainfall function only? if (temperature.size() != m_size || precipitation.size() != m_size) return(false); int size = m_size; _ZeroPointers(); m_T_Rain = T_Rain; m_T_Melt = T_Melt; m_DD_FAC = DD_FAC; double T_diff; for (int i = 1; i < size; i++) { // calculate snow accumulation if (temperature[i] < T_Rain) { m_pSnowStorage[i] = m_pSnowStorage[i-1] + precipitation[i]; m_pMeltRate[i] = 0.0; } // calculate snowmelt if (temperature[i] > T_Melt) { T_diff = temperature[i] - T_Melt; m_pMeltRate[i] = DD_FAC * max(0.0,T_diff); if (m_pMeltRate[i] > m_pSnowStorage[i-1]) { m_pMeltRate[i] = m_pSnowStorage[i-1]; m_pSnowStorage[i] = 0.0; } m_pSnowStorage[i] = m_pSnowStorage[i-1] - m_pMeltRate[i]; } // if temperature between T_Rain and T_Melt if ((temperature[i] > T_Rain) && (temperature[i] < T_Melt)) { /* T_diff = temperature[i] - T_Melt; m_pMeltRate[i] = (DD_FAC * max(0.0, T_diff)) / 2; */ m_pMeltRate[i] = 0.0; if (precipitation[i] > 0.0) m_pMeltRate[i] = precipitation[i] / 2; if (m_pMeltRate[i] > m_pSnowStorage[i-1]) { m_pMeltRate[i] = m_pSnowStorage[i-1]; m_pSnowStorage[i] = 0.0; } m_pSnowStorage[i] = m_pSnowStorage[i-1] - m_pMeltRate[i]; } if (m_pSnowStorage[i] < 0.0) m_pSnowStorage[i] = 0.0; } return(true); } //-------------------------------------------------------------- // // PRIVATE FUNCTIONS // //-------------------------------------------------------------- void CSnowModule::_ZeroPointers() { // This is important, because only on days where snow // accumulats or melts a value is assigned to the pointers if (m_pSnowStorage != NULL && m_pMeltRate != NULL && m_size > 0) { for (unsigned int i = 0; i < m_size; i++) { m_pSnowStorage[i] = 0.0; m_pMeltRate[i] = 0.0; } } } saga-2.3.1/src/modules/simulation/sim_ihacres/convert_sl.h0000744000175000017500000000416612737416207025045 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: convert_sl.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ #ifndef __convert_sl_h #define __convert_sl_h #include #include #include // function StringToDouble #ifdef _SAGA_LINUX #include #endif using std::string; using std::istringstream; // function StringToDouble using std::stringstream; // used by function Double2String(), Int2String() namespace convert_sl { // if a string is a char* then: // sprintf(myString, "%d", myInt); // or: // _itoa(myInt, myString, 10); //--------------------------------------------------------------------- // Converting a string to an integer value int StringToInt(string str); //--------------------------------------------------------------------- // Converting a string to a double value double StringToDouble (string s); //--------------------------------------------------------------------- // Any Number to std::string //--------------------------------------------------------------------- string Number2String(double d); string Number2String(float f); string Number2String(int i); string Number2String(long l); //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Converting a double to a string value string Double2String(double d); //--------------------------------------------------------------------- // Converting a float to a string value string Float2String(float f); //--------------------------------------------------------------------- // Converting an integer to a string value string Int2String(int i); //--------------------------------------------------------------------- // Converting a string value to bool bool StringToBool(string str); //--------------------------------------------------------------------- // Converting a date string 'YYYYMMDD' to three separate integer values void Get_Date_Int(string date, int &year, int &month, int &day); }; #endif /* __convert_sl_h */ saga-2.3.1/src/modules/simulation/sim_ihacres/model_tools.cpp0000744000175000017500000002255712737416210025540 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: model_tools.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ #include "model_tools.h" #include #include // random numbers //------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // OBJECTIVE FUNCTIONS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Calculate Nash-Sutcliff efficiency //--------------------------------------------------------------------- double model_tools::CalcEfficiency(double *obs, double *sim, int nvals) { int i; double sum_obsminsim_2 = 0.0; double sum_obsminmean_2 = 0.0; double mean_obs = 0.0; //double sum_obs = 0.0; // sum of observed discharge // calculate mean of observed time series for (i = 0; i < nvals; i++) mean_obs += obs[i] / nvals; for (i = 0; i < nvals; i++) { sum_obsminsim_2 += pow(obs[i] - sim[i], 2.0); sum_obsminmean_2 += pow(obs[i] - mean_obs, 2.0); } return (1 - sum_obsminsim_2 / sum_obsminmean_2); } //------------------------------------------------------------------- double model_tools::CalcEfficiency(vector_d &obs, vector_d &sim) { int i; int nvals = obs.size(); double sum_obsminsim_2 = 0.0; double sum_obsminmean_2 = 0.0; double mean_obs = 0.0; //double sum_obs = 0.0; // sum of observed discharge // calculate mean of observed time series for (i = 0; i < nvals; i++) mean_obs += obs[i] / nvals; for (i = 0; i < nvals; i++) { sum_obsminsim_2 += pow(obs[i] - sim[i], 2.0); sum_obsminmean_2 += pow(obs[i] - mean_obs, 2.0); } return (1 - sum_obsminsim_2 / sum_obsminmean_2); } //------------------------------------------------------------------- // Calculate Nash-Sutcliff efficiency adapted to high flow // Reference: // Liu and De Smedt, 2004. WetSpa Extension, // A GIS-based Hydrologic Model for Flood Prediction and Watershed Management // Documentation and User Manual. Brussels. Vrije Universiteit Brussel. double model_tools::Calc_NSE_HighFlow(double *obs, double *sim, int nvals) { int i; double mean_obs = 0.0; double sum_numerator = 0.0; double sum_denominator = 0.0; // calculate mean of observed time series for (i = 0; i < nvals; i++) mean_obs += obs[i] / nvals; for (i = 0; i < nvals; i++) { sum_numerator += ( (obs[i] + mean_obs) * pow(sim[i] - obs[i], 2.0)); sum_denominator += ( (obs[i] + mean_obs) * pow(obs[i] - mean_obs, 2.0)); } return ( 1 - sum_numerator / sum_denominator ); } //------------------------------------------------------------------- //------------------------------------------------------------------- // Calculate Nash-Sutcliff efficiency adapted to high flow // Reference: // Liu and De Smedt, 2004. WetSpa Extension, // A GIS-based Hydrologic Model for Flood Prediction and Watershed Management // Documentation and User Manual. Brussels. Vrije Universiteit Brussel. double model_tools::Calc_NSE_LowFlow(double *obs, double *sim, int nvals) { int i; double mean_obs = 0.0; double sum_log_obsminsim_2 = 0.0; double sum_log_obsminmean_2 = 0.0; // calculate mean of observed time series for (i = 0; i < nvals; i++) mean_obs += obs[i] / nvals; for (i = 0; i < nvals; i++) { sum_log_obsminsim_2 += pow( (log(obs[i])-log(sim[i])),2 ); sum_log_obsminmean_2 += pow( (log(obs[i])-log(mean_obs)),2 ); } return( 1 - sum_log_obsminsim_2 / sum_log_obsminmean_2); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Calculate PBIAS //--------------------------------------------------------------------- double model_tools::Calc_PBIAS(double* obs, double* sim, int nvals) { double sim_min_obs = 0.0; double sum_obs = 0.0; for (int i = 0; i < nvals; i++) { sim_min_obs += sim[i] - obs[i]; sum_obs += obs[i]; } return(sim_min_obs * 100 / sum_obs); } //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // RUNOFF COEFFICIENT // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Calculate Runoff Coefficient //--------------------------------------------------------------------- double model_tools::CalcRunoffCoeff(vector_d &streamflow, vector_d &precipitation) { // calculate runoff coefficient as stated in: // Kokkonen, T. S. et al. (2003). double sum_flow = 0; double sum_pcp = 0; for (unsigned int i = 0; i < streamflow.size(); i++) { sum_flow += streamflow[i]; sum_pcp += precipitation[i]; } return (sum_flow / sum_pcp * 100); } //--------------------------------------------------------------------- double model_tools::CalcRunoffCoeff(double *streamflow, double *precipitation, int nvals) { // calculate runoff coefficient as stated in: // Kokkonen, T. S. et al. (2003). double sum_flow = 0; double sum_pcp = 0; for (int i = 0; i < nvals; i++) { sum_flow += streamflow[i]; sum_pcp += precipitation[i]; } return (sum_flow / sum_pcp * 100); } /////////////////////////////////////////////////////////////////////// // // UNIT CONVERSION // /////////////////////////////////////////////////////////////////////// double model_tools::m3s_to_mmday(double val, double area) { return(val * 86.4 / area); } //--------------------------------------------------------------------- double *model_tools::m3s_to_mmday(double *m3s, double *mmday, int nvals, double area) { for (int i = 0; i < nvals; i++) mmday[i] = m3s[i] * 86.4 / area; return(mmday); } //--------------------------------------------------------------------- vector_d model_tools::m3s_to_mmday(vector_d &m3s, vector_d &mmday, double area) { for (unsigned int i = 0; i < m3s.size(); i++) mmday[i] = m3s[i] * 86.4 / area; return(mmday); } //--------------------------------------------------------------------- double model_tools::mmday_to_m3s(double val, double area) { return(val * area / 86.4); } //--------------------------------------------------------------------- double *model_tools::mmday_to_m3s(double *mmday, double *m3s, int nvals, double area) { for (int i = 0; i < nvals; i++) m3s[i] = mmday[i] * area / 86.4; return(m3s); } //--------------------------------------------------------------------- vector_d model_tools::mmday_to_m3s(vector_d &mmday, vector_d &m3s, double area) { for (unsigned int i = 0; i < m3s.size(); i++) m3s[i] = mmday[i] * area / 86.4; return(m3s); } /////////////////////////////////////////////////////////////////////// // // MISC // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Create a random number //--------------------------------------------------------------------- double model_tools::Random_double(double lb, double ub) { // lb = lower bound, ub = upper bound double random; random = rand()/(1.+RAND_MAX); random = lb + (ub - lb) * random; return(random); } //------------------------------------------------------------------- //--------------------------------------------------------------------- // Leap year function //--------------------------------------------------------------------- bool model_tools::LeapYear(int year) { if ( (year % 4 == 0) && (year % 100 != 0) || (year % 400 == 0) ) return(true); else return(false); } //------------------------------------------------------------------- //--------------------------------------------------------------------- // Find indices of lowest values //--------------------------------------------------------------------- void model_tools::FindLowestIndices(double *array, int nvals, int *TopIndex, int top) { double min_temp = 99999999.0; double x = -99999999.0; int index = 0; for (int k = 0; k < top; k++) { for (int j = 0; j < nvals; j++) { if (array[j] < min_temp && array[j] > x) { min_temp = array[j]; index = j; } } TopIndex[k] = index; x = min_temp; min_temp = 99999999.0; } } //--------------------------------------------------------------------- // Find indices of highest values //--------------------------------------------------------------------- void model_tools::FindHighestIndices(double *array, int nvals, int *TopIndex, int top, double min) { double max_temp = -99999999.0; double x = 99999999.0; int index = 0; bool exist = false; for (int k = 0; k < top; k++) { for (int j = 0; j < nvals; j++) { if (array[j] > max_temp && array[j] < x && array[j] > min) { max_temp = array[j]; index = j; exist = true; } } if (exist) { TopIndex[k] = index; } else { TopIndex[k] = -1; } exist = false; x = max_temp; max_temp = -99999999.0; } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // summarize arrays //--------------------------------------------------------------------- double model_tools::SumArray(double* array, unsigned int size) { double sum = 0.0; for (unsigned int i = 0; i < size; i++) { sum += array[i]; } return(sum); } //--------------------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_elev.cpp0000744000175000017500000006535212737416207025657 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev.cpp 1261 2011-12-16 15:12:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_elev.cpp // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-01-08 // /////////////////////////////////////////////////////////// #include "ihacres_elev.h" #include "convert_sl.h" #include "model_tools.h" // TEST OUTPUT ONLY #include //--------------------------------------------------------------------- Cihacres_elev::Cihacres_elev() { //----------------------------------------------------- // 1. Info... Set_Name(_TL("IHACRES Elevation Bands")); Set_Author(SG_T("copyrights (c) 2008 Stefan Liersch")); Set_Description(_TW("The Rainfall-Runoff Model IHACRES \n \n \n" "Reference: \n \n" "Jakeman, A.J. / Hornberger, G.M. (1993). \n" "How Much Complexity Is Warranted in a Rainfall-Runoff Model? \n" "Water Resources Research, (29), NO. 8 (2637-2649) \n \n" "Croke, B. F. W., W. S. Merritt, et al. (2004).\n" "A dynamic model for predicting hydrologic response " "to land cover changes in gauged and " "ungauged catchments. \n" "Journal Of Hydrology 291(1-2): 115-131." )); Parameters.Add_Table_Output( NULL , "TABLEout" , _TL("Table"), _TL("") ); /////////////////////////////////////////////////////////////////// // FIRST MODULE DIALOG _CreateDialog1(); /////////////////////////////////////////////////////////////////// } Cihacres_elev::~Cihacres_elev() {} //--------------------------------------------------------------------- bool Cihacres_elev::On_Execute() { CSG_Parameters P; //std::ofstream f("_out_elev.txt"); // Assign Parameters from first Module Dialog //--------------------------------------------------------- int eb = Parameters("NELEVBANDS") ->asInt(); m_nElevBands = eb + 2; // because list starts with 2 ! m_Area_tot = Parameters("AREA_tot") ->asDouble(); m_IHAC_version = Parameters("IHACVERS") ->asInt(); m_StorConf = Parameters("STORAGE") ->asInt(); m_bSnowModule = Parameters("SNOW_MODULE") ->asBool(); //--------------------------------------------------------- //--------------------------------------------------------- // Assign number of storages m_nStorages = ihacres.Assign_nStorages(m_StorConf); //--------------------------------------------------------- //--------------------------------------------------------- // Initialize pointers _Init_ElevBands(m_nElevBands); m_p_linparms = new C_IHAC_LinearParms(m_nElevBands,m_nStorages); m_p_nonlinparms = new C_IHAC_NonLinearParms(m_nElevBands); //--------------------------------------------------------- //--------------------------------------------------------- // open second and third user dialog if ( _CreateDialog2() && _CreateDialog3()) { //--------------------------------------------------------- // searching the first and the last record of the time range ihacres.AssignFirstLastRec(*m_p_InputTable, m_first, m_last, m_date1, m_date2, m_dateField); m_nValues = m_last - m_first + 1; //--------------------------------------------------------- //--------------------------------------------------------- _Init_Pointers(m_nValues); //--------------------------------------------------------- //--------------------------------------------------------- // read input table _ReadInputFile(); //--------------------------------------------------------- //--------------------------------------------------------- // PERFORM STREAMFLOW SIMULATION // FOR EACH ELEVATION BAND //--------------------------------------------------------- // Convert Streamflow vector from m3/s*day-1 to mm/day m_p_Q_obs_mmday = model_tools::m3s_to_mmday(m_p_Q_obs_m3s, m_p_Q_obs_mmday, m_nValues, m_Area_tot); //--------------------------------------------------------- // SNOW MODULE //--------------------------------------------------------- for (int i = 0; i < m_nElevBands; i++) { if (m_bSnowModule) { _CalcSnowModule(i); } _Simulate_NonLinearModule(i); _Simulate_Streamflow(i); } //--------------------------------------------------------- m_pTable = SG_Create_Table(); _CreateTableSim(); // add tables to SAGA Workspace m_pTable->Set_Name(SG_T("IHACRES_ElevBands_output")); Parameters("TABLEout")->Set_Value(m_pTable); delete[] m_p_elevbands; // sämtliche Unter-Pointer noch löschen delete[] m_p_pcpField; delete[] m_p_tmpField; delete m_p_linparms; delete m_p_nonlinparms; if (m_bSnowModule) delete[] m_pSnowparms; return(true); } // end if ( _CreateDialog2() ) // delete[] m_p_elevbands; // delete[] m_p_pcpFields; // delete[] m_p_tmpFields; // delete m_p_linparms; // delete m_p_nonlinparms; return(false); } //--------------------------------------------------------------------- void Cihacres_elev::_Init_ElevBands(int n) { // instantiate elevation bands m_p_elevbands = new Cihacres_elev_bands[n]; // instantiate field numbers m_p_pcpField = new int[n]; m_p_tmpField = new int[n]; if ( m_bSnowModule) { m_pSnowparms = new CSnowParms[n]; } } //--------------------------------------------------------------------- void Cihacres_elev::_Init_Pointers(int nvals) { m_vec_date.resize(nvals); m_p_Q_obs_m3s = new double[nvals]; m_p_Q_obs_mmday = new double[nvals]; for (int eb = 0; eb < m_nElevBands; eb++) { m_p_elevbands[eb].m_p_pcp = new double[nvals]; m_p_elevbands[eb].m_p_tmp = new double[nvals]; m_p_elevbands[eb].m_p_ER = new double[nvals]; m_p_elevbands[eb].m_p_streamflow_sim = new double[nvals]; m_p_elevbands[eb].m_p_Tw = new double[nvals]; m_p_elevbands[eb].m_p_WI = new double[nvals]; if (m_bSnowModule) { m_p_elevbands[eb].m_p_SnowStorage = new double[nvals]; m_p_elevbands[eb].m_p_MeltRate = new double[nvals]; } } } //--------------------------------------------------------------------- void Cihacres_elev::_ReadInputFile() { for (int j = 0, k = m_first; j < m_nValues, k < m_last + 1; j++, k++) { m_vec_date[j].append(CSG_String(m_p_InputTable->Get_Record(k)->asString(m_dateField))); m_p_Q_obs_m3s[j] = m_p_InputTable->Get_Record(k)->asDouble(m_streamflowField); for (int eb = 0; eb < m_nElevBands; eb++) { m_p_elevbands[eb].m_p_pcp[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_pcpField[eb]); m_p_elevbands[eb].m_p_tmp[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_tmpField[eb]); } } } //--------------------------------------------------------------------- void Cihacres_elev::_CalcSnowModule(int eb) { m_p_SnowModule = new CSnowModule(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_pcp, m_nValues, m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_pSnowparms[eb].DD_FAC); m_p_elevbands[eb].m_p_MeltRate = m_p_SnowModule->Get_MeltRate(m_p_elevbands[eb].m_p_MeltRate, m_nValues); m_p_elevbands[eb].m_p_SnowStorage = m_p_SnowModule->Get_SnowStorage(m_p_elevbands[eb].m_p_SnowStorage, m_nValues); delete m_p_SnowModule; } //--------------------------------------------------------------------- void Cihacres_elev::_Simulate_NonLinearModule(int eb) { double eR_init = 0.0; //---------------------------------------------------------- // calculate excess rainfall time series //---------------------------------------------------------- switch(m_IHAC_version) { case 0: // Jakeman & Hornberger (1993) // The parameter index (fourth parameter) is zero here, because // the parameter settings of the non-linear module are in all elevationbands equal. // If they should be different the index parameter can be used to identify the // corresponding elevation band. ihacres.CalcWetnessTimeConst(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_Tw, m_p_nonlinparms, eb, m_nValues); // 0 = index (only one instance of m_p_nonlinparms) if (m_bSnowModule) { ihacres.CalcWetnessIndex(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, 0.5, m_p_nonlinparms->mp_c[eb], m_bSnowModule, m_pSnowparms[eb].T_Rain, m_nValues); ihacres.CalcExcessRain(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_bSnowModule, m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_p_elevbands[eb].m_p_MeltRate); } else { ihacres.CalcWetnessIndex(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, 0.5, m_p_nonlinparms->mp_c[eb], m_bSnowModule, 0, m_nValues); ihacres.CalcExcessRain(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_bSnowModule, 0,0,0); } break; case 1: // Croke et al. (2005) ihacres.CalcWetnessTimeConst_Redesign(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_Tw, m_p_nonlinparms, eb, m_nValues); // 0 = index (only one instance of m_p_nonlinparms) if (m_bSnowModule) { ihacres.CalcWetnessIndex_Redesign(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_WI, 0.5, m_bSnowModule, m_pSnowparms[eb].T_Rain, m_nValues); ihacres.CalcExcessRain_Redesign(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_p_nonlinparms->mp_c[eb], m_p_nonlinparms->mp_l[eb], m_p_nonlinparms->mp_p[eb], m_bSnowModule, m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_p_elevbands[eb].m_p_MeltRate); } else { ihacres.CalcWetnessIndex_Redesign(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_WI, 0.5, m_bSnowModule, 0, m_nValues); ihacres.CalcExcessRain_Redesign(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_p_nonlinparms->mp_c[eb], m_p_nonlinparms->mp_l[eb], m_p_nonlinparms->mp_p[eb], m_bSnowModule, 0,0,0); } break; } // end switch(m_IHAC_vers) } //--------------------------------------------------------------------- void Cihacres_elev::_Simulate_Streamflow(int eb) { //---------------------------------------------------------- //---------------------------------------------------------- // calculate streamflow //---------------------------------------------------------- switch(m_StorConf) { case 0: // single storage ihacres.SimStreamflowSingle(m_p_elevbands[eb].m_p_ER, m_p_Q_obs_mmday[0], m_p_elevbands[eb].m_p_streamflow_sim, m_delay, m_p_linparms->a[eb], m_p_linparms->b[eb], m_nValues); break; case 1: // two storages in parallel ihacres.SimStreamflow2Parallel(m_p_elevbands[eb].m_p_ER, m_p_elevbands[eb].m_p_streamflow_sim, m_p_Q_obs_mmday[0], m_p_linparms, eb, m_vq, m_vs, m_nValues, m_delay); break; case 2: // two storages in series break; } // end switch(m_StorConf) } //--------------------------------------------------------------------- void Cihacres_elev::_CreateTableSim() { int i = 0; // used in function Get_Record(i) CSG_Table_Record *pRecord; CSG_String tmpName; double sim_eb, sim; // creating the column titles m_pTable->Add_Field("Date", SG_DATATYPE_String); m_pTable->Add_Field("Flow_OBS", SG_DATATYPE_Double); for (int eb = 0; eb < m_nElevBands; eb++) { tmpName = SG_T("ELEVB_"); tmpName += convert_sl::Int2String(eb+1).c_str(); m_pTable->Add_Field(tmpName.c_str(), SG_DATATYPE_Double); } m_pTable->Add_Field(SG_T("Flow_SIM"), SG_DATATYPE_Double); for (int j = 0; j < m_nValues; j++) { m_pTable->Add_Record(); pRecord = m_pTable->Get_Record(i); // writing the data into the rows pRecord->Set_Value(0,CSG_String(m_vec_date[j].c_str())); pRecord->Set_Value(1,m_p_Q_obs_m3s[j]); sim_eb = 0.0; sim = 0.0; for (int eb = 0; eb < m_nElevBands; eb++) { sim_eb = model_tools::mmday_to_m3s(m_p_elevbands[eb].m_p_streamflow_sim[j],m_p_elevbands[eb].m_area); //pRecord->Set_Value(3+eb,model_tools::mmday_to_m3s(m_p_elevbands[eb].m_p_streamflow_sim[j],m_p_elevbands[eb].m_area)); pRecord->Set_Value(2+eb, sim_eb); sim += sim_eb; } pRecord->Set_Value(2+m_nElevBands,sim); i++; } } //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // DIALOGS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // DIALOG 1 //--------------------------------------------------------------------- void Cihacres_elev::_CreateDialog1() { CSG_Parameter *pNode; CSG_String s; pNode = Parameters.Add_Choice( NULL , "NELEVBANDS" , SG_T("Number of elevation bands"), _TL(""), SG_T("2|3|4|5|6|7|8|9|10") ); pNode = Parameters.Add_Value( pNode, "AREA_tot", _TL("Total Catchment Area [km2]"), _TL(""), PARAMETER_TYPE_Double ); s.Printf(SG_T("Node1"), 1); pNode = Parameters.Add_Node(NULL,s,SG_T("IHACRES Version"),_TL("")); Parameters.Add_Choice( pNode , "IHACVERS" , SG_T("IHACRES Version"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Jakeman & Hornberger (1993)"), // 0 _TL("Croke et al. (2005) !!! not yet implemented !!!") // 1 ) ); s.Printf(SG_T("Node2"), 2); pNode = Parameters.Add_Node(NULL,s,SG_T("Storage Configuration"),_TL("")); Parameters.Add_Choice( pNode , "STORAGE" , SG_T("Storage"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Single Storage"), // 0 _TL("Two Parallel Storages"), // 1 _TL("Two Storages in Series !!! not yet implemented !!!") // 2 ) ); Parameters.Add_Value( pNode, "SNOW_MODULE", _TL("Using the snow-melt module?"), _TL("If checked, snow-melt module is used."), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------------------- // DIALOG 2 //--------------------------------------------------------------------- bool Cihacres_elev::_CreateDialog2() { int i; //std::ofstream f("_out_elev.txt"); CSG_Parameters P; // used to add Parameters in the second dialog CSG_Parameter *pNode, *pNode1; CSG_String s; CSG_String tmpNode, tmpName; P.Set_Name(_TL("IHACRES Elevation Bands (Dialog 2)")); // Input file ---------------------------------------------- pNode = P.Add_Table( NULL , "TABLE" , _TL("IHACRES Input Table"), _TL(""), PARAMETER_INPUT ); P.Add_Table_Field( pNode , "DATE_Field" , _TL("Date Column"), SG_T("Select the column containing the Date") ); P.Add_Table_Field( pNode , "DISCHARGE_Field" , _TL("Streamflow (obs.) Column"), SG_T("Select the column containing the observed streamflow time series)") ); for (i = 0; i < m_nElevBands; i++) { tmpNode = convert_sl::Int2String(i+1).c_str(); //s.Printf(tmpNode.c_str(), i); //pNode1 = P.Add_Node(NULL,s,SG_T("Elevation Band Input",_TL("")); tmpName = SG_T("PCP Column: Elevation Band: "); tmpName+=tmpNode; P.Add_Table_Field( pNode , tmpName.c_str(), tmpName.c_str(), SG_T("Select Precipitation Column") ); tmpName = SG_T("TMP Column: Elevation Band: "); tmpName+=tmpNode; P.Add_Table_Field( pNode , tmpName.c_str() , tmpName.c_str(), SG_T("Select Temperature Column") ); } // Input file ---------------------------------------------- for (i = 0; i < m_nElevBands; i++) { tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+100).c_str(); tmpName = SG_T("Elevation Band "); tmpName+=convert_sl::Int2String(i+1).c_str(); s.Printf(tmpNode.c_str(), i+100); pNode = P.Add_Node(NULL,s,tmpName.c_str(),_TL("")); tmpName = SG_T("Area [km2] Elev("); tmpName += tmpNode; tmpName += SG_T(")"); P.Add_Value( pNode, tmpName, _TL("Area [km2]"), _TL(""), PARAMETER_TYPE_Double ); tmpName = SG_T("Mean Elevation [m.a.s.l] Elev("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode, tmpName, _TL("Mean Elevation [m.a.s.l]"), _TL(""), PARAMETER_TYPE_Double ); //} // Parameters of non-linear module ------------------------- tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+150).c_str(); s.Printf(tmpNode.c_str(), i+150); pNode1 = P.Add_Node(pNode,s,SG_T("Non-Linear Module"),_TL("")); tmpName = SG_T("TwFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Wetness decline time constant (Tw)"), _TW("Tw is approximately the time constant, or inversely, " "the rate at which the catchment wetness declines in the absence of rainfall"), PARAMETER_TYPE_Double, 1.0, 0.01, true, 150.0, true ); tmpName = SG_T("TFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, SG_T("Temperature Modulation Factor (f)"), _TL("Temperature Modulation Factor f"), PARAMETER_TYPE_Double, 1.0, 0.0001, true, 10.0, true ); tmpName = SG_T("CFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1,tmpName, _TL("Parameter (c)"), _TL("Parameter (c) to fit streamflow volume"), PARAMETER_TYPE_Double, 0.001, 0.0, true, 1.0, true ); switch(m_IHAC_version) { case 0: // Jakeman & Hornberger (1993) break; case 1: // Croke et al. (2005) tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+200).c_str(); s.Printf(tmpNode.c_str(), i+200); pNode1 = P.Add_Node(pNode,s,SG_T("Soil Moisture Power Eq."),_TL("")); tmpName = SG_T("LFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Parameter (l)"), _TL("Soil moisture index threshold"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); tmpName = SG_T("PFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Parameter (p)"), _TL("non-linear response term"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); break; } // Parameters of non-linear module ------------------------- // Parameters of linear module ----------------------------- switch(m_StorConf) { case 0: // single storage tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); s.Printf(tmpNode.c_str(), i+250); pNode1 = P.Add_Node(pNode,s,SG_T("Linear Module"),_TL("")); tmpName = SG_T("AFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("(a)"), _TL(""), PARAMETER_TYPE_Double, -0.8, -0.99, true, -0.01, true ); tmpName = SG_T("BFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("(b)"), _TL(""), PARAMETER_TYPE_Double, 0.2, 0.001, true, 1.0, true ); break; case 1: // two parallel storages tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); s.Printf(tmpNode.c_str(), i+250); pNode1 = P.Add_Node(pNode,s,SG_T("Linear Module"),_TL("")); // Parameter a tmpName = SG_T("AQ("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1,tmpName, _TL("a(q)"), _TL(""), PARAMETER_TYPE_Double, -0.7, -0.99, true, -0.01, true ); tmpName = SG_T("AS("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("a(s)"), _TL(""), PARAMETER_TYPE_Double, -0.9, -0.99, true, -0.01, true ); // Parameter b tmpName = SG_T("BQ("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("b(q)"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); break; case 2: // two storages in series break; } // end switch (storconf) // Parameters of linear module ----------------------------- tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+300).c_str(); s.Printf(tmpNode.c_str(), i+300); pNode1 = P.Add_Node(pNode,s,SG_T("Time Delay after Start of Rainfall (INTEGER)"),_TL("")); tmpName = SG_T("DELAY("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1,tmpName, SG_T("Time Delay (Rain-Runoff)"), SG_T("The delay after the start of rainfall, before the discharge starts to rise."), PARAMETER_TYPE_Int, 0, 1, true, 100, true ); // snow module parameters ---------------------------------- if (m_bSnowModule) { tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+350).c_str(); s.Printf(tmpNode.c_str(), i+350); pNode1 = P.Add_Node(pNode,s,SG_T("Snow Module Parameters"),_TL("")); tmpName = SG_T("T_RAIN("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1,tmpName, SG_T("Temperature Threshold for Rainfall)"), SG_T("Below this threshold precipitation will fall as snow"), PARAMETER_TYPE_Double, -1.0, -10.0, true, 10.0, true ); tmpName = SG_T("T_MELT("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1,tmpName, SG_T("Temperature Threshold for Melting"), SG_T("Above this threshold snow will start to melt"), PARAMETER_TYPE_Double, 1.0, -5.0, true, 10.0, true ); tmpName = SG_T("DD_FAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1,tmpName, SG_T("Day-Degree Factor"), SG_T("Day-Degree Factor depends on catchment characteristics"), PARAMETER_TYPE_Double, 0.7, 0.7, true, 9.2, true ); } // snow module parameters ---------------------------------- } if( SG_UI_Dlg_Parameters(&P, _TL("IHACRES Distributed Input Dialog 2")) ) { // input table m_p_InputTable = P("TABLE") ->asTable(); // field numbers m_dateField = P("DATE_Field") ->asInt(); m_streamflowField = P("DISCHARGE_Field") ->asInt(); for (int i = 0; i < m_nElevBands; i++) { tmpNode = convert_sl::Int2String(i+1).c_str(); // get precipitation column of Elevation Band[i] tmpName = SG_T("PCP Column: Elevation Band: "); tmpName+=tmpNode; m_p_pcpField[i] = P(tmpName) ->asInt(); // get temperature column of Elevation Band[i] tmpName = SG_T("TMP Column: Elevation Band: "); tmpName+=tmpNode; m_p_tmpField[i] = P(tmpName) ->asInt(); tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+100).c_str(); // get area[km2] of Elevation Band[i] tmpName = SG_T("Area [km2] Elev("); tmpName += tmpNode; tmpName += _TL(")"); m_p_elevbands[i].m_area = P(tmpName) ->asDouble(); // get mean elevation of Elevation Band[i] tmpName = SG_T("Mean Elevation [m.a.s.l] Elev("); tmpName += tmpNode; tmpName += _TL(")"); m_p_elevbands[i].m_mean_elev =P(tmpName) ->asDouble(); // non-linear module parameters tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+150).c_str(); // get Tw tmpName = SG_T("TwFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nonlinparms->mp_tw[i] = P(tmpName) ->asDouble(); // get f tmpName = SG_T("TFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nonlinparms->mp_f[i] = P(tmpName) ->asDouble(); // get c tmpName = SG_T("CFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nonlinparms->mp_c[i] = P(tmpName) ->asDouble(); switch(m_IHAC_version) { case 0: // Jakeman & Hornberger (1993) break; case 1: // Croke et al. (2005) // get l tmpName = SG_T("LFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nonlinparms->mp_l[i]= P(tmpName) ->asDouble(); // get p tmpName = SG_T("PFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nonlinparms->mp_p[i]= P(tmpName) ->asDouble(); } // linear module parameters switch(m_nStorages) { case 1: // single storage tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); // get a tmpName = SG_T("AFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_linparms->a[i] = P(tmpName) ->asDouble(); // get b tmpName = SG_T("BFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_linparms->b[i] = P(tmpName) ->asDouble(); break; case 2: // two storages tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); // get aq tmpName = SG_T("AQ("); tmpName += tmpNode; tmpName += _TL(")"); m_p_linparms->aq[i] = P(tmpName) ->asDouble(); // get bq tmpName = SG_T("BQ("); tmpName += tmpNode; tmpName += _TL(")"); m_p_linparms->bq[i] = P(tmpName) ->asDouble(); // get as tmpName = SG_T("AS("); tmpName += tmpNode; tmpName += _TL(")"); m_p_linparms->as[i] = P(tmpName) ->asDouble(); // get bs m_p_linparms->bs[i] = ihacres.Calc_Parm_BS(m_p_linparms->aq[i],m_p_linparms->as[i],m_p_linparms->bq[i]); break; } // get delay tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+300).c_str(); tmpName = SG_T("DELAY("); tmpName += tmpNode; tmpName += _TL(")"); m_delay = P(tmpName) ->asInt(); if (m_bSnowModule) { tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+350).c_str(); // get T_RAIN tmpName = SG_T("T_RAIN("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms[i].T_Rain = P(tmpName) ->asDouble(); // get T_MELT tmpName = SG_T("T_MELT("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms[i].T_Melt = P(tmpName) ->asDouble(); // get DD_FAC tmpName = SG_T("DD_FAC("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms[i].DD_FAC = P(tmpName) ->asDouble(); } } return(true); } return(false); } //--------------------------------------------------------------------- // DIALOG 3 //--------------------------------------------------------------------- bool Cihacres_elev::_CreateDialog3() { CSG_String s; CSG_Parameters P; // used to add Parameters in the second dialog CSG_Parameter *pNode; // Dialog design P.Set_Name(_TL("Choose Time Range")); s.Printf(SG_T("Node1"), 1); pNode = P.Add_Node(NULL,s,SG_T("Time Range"),_TL("")); s.Printf(SG_T("FDAY") , 1-1); P.Add_String(pNode,s,_TL("First Day"),_TL(""), m_p_InputTable->Get_Record(0)->asString(m_dateField)); s.Printf(SG_T("LDAY") , 1-2); P.Add_String(pNode,s,_TL("Last Day"),_TL(""), m_p_InputTable->Get_Record(m_p_InputTable->Get_Record_Count()-1)->asString(m_dateField)); if( SG_UI_Dlg_Parameters(&P, _TL("Choose Time Range")) ) { /////////////////////////////////////////////////////////////// // // ASSIGN DATA FROM SECOND DIALOG // /////////////////////////////////////////////////////////////// m_date1 = P(CSG_String::Format(SG_T("FDAY"),m_dateField).c_str())->asString(); m_date2 = P(CSG_String::Format(SG_T("LDAY"),m_streamflowField).c_str())->asString(); return(true); } return(false); } saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_v1.cpp0000744000175000017500000006003112737416210025231 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_v1.cpp 1261 2011-12-16 15:12:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ihacres_v1 // // // //-------------------------------------------------------// // // // ihacres_v1.cpp // // // // Copyright (C) 2006 by // // Stefan Liersch // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // // // 2006-08-31 // //-------------------------------------------------------// // // References: // Jakeman, A.J. / Hornberger, G.M (1993). // How Much Complexity Is Warranted in a // Rainfall-Runoff Model? // Water Resources Research, (29), NO. 8 (2637-2649) // Kokkonen, T. S. et al. (2003). // Predicting daily flows in ungauged catchments: // model regionalization from catchment descriptors // at the Coweeta Hydrologic Laboratory, North Carolina // Hydrological Processes (17), 2219-2238 // Croke, B. F. W., W. S. Merritt, et al. (2004). // A dynamic model for predicting hydrologic response // to land cover changes in gauged and // ungauged catchments. // Journal Of Hydrology 291(1-2): 115-131. //-------------------------------------------------------// //--------------------------------------------------------- #include // used for textfile output (test only) #include // used for textfile output (test only) #include "ihacres_v1.h" //#include "ihacres_cal.h" #include "model_tools.h" //--------------------------------------------------------- // constructor Cihacres_v1::Cihacres_v1(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("IHACRES Version 1.0")); Set_Author(SG_T("copyrights (c) 2008 Stefan Liersch")); Set_Description(_TW("The Rainfall-Runoff Model IHACRES \n \n \n" "Reference: \n \n" "Jakeman, A.J. / Hornberger, G.M. (1993). \n" "How Much Complexity Is Warranted in a Rainfall-Runoff Model? \n" "Water Resources Research, (29), NO. 8 (2637-2649) \n \n" "Croke, B. F. W. et al.(2004).\n" "A dynamic model for predicting hydrologic response " "to land cover changes in gauged and " "ungauged catchments. \n" "Journal Of Hydrology 291(1-2): 115-131." )); /////////////////////////////////////////////////////////////////// // FIRST MODULE DIALOG CreateDialog1(); /////////////////////////////////////////////////////////////////// } //--------------------------------------------------------- // destructor Cihacres_v1::~Cihacres_v1(void) {} //--------------------------------------------------------- bool Cihacres_v1::On_Execute(void) { /////////////////////////////////////////////////////////////////// // // VARIABLES // /////////////////////////////////////////////////////////////////// int j,k; //counter CSG_Table *pTable, *pTable_out, *pTable_parms, *pTable_settings; bool bTMP; // true, if temperature data are used to // to refine wetness index estimation. bool writeAllTimeSeries; int storconf; // storage configuration // 0 = single, 1 = two parallel, 2 = two in series // Assign Parameters from first Module Dialog //--------------------------------------------------------- pTable = Parameters("TABLE") ->asTable(); // Field numbers dateField = Parameters("DATE_Field") ->asInt(); dischargeField = Parameters("DISCHARGE_Field") ->asInt(); pcpField = Parameters("PCP_Field") ->asInt(); tmpField = Parameters("TMP_Field") ->asInt(); bTMP = Parameters("USE_TMP") ->asBool(); c = Parameters("CFAC") ->asDouble(); TwConst = Parameters("TwFAC") ->asDouble(); m_area = Parameters("AREA") ->asDouble(); storconf = Parameters("STORAGE") ->asInt(); IHAC_version = Parameters("IHACVERS") ->asInt(); bSnowModule = Parameters("SNOW_MODULE") ->asBool(); writeAllTimeSeries = Parameters("WRITEALL_TS") ->asBool(); first = last = 0; //--------------------------------------------------------- /////////////////////////////////////////////////////////////////// // Create Second Dialog and assign linear module parameters if ( CreateDialog2(bTMP, storconf, IHAC_version, pTable, dateField, dischargeField) ) { /////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// // searching the first and the last record of the time range ihacres->AssignFirstLastRec(*pTable, first, last, date1, date2, dateField); /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// // INITIALIZE VECTORS sizeAll = last - first + 1; // global array variables date.resize(sizeAll); m_Q_obs_m3s.resize(sizeAll); m_Q_obs_mmday.resize(sizeAll); precipitation.resize(sizeAll); if (bTMP) temperature.resize(sizeAll); for (j = 0, k = first; j < sizeAll, k < last + 1; j++, k++) { date[j].append(CSG_String (pTable->Get_Record(k)->asString(dateField))); m_Q_obs_m3s[j] = pTable->Get_Record(k)->asDouble(dischargeField); precipitation[j] = pTable->Get_Record(k)->asDouble(pcpField); if (bTMP) temperature[j] = pTable->Get_Record(k)->asDouble(tmpField); } if (bSnowModule && bTMP) { m_pSnowModule = new CSnowModule(temperature, precipitation, T_Rain, T_Melt, DD_FAC); if (!bSnowModule) m_pSnowModule = NULL; //m_pSnowModule->MeltRate = new double[sizeAll]; //m_pSnowModule->SnowStorage = new double[sizeAll]; } //--------------------------------------------------------- // Convert streamflow from m3/s to mm/day /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// // // INSTANTIATE CLASS IHACRES // /////////////////////////////////////////////////////////////// // different constructors are available for class ihacres_eq, // depending on availability of temperature data, // storage characteristics, and data storage properties (vector / arrays) switch(storconf) { case 0: // single storage ihacres = new Cihacres_eq(date, m_Q_obs_m3s, precipitation, temperature, TwConst, f, c, l, p, a, 0, b, 0, m_area, bTMP, IHAC_version, storconf, bSnowModule, m_pSnowModule, delay); break; case 1: // two storages in parallel // if temperature data available // and using vectors to store time series data // and 2 storages in parallel ihacres = new Cihacres_eq(date, m_Q_obs_m3s, precipitation, temperature, TwConst, f, c, l, p, aq, as, bq, bs, m_area, bTMP, IHAC_version, storconf, bSnowModule, m_pSnowModule, delay); break; } // end switch //--------------------------------------------------------- // create output tables and add them to SAGA workspace //--------------------------------------------------------- pTable_out = SG_Create_Table(); CreateTableSim(pTable_out, date, m_Q_obs_m3s, ihacres->get_streamflow_sim());//ihacres->streamflow_sim); // add tables to SAGA Workspace pTable_out->Set_Name(SG_T("IHACRES_Sim")); Parameters("TABLEout")->Set_Value(pTable_out); pTable_settings = SG_Create_Table(); if (bSnowModule) { CreateTableSettings(pTable_settings, TwConst, c, f, aq, as, bq, bs, ihacres->get_vq(), ihacres->get_vs(), bSnowModule, m_pSnowModule->Get_T_Rain(), m_pSnowModule->Get_T_Melt(), m_pSnowModule->Get_DD_FAC(), delay, model_tools::CalcRunoffCoeff(m_Q_obs_mmday,precipitation), ihacres->get_NSE(), m_area); } else { CreateTableSettings(pTable_settings, TwConst, c, f, aq, as, bq, bs, ihacres->get_vq(), ihacres->get_vs(), bSnowModule, 0, 0, 0, delay, model_tools::CalcRunoffCoeff(m_Q_obs_mmday,precipitation), ihacres->get_NSE(), m_area); } pTable_settings->Set_Name(SG_T("IHACRES_Settings")); Parameters("TABLEsettings")->Set_Value(pTable_settings); if (writeAllTimeSeries) { pTable_parms = SG_Create_Table(); CreateTableParms(pTable_parms, date, m_Q_obs_m3s, precipitation, temperature, ihacres->get_streamflow_sim(), ihacres->get_excessRain(), ihacres->get_WetnessIndex(), ihacres->get_Tw()); pTable_parms->Set_Name(SG_T("IHACRES_Parms")); Parameters("TABLEparms")->Set_Value(pTable_parms); } /////////////////////////////////////////////////////////////// // DELETE AND RESIZE /////////////////////////////////////////////////////////////// delete ihacres; date.resize(0); m_Q_obs_m3s.resize(0); m_Q_obs_mmday.resize(0); precipitation.resize(0); if (bTMP) temperature.resize(0); if (bSnowModule) delete m_pSnowModule; /////////////////////////////////////////////////////////////// //--------------------------------------------------------- return( true ); // bool Cihacres_cal::On_Execute(void) } else { return(false); } } // end function On_Execute() /////////////////////////////////////////////////////////////////////// // // PRIVATE FUNCTIONS // /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // // CREATE OUTPUT TABLES // /////////////////////////////////////////////////////////////////////// void Cihacres_v1::CreateTableSim(CSG_Table *pTable, date_array date, vector_d strfl_obs, vector_d strfl_sim) { int i = 0; // used in function Get_Record(i) CSG_Table_Record *pRecord; // creating the column titles pTable->Add_Field("Date", SG_DATATYPE_String); pTable->Add_Field("Flow OBS", SG_DATATYPE_Double); pTable->Add_Field("Flow SIM", SG_DATATYPE_Double); for (unsigned int j = 0; j < date.size(); j++) { pTable->Add_Record(); pRecord = pTable->Get_Record(i); // writing the data into the rows pRecord->Set_Value(0,CSG_String(date[j].c_str())); pRecord->Set_Value(1,strfl_obs[j]); pRecord->Set_Value(2,model_tools::mmday_to_m3s(strfl_sim[j],m_area)); i++; } } void Cihacres_v1::CreateTableParms(CSG_Table *pTable, date_array date, vector_d strfl_obs, vector_d precipitation, vector_d temperature, vector_d strfl_sim, vector_d excessRain, vector_d wi, vector_d Tw) { int i = 0; // used in function Get_Record(i) CSG_Table_Record *pRecord; // creating the column titles pTable->Add_Field("Date", SG_DATATYPE_String); pTable->Add_Field("Flow OBS", SG_DATATYPE_Double); pTable->Add_Field("Flow SIM", SG_DATATYPE_Double); pTable->Add_Field("TMP", SG_DATATYPE_Double); pTable->Add_Field("PCP", SG_DATATYPE_Double); pTable->Add_Field("ExcessRain", SG_DATATYPE_Double); pTable->Add_Field("WetnessIndex", SG_DATATYPE_Double); pTable->Add_Field("Tau", SG_DATATYPE_Double); for (unsigned int j = 0; j < date.size(); j++) { pTable->Add_Record(); pRecord = pTable->Get_Record(i); // writing the data into the rows pRecord->Set_Value(0,CSG_String(date[j].c_str())); pRecord->Set_Value(1,strfl_obs[j]); pRecord->Set_Value(2,model_tools::mmday_to_m3s(strfl_sim[j], m_area)); pRecord->Set_Value(3,temperature[j]); pRecord->Set_Value(4,precipitation[j]); pRecord->Set_Value(5,excessRain[j]); pRecord->Set_Value(6,wi[j]); pRecord->Set_Value(7,Tw[j]); i++; } } void Cihacres_v1::CreateTableSettings(CSG_Table *pTable, double Tw, double c, double f, double aq, double as, double bq, double bs, double vq , double vs, bool bSnowModule, double T_Rain, double T_Melt, double DD_FAC, int delay, double RRCoef, double NSE, double m_area) { int count = 1; CSG_Table_Record *pRecord; // creating the column titles pTable->Add_Field("Parameters", SG_DATATYPE_String); pTable->Add_Field("Settings", SG_DATATYPE_Double); pTable->Add_Record(); pRecord = pTable->Get_Record(0); pRecord->Set_Value(0,SG_T("Tau")); pRecord->Set_Value(1,Tw); pTable->Add_Record(); pRecord = pTable->Get_Record(1); pRecord->Set_Value(0,SG_T("c")); pRecord->Set_Value(1,c); pTable->Add_Record(); pRecord = pTable->Get_Record(2); pRecord->Set_Value(0,SG_T("f")); pRecord->Set_Value(1,f); pTable->Add_Record(); pRecord = pTable->Get_Record(3); pRecord->Set_Value(0,SG_T("a(q)")); pRecord->Set_Value(1,aq); pTable->Add_Record(); pRecord = pTable->Get_Record(4); pRecord->Set_Value(0,SG_T("a(s)")); pRecord->Set_Value(1,as); pTable->Add_Record(); pRecord = pTable->Get_Record(5); pRecord->Set_Value(0,SG_T("b(q)")); pRecord->Set_Value(1,bq); pTable->Add_Record(); pRecord = pTable->Get_Record(6); pRecord->Set_Value(0,SG_T("b(s)")); pRecord->Set_Value(1,bs); //pRecord->Set_Value(1,vs * (1 + as)); pTable->Add_Record(); pRecord = pTable->Get_Record(7); pRecord->Set_Value(0,SG_T("v(q)")); pRecord->Set_Value(1,vq); pTable->Add_Record(); pRecord = pTable->Get_Record(8); pRecord->Set_Value(0,SG_T("v(s)")); pRecord->Set_Value(1,vs); pTable->Add_Record(); pRecord= pTable->Get_Record(9); pRecord->Set_Value(0,SG_T("T(q)")); pRecord->Set_Value(1,ihacres->Calc_TimeOfDecay(aq)); pTable->Add_Record(); pRecord= pTable->Get_Record(10); pRecord->Set_Value(0,SG_T("T(s)")); pRecord->Set_Value(1,ihacres->Calc_TimeOfDecay(as)); if (bSnowModule) { pTable->Add_Record(); pRecord = pTable->Get_Record(10+count); pRecord->Set_Value(0,SG_T("T_Rain")); pRecord->Set_Value(1,T_Rain); count++; pTable->Add_Record(); pRecord = pTable->Get_Record(10+count); pRecord->Set_Value(0,SG_T("T_Melt")); pRecord->Set_Value(1,T_Melt); count++; pTable->Add_Record(); pRecord = pTable->Get_Record(10+count); pRecord->Set_Value(0,SG_T("DD_Fac")); pRecord->Set_Value(1,DD_FAC); count++; } pTable->Add_Record(); pRecord = pTable->Get_Record(10+count); pRecord->Set_Value(0,SG_T("RR-Delay")); pRecord->Set_Value(1,delay); count++; pTable->Add_Record(); pRecord = pTable->Get_Record(10+count); pRecord->Set_Value(0,SG_T("RRCoef")); pRecord->Set_Value(1,RRCoef); count++; pTable->Add_Record(); pRecord = pTable->Get_Record(10+count); pRecord->Set_Value(0,SG_T("NSE")); pRecord->Set_Value(1,NSE); count++; pTable->Add_Record(); pRecord = pTable->Get_Record(10+count); pRecord->Set_Value(0,SG_T("Area")); pRecord->Set_Value(1,m_area); count++; } /////////////////////////////////////////////////////////////////////// // // DIALOGS // /////////////////////////////////////////////////////////////////////// void Cihacres_v1::CreateDialog1() { CSG_Parameter *pNode; CSG_String s; pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "DATE_Field" , _TL("Date Column"), SG_T("Select the column containing the Date") ); Parameters.Add_Table_Field( pNode , "DISCHARGE_Field" , _TL("Streamflow Column"), SG_T("Select the Column containing Discharge Values") ); Parameters.Add_Table_Field( pNode , "PCP_Field" , _TL("Precipitation Column"), SG_T("Select the Column containing precipitation Values") ); Parameters.Add_Table_Field( pNode , "TMP_Field" , _TL("Temperature Column"), SG_T("Select the Column containing Temperature Values") ); Parameters.Add_Value( pNode, "USE_TMP", _TL("Using temperature data?"), _TL("If checked, then temperature data are used."), PARAMETER_TYPE_Bool, true ); pNode = Parameters.Add_Value( NULL, "AREA", _TL("Area of the Watershed in [km2]"), _TL("Area of the Watershed in [km2] used for unit conversion"), PARAMETER_TYPE_Double, 100.0, 0.00001, true, 0.0, false ); s.Printf(SG_T("Node2"), 2); pNode = Parameters.Add_Node(NULL,s,SG_T("Non-Linear Module"),_TL("")); Parameters.Add_Value( pNode, "CFAC", _TL("Parameter (c)"), _TL("Parameter (c) to fit streamflow volume"), PARAMETER_TYPE_Double, 0.001, 0.0, true, 1.0, true ); Parameters.Add_Value( pNode, "TwFAC", _TL("(Tw) wetness decline time constant"), _TW("Tw is approximately the time constant, or inversely," "the rate at which the catchment wetness declines in the absence of rainfall"), PARAMETER_TYPE_Double, 1.0, 0.01, true, 150.0, true ); s.Printf(SG_T("Node3"), 3); pNode = Parameters.Add_Node(NULL,s,SG_T("Storage Configuration"),_TL("")); Parameters.Add_Choice( pNode , "STORAGE" , _TL("Storage"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Single Storage"), // 0 _TL("Two Parallel Storages"), // 1 _TL("Two Storages in Series !!! not yet implemented !!!") // 2 ) ); s.Printf(SG_T("Node4"), 4); pNode = Parameters.Add_Node(NULL,s,SG_T("IHACRES Version"),_TL("")); Parameters.Add_Choice( pNode , "IHACVERS" , _TL("IHACRES Version"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Jakeman & Hornberger (1993)"), // 0 _TL("Croke et al. (2005)") // 1 ) ); Parameters.Add_Value( pNode, "SNOW_MODULE", _TL("Using the snow-melt module?"), _TL("If checked, snow-melt module is used."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL, "WRITEALL_TS", _TL("Write all calculated Time Series in a table?"), _TL("If checked, then a second output table with all Time Series data is created."), PARAMETER_TYPE_Bool, true ); Parameters.Add_Table_Output( NULL , "TABLEout" , _TL("Table"), _TL("") ); Parameters.Add_Table_Output( NULL , "TABLEparms" , _TL("Table"), _TL("") ); Parameters.Add_Table_Output( NULL , "TABLEsettings", _TL("Table"), _TL("") ); } //--------------------------------------------------------------------- // DIALOG 2 //--------------------------------------------------------------------- bool Cihacres_v1::CreateDialog2(bool bTMP, int storconf, int IHAC_version, CSG_Table *pTable, int dateField, int dischargeField) { CSG_String s; CSG_Parameters P; // used to add Parameters in the second dialog CSG_Parameter *pNode, *pNode1; // Dialog design P.Set_Name(_TL("IHACRES Model Parameters (Calibration)")); s.Printf(SG_T("Node1"), 1); pNode = P.Add_Node(NULL,s,SG_T("Time Range"),_TL("")); s.Printf(SG_T("FDAY") , 1-1); P.Add_String(pNode,s,_TL("First Day"),_TL(""), pTable->Get_Record(0)->asString(dateField)); s.Printf(SG_T("LDAY") , 1-2); P.Add_String(pNode,s,_TL("Last Day"),_TL(""), pTable->Get_Record(pTable->Get_Record_Count()-1)->asString(dateField)); if (bTMP) // if observed temperature data are used { s.Printf(SG_T("Node2"), 2); pNode = P.Add_Node(NULL,s,SG_T("Non-Linear Module"),_TL("")); s.Printf(SG_T("Node2-1"), 2-1); pNode1 = P.Add_Node(pNode,s,SG_T("Temperature Modulation Factor"),_TL("")); P.Add_Value( pNode1 , "TFac" , _TL("Temperature Modulation Factor (f)"), _TL("Temperature Modulation Factor f"), PARAMETER_TYPE_Double, 1.0, 0.0001, true, 10.0, true ); } // End if (bTMP) switch(IHAC_version) { case 0: // Jakeman & Hornberger (1993) break; case 1: // Croke et al. (2005) s.Printf(SG_T("Node4"), 4); pNode = P.Add_Node(NULL,s,SG_T("Soil Moisture Power Eq."),_TL("")); s.Printf(SG_T("Node4-1"), 4-1); pNode1 = P.Add_Node(pNode,s,SG_T("Parameter l"),_TL("")); P.Add_Value( pNode1,"L",_TL("Soil moisture index (l)"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); s.Printf(SG_T("Node4-2"), 4-2); pNode1 = P.Add_Node(pNode,s,SG_T("Parameter p"),_TL("")); P.Add_Value( pNode1,"P",_TL("Power on soil (p)"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); break; } // end switch (IHAC_version) switch(storconf) { case 0: // single storage s.Printf(SG_T("Node3"), 3); pNode = P.Add_Node(NULL,s,SG_T("Linear Module"),_TL("")); s.Printf(SG_T("Node3-1"), 3-1); pNode1 = P.Add_Node(pNode,s,SG_T("Parameter (a)"),_TL("")); P.Add_Value( pNode1, "AFAC", _TL("(a)"), _TL(""), PARAMETER_TYPE_Double, -0.8, -0.99, true, -0.01, true ); s.Printf(SG_T("Node3-2"), 3-2); pNode1 = P.Add_Node(pNode,s,SG_T("Parameter (b)"),_TL("")); P.Add_Value( pNode1, "BFAC", _TL("(b)"), _TL(""), PARAMETER_TYPE_Double, 0.2, 0.001, true, 1.0, true ); break; case 1: // two parallel storages s.Printf(SG_T("Node3"), 3); pNode = P.Add_Node(NULL,s,SG_T("Linear Module"),_TL("")); // Parameter a s.Printf(SG_T("Node3-1"), 3-1); pNode1 = P.Add_Node(pNode,s,SG_T("Parameter (a)"),_TL("")); P.Add_Value( pNode1, "AQ", _TL("a(q)"), _TL(""), PARAMETER_TYPE_Double, -0.7, -0.99, true, -0.01, true ); P.Add_Value( pNode1, "AS", _TL("a(s)"), _TL(""), PARAMETER_TYPE_Double, -0.9, -0.99, true, -0.01, true ); // Parameter b s.Printf(SG_T("Node3-2"), 3-2); pNode1 = P.Add_Node(pNode,s,SG_T("Parameter (b)"),_TL("")); P.Add_Value( pNode1, "BQ", _TL("b(q)"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); break; case 2: // two storages in series break; } // end switch (storconf) if (bSnowModule) { s.Printf(SG_T("Node5"), 5); pNode1 = P.Add_Node(NULL,s,SG_T("Snow Module Parameters"),_TL("")); P.Add_Value( pNode1, "T_RAIN", _TL("Temperature Threshold for Rainfall"), _TL("Below this threshold precipitation will fall as snow"), PARAMETER_TYPE_Double, -1.0, -10.0, true, 10.0, true ); P.Add_Value( pNode1, "T_MELT", _TL("Temperature Threshold for Melting"), _TL("Above this threshold snow will start to melt"), PARAMETER_TYPE_Double, 1.0, -5.0, true, 10.0, true ); P.Add_Value( pNode1, "DD_FAC", _TL("Day-Degree Factor"), _TL("Day-Degree Factor depends on catchment characteristics"), PARAMETER_TYPE_Double, 0.7, 0.7, true, 9.2, true ); } s.Printf(SG_T("Node6"), 6); pNode1 = P.Add_Node(NULL,s,SG_T("Time Delay after Start of Rainfall (INTEGER)"),_TL("")); P.Add_Value( pNode1, "DELAY", _TL("Time Delay (Rain-Runoff)"), _TL("The delay after the start of rainfall, before the discharge starts to rise."), PARAMETER_TYPE_Int, 1, 0, true, 100, true ); // End of second dialog design if( SG_UI_Dlg_Parameters(&P, _TL("Choose Time Range")) ) { /////////////////////////////////////////////////////////////// // // ASSIGN DATA FROM SECOND DIALOG // /////////////////////////////////////////////////////////////// date1 = P(CSG_String::Format(SG_T("FDAY"),dateField).c_str()) ->asString(); date2 = P(CSG_String::Format(SG_T("LDAY"),dischargeField).c_str()) ->asString(); // if observed temperature data are used if (bTMP) f = P("TFac") ->asDouble(); switch(IHAC_version) { case 0: break; case 1: l = P("L") ->asDouble(); p = P("P") ->asDouble(); break; } if (bSnowModule) { T_Rain = P("T_RAIN") ->asDouble(); T_Melt = P("T_MELT") ->asDouble(); DD_FAC = P("DD_FAC") ->asDouble(); } switch (storconf) { case 0: // single storage a = P("AFAC") ->asDouble(); b = P("BFAC") ->asDouble(); delay = P("DELAY") ->asInt(); break; case 1: // two parallel storages aq = P("AQ") ->asDouble(); as = P("AS") ->asDouble(); bq = P("BQ") ->asDouble(); //bs = P("BS") ->asDouble(); bs = ihacres->Calc_Parm_BS(aq,as,bq); delay = P("DELAY") ->asInt(); break; case 2: // two storages in series break; } // end switch (storconf) return(true); } else { return(false); } }saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_elev_bands.h0000744000175000017500000000541112737416207026461 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev_bands.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_elev_bands.h // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-01-08 // //-------------------------------------------------------// //*******************************************************// // ToDo // //-------------------------------------------------------// // - //*******************************************************// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ihacres_elev_bands_H #define HEADER_INCLUDED__ihacres_elev_bands_H //--------------------------------------------------------- class Cihacres_elev_bands { public: /////////////////////////////////////////////////////////////////// // // CONSTRUCTORS // /////////////////////////////////////////////////////////////////// // default Cihacres_elev_bands(); // destructor ~Cihacres_elev_bands(); /////////////////////////////////////////////////////////////////// // // PARAMETERS // /////////////////////////////////////////////////////////////////// //bool m_b_SnowModule; // true, if snow module is active //int m_IHAC_version; // IHACRES version (Jakeman & Hornberger, 1993 / Croke, B. 2005 /...) // time series variables //double m_nValues; // number of pointer elements (time steps / days / ...) double* m_p_pcp; // precipitation time series double* m_p_tmp; // temperature time series double* m_p_ER; // excess rainfall time series double* m_p_streamflow_sim; // simulated streamflow time series [mm] !!! double* m_p_Tw; // double* m_p_WI; // Wetness Index double* m_p_MeltRate; double* m_p_SnowStorage; double m_sum_eRainGTpcp; double m_mean_elev; // mean elevation of elevation band [m.a.s.l.] double m_area; /////////////////////////////////////////////////////////////////// // // PUBLIC FUNCTIONS // /////////////////////////////////////////////////////////////////// //double Get_Elevation() { return(m_mean_elev); } //double Get_Area() { return(m_area); } private: // elevation band area [km2] }; #endif /* HEADER_INCLUDED__ihacres_elev_bands_H */saga-2.3.1/src/modules/simulation/sim_ihacres/convert_sl.cpp0000744000175000017500000000730712737416207025400 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: convert_sl.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ #include "convert_sl.h" //--------------------------------------------------------------------- // // DATA TYPE // CONVERTING FUNCTIONS // //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Converting a string to an integer value int convert_sl::StringToInt(string str) { int i; sscanf(str.c_str(),"%d",&i); return i; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Converting a string to a double value double convert_sl::StringToDouble (string s) { // function adopted from: // http://episteme.arstechnica.com/groupee/forums/a/tpc/f/6330927813/m/736000556631/p/2 double d_return_value; istringstream iss(s); // Extract a double from the input string stream iss >> d_return_value; if (iss.fail()) { return -9999.0; } return d_return_value; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Any number to string //--------------------------------------------------------------------- string convert_sl::Number2String(double d) { std::ostringstream s; s << d; return(s.str()); } //--------------------------------------------------------------------- string convert_sl::Number2String(float f) { std::ostringstream s; s << f; return(s.str()); } //--------------------------------------------------------------------- string convert_sl::Number2String(int i) { std::ostringstream s; s << i; return(s.str()); } //--------------------------------------------------------------------- string convert_sl::Number2String(long l) { std::ostringstream s; s << l; return(s.str()); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- string convert_sl::Double2String(double d) { std::ostringstream s; s << d; return(s.str()); } //--------------------------------------------------------------------- string convert_sl::Float2String(float f) { std::ostringstream s; s << f; return(s.str()); } //--------------------------------------------------------------------- string convert_sl::Int2String(int i) { // Bjarne Stroustrup's C++ Style and Technique FAQ // http://www.research.att.com/~bs/bs_faq2.html#int-to-string std::ostringstream s; s << i; return(s.str()); } //--------------------------------------------------------------------- bool convert_sl::StringToBool(string str) { if ( (str.substr(0,1) == "0") || (str == "false") || (str == "FALSE") || (str == "False") || (str == "f") || (str == "F") ) { return(false); } else { return(true); } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Converting a date string 'YYYYMMDD' to three separate integer values void convert_sl::Get_Date_Int(string date, int &year, int &month, int &day) { year = StringToInt(date.substr(0,4)); month = StringToInt(date.substr(4,2)); day = StringToInt(date.substr(6,2)); // divide date string to year, month, and day string //string y(date.c_str(),0,4); //string m(date.c_str(),4,2); //string d(date.c_str(),6,2); //// convert to integer //sscanf(y.c_str(),"%d",&year); //sscanf(m.c_str(),"%d",&month); //sscanf(d.c_str(),"%d",&day); } //--------------------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_ihacres/model_tools.h0000744000175000017500000001541512737416210025200 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: model_tools.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // model_tools.h // // // // Copyright (C) 2007 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-01-24 // //-------------------------------------------------------// #ifndef HEADER_INCLUDED__model_tools_H #define HEADER_INCLUDED__model_tools_H #include typedef std::vector vector_d; namespace model_tools { /////////////////////////////////////////////////////////////////////// // // OBJECTIVE FUNCTIONS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Calculate Nash-Sutcliff efficiency //--------------------------------------------------------------------- double CalcEfficiency(double *obs, double *sim, int nvals); double CalcEfficiency(vector_d &obs, vector_d &sim); // Calculate Nash-Sutcliff efficiency adapted to high flow // Reference: // Liu and De Smedt, 2004. WetSpa Extension, // A GIS-based Hydrologic Model for Flood Prediction and Watershed Management – // Documentation and User Manual. Brussels. Vrije Universiteit Brussel. double Calc_NSE_HighFlow(double *obs, double *sim, int nvals); double Calc_NSE_LowFlow (double *obs, double *sim, int nvals); //--------------------------------------------------------------------- //--------------------------------------------------------------------- // PBIAS //--------------------------------------------------------------------- double Calc_PBIAS(double* obs, double* sim, int nvals); //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // RUNOFF COEFFICIENT // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Calculate rainfall-runoff coefficient double CalcRunoffCoeff (double *streamflow, double *precipitation, int nvals); double CalcRunoffCoeff (vector_d &streamflow, vector_d &precipitation); //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // UNIT CONVERSION FUNCTIONS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- double m3s_to_mmday(double val, double area); double* m3s_to_mmday(double *m3s, double *mmday, int nvals, double area); vector_d m3s_to_mmday(vector_d &m3s, vector_d &mmday, double area); double mmday_to_m3s(double val, double area); double* mmday_to_m3s(double *mmday, double *m3s, int nvals, double area); vector_d mmday_to_m3s(vector_d &mmday, vector_d &m3s, double area); //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // MISC // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Produce a random number within the given lower and upper bound // Don't forget to initialize the random function before calling // this function with: srand((unsigned) time(NULL)); // using time.h // include 'stdlib.h' and 'time.h' in the calling program double Random_double(double lb, double ub); //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Returns true if the year is a leap year bool LeapYear(int year); //--------------------------------------------------------------------- //--------------------------------------------------------------------- // This function receives an array of doubles and // returns the indices of the lowest values. // array = array of doubles // nvals = number of values in array // TopIndex = array of indices = return values // top = number of lowest values which indices will be stored in TopIndex void FindLowestIndices(double* array, int nvals, int* TopIndex, int top); //--------------------------------------------------------------------- //--------------------------------------------------------------------- // This function receives an array of doubles and // returns the indices of the highest values. // array = array of doubles // nvals = number of values in array // TopIndex = array of indices = return values // top = number of highest values which indices will be stored in TopIndex // min = minimum void FindHighestIndices(double* array, int nvals, int* TopIndex, int top, double min); //--------------------------------------------------------------------- //--------------------------------------------------------------------- // summarize arrays //--------------------------------------------------------------------- double SumArray(double* array, unsigned int size); }; /////////////////////////////////////////////////////////////////////// // // dynamic array template class // /////////////////////////////////////////////////////////////////////// // http://www.codeguru.com/forum/showthread.php?s=&threadid=231046 template class dynamic_array { public: dynamic_array(){}; dynamic_array(int rows, int cols) { for(int i=0; i(cols)); } } // other ctors .... inline std::vector & operator[](int i) { return data_[i]; } inline const std::vector & operator[] (int i) const { return data_[i]; } // other accessors, like at() ... void resize(int rows, int cols) { data_.resize(rows); for(int i = 0; i < rows; ++i) data_[i].resize(cols); } // other member functions, like reserve().... private: std::vector > data_; }; //--------------------------------------------------------------------- // An example to use the template class //--------------------------------------------------------------------- //int main() //{ // dynamic_array a(3, 3); // a[1][1] = 2; // int x = a[1][1]; // return 0; //} /////////////////////////////////////////////////////////////////////// #endif /* HEADER_INCLUDED__model_tools_H */ saga-2.3.1/src/modules/simulation/sim_ihacres/snow_module.h0000744000175000017500000001055312737416210025211 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: snow_module.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ //////////////////////////////////////////////////////////////// // File: // snow_module.h // // A class to calculate a time series of // snow melt and snow storage. // // Author: // Stefan Liersch: stefan.liersch@gmail.com, stefan.liersch@ufz.de // // Date: 2007-10-05 // last modified: 2007-10-05 // //-------------------------------------------------------------- // DESCRIPTION //-------------------------------------------------------------- // This class provides functions to calculate snow melt processes, // based on the simple degree-day method. // INPUT: // - Daily temperature and precipitation time series // This could be double* pointers or double vectors. // In both cases the output (snow storage and melt rate) will be double* !!! // - T_Rain : temperature threshold, T < T_Rain precip = snow (range: -10 to +10�C) // - T_Melt : temperature threshold, T > T_Melt = Snow storage starts melting (range: -5 to +10�C) // - DD_FAC : day-degree factor (range: 0.7 to 9.2) // OUTPUT: // - double* m_pSnowStorage[i] // - double* m_pMeltRate[i] //-------------------------------------------------------------- // REFERENCES //-------------------------------------------------------------- // - The Encyclopedia of Water // http://www.wileywater.com/Contributor/Sample_3.htm // - Chang, A. T. C., J. L. Foster, P. Gloersen, W. J. Campbell, E. G. Josberger, A. Rango and Z. F. Danes (1987) // Estimating snowpack parameters in the Colorado River basin. // In: Proc. Large Scale Effects of Seasonal Snow Cover, // IAHS Publ. No. 166, 343-353. // - Singh, P. and Singh, V.P. (2001) // Snow and Glacier Hydrology. // Kluwer Academic Publishers, Dordrecht, The Netherlands, p. 221 //-------------------------------------------------------------- // ToDo //-------------------------------------------------------------- // - implementation for vector instead of double* //-------------------------------------------------------------- #ifndef HEADER_INCLUDED__snow_module_H #define HEADER_INCLUDED__snow_module_H #include // used for storing date string values in array typedef std::vector vector_d; //-------------------------------------------------------------- class CSnowParms { public: CSnowParms() { T_Rain = 0.0; T_Melt = 0.0; DD_FAC = 0.0; } double T_Rain; double T_Melt; double DD_FAC; }; //-------------------------------------------------------------- class CSnowModule { public: CSnowModule(int size); CSnowModule(double *temperature, double *precipitation, int size, double T_Rain, double T_Melt, double DD_FAC); // using double vectors as input instead of double* CSnowModule(vector_d temperature, vector_d precipitation, double T_Rain, double T_Melt, double DD_FAC); ~CSnowModule(); //---------------------------------------------- // PUBLIC FUNCTIONS //---------------------------------------------- void InitParms(int size); double Get_SnowStorage(unsigned int i) { return( i < m_size ? m_pSnowStorage[i] : -9999); } double* Get_SnowStorage(double *snow_storage, int size); double Get_MeltRate(unsigned int i) { return( i < m_size ? m_pMeltRate[i] : -9999); } double* Get_MeltRate(double *melt_rate, int size); double Get_T_Rain() { return(m_T_Rain); } double Get_T_Melt() { return(m_T_Melt); } double Get_DD_FAC() { return(m_DD_FAC); } bool Set_T_Rain(double value); bool Set_T_Melt(double value); bool Set_DD_FAC(double value); bool Calc_SnowModule(double *temperature, double *precipitation, unsigned int size,// pointer size (temperature, precip) double T_Rain, double T_Melt, double DD_FAC); //---------------------------------------------- private: void _ZeroPointers(); // variables double* m_pSnowStorage; double* m_pMeltRate; unsigned int m_size; // number of values in arrays, time steps double m_T_Rain; double m_T_Melt; double m_DD_FAC; //-------------------------------------------------------------- // // FUNCTIONS FOR VECTORS // //-------------------------------------------------------------- public: bool Calc_SnowModule(vector_d temperature, vector_d precipitation, double T_Rain, double T_Melt, double DD_FAC); }; #endif /* HEADER_INCLUDED__snow_module_H */ saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_basin.cpp0000744000175000017500000006607312737416207026021 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_basin.cpp 1261 2011-12-16 15:12:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_basin.cpp // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-01-30 // /////////////////////////////////////////////////////////// //*******************************************************// // ToDo // //-------------------------------------------------------// // - lag COEFFICIENT in write output table IMPLEMENTIEREN !!!!!!! //*******************************************************// #define NULL 0 #include "ihacres_basin.h" #include "convert_sl.h" #include "model_tools.h" //--------------------------------------------------------------------- Cihacres_basin::Cihacres_basin() { //----------------------------------------------------- // 1. Info... Set_Name(_TL("IHACRES Basin")); Set_Author(SG_T("copyrights (c) 2008 Stefan Liersch")); Set_Description(_TW( "The Rainfall-Runoff Model IHACRES \n \n \n" "Reference: \n \n" "Jakeman, A.J. / Hornberger, G.M. (1993). \n" "How Much Complexity Is Warranted in a Rainfall-Runoff Model? \n" "Water Resources Research, (29), NO. 8 (2637-2649) \n \n" "Croke, B. F. W., W. S. Merritt, et al. (2004).\n" "A dynamic model for predicting hydrologic response " "to land cover changes in gauged and " "ungauged catchments. \n" "Journal Of Hydrology 291(1-2): 115-131." )); Parameters.Add_Table_Output( NULL , "TABLEout" , _TL("Table"), _TL("") ); /////////////////////////////////////////////////////////////////// // FIRST MODULE DIALOG _CreateDialog1(); /////////////////////////////////////////////////////////////////// } //--------------------------------------------------------------------- Cihacres_basin::~Cihacres_basin() {} //--------------------------------------------------------------------- //--------------------------------------------------------------------- // ON_EXECUTE //--------------------------------------------------------------------- bool Cihacres_basin::On_Execute() { CSG_Parameters P; //std::ofstream f("_out_elev.txt"); // Assign Parameters from first Module Dialog //--------------------------------------------------------- int nSBS = Parameters("NSUBBASINS") ->asInt(); m_nSubbasins = nSBS + 2; // because list starts with 2 ! m_IHAC_version = Parameters("IHACVERS") ->asInt(); m_StorConf = Parameters("STORAGE") ->asInt(); m_bSnowModule = Parameters("SNOW_MODULE") ->asBool(); //--------------------------------------------------------- //--------------------------------------------------------- // Assign number of storages m_nStorages = ihacres.Assign_nStorages(m_StorConf); //--------------------------------------------------------- //--------------------------------------------------------- // Initialize pointers _Init_Subbasins(m_nSubbasins); m_p_linparms = new C_IHAC_LinearParms(m_nSubbasins,m_nStorages); m_p_nonlinparms = new C_IHAC_NonLinearParms(m_nSubbasins); //--------------------------------------------------------- //--------------------------------------------------------- // open second and third user dialog if ( _CreateDialog2() && _CreateDialog3()) { //--------------------------------------------------------- // searching the first and the last record of the time range ihacres.AssignFirstLastRec(*m_p_InputTable, m_first, m_last, m_date1, m_date2, m_dateField); m_nValues = m_last - m_first + 1; //--------------------------------------------------------- //--------------------------------------------------------- _Init_Pointers(m_nValues); //--------------------------------------------------------- //--------------------------------------------------------- // read input table _ReadInputFile(); //--------------------------------------------------------- //--------------------------------------------------------- // PERFORM STREAMFLOW SIMULATION // FOR EACH ELEVATION BAND //--------------------------------------------------------- // Convert Streamflow vector from m3/s*day-1 to mm/day //m_p_Q_obs_mmday = model_tools::m3s_to_mmday(m_p_Q_obs_m3s, m_p_Q_obs_mmday, m_nValues, m_Area_tot); //--------------------------------------------------------- // SNOW MODULE //--------------------------------------------------------- double Q_init = 1.0; // ??? for (int i = 0; i < m_nSubbasins; i++) { if (m_bSnowModule) { _CalcSnowModule(i); } _Simulate_NonLinearModule(i); _Simulate_Streamflow(i, Q_init); } //--------------------------------------------------------- m_pTable = SG_Create_Table(); _CreateTableSim(); // add tables to SAGA Workspace m_pTable->Set_Name(_TL("IHACRES_Basin_output")); Parameters("TABLEout")->Set_Value(m_pTable); delete[] m_pSubbasin; // sämtliche Unter-Pointer noch löschen delete[] m_p_pcpField; delete[] m_p_tmpField; delete m_p_linparms; delete m_p_nonlinparms; if (m_bSnowModule) delete m_pSnowparms; return(true); } // end if ( _CreateDialog2() ) return(false); } //--------------------------------------------------------------------- void Cihacres_basin::_Init_Subbasins(int n) { // instantiate elevation bands m_pSubbasin = new Cihacres_subbasin[n]; // instantiate field numbers m_p_pcpField = new int[n]; m_p_tmpField = new int[n]; if (m_bSnowModule) { m_pSnowparms = new CSnowParms[n]; } } //--------------------------------------------------------------------- void Cihacres_basin::_Init_Pointers(int n) { m_vec_date.resize(n); m_p_Q_obs_m3s = new double[n]; m_p_Q_obs_mmday = new double[n]; for (int i = 0; i < m_nSubbasins; i++) { m_pSubbasin[i].m_pPCP = new double[n]; m_pSubbasin[i].m_pTMP = new double[n]; m_pSubbasin[i].m_pER = new double[n]; m_pSubbasin[i].m_p_Q_sim_mmday = new double[n]; m_pSubbasin[i].m_pTw = new double[n]; m_pSubbasin[i].m_pWI = new double[n]; } if (m_bSnowModule) { for (int eb = 0; eb < m_nSubbasins; eb++) { m_pSubbasin[eb].m_pSnowStorage = new double[n]; m_pSubbasin[eb].m_pMeltRate = new double[n]; } } } //--------------------------------------------------------------------- void Cihacres_basin::_ReadInputFile() { for (int j = 0, k = m_first; j < m_nValues, k < m_last + 1; j++, k++) { m_vec_date[j].append(CSG_String(m_p_InputTable->Get_Record(k)->asString(m_dateField))); m_p_Q_obs_m3s[j] = m_p_InputTable->Get_Record(k)->asDouble(m_streamflowField); for (int eb = 0; eb < m_nSubbasins; eb++) { m_pSubbasin[eb].m_pPCP[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_pcpField[eb]); m_pSubbasin[eb].m_pTMP[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_tmpField[eb]); } } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- void Cihacres_basin::_CalcSnowModule(int iSBS) { m_p_SnowModule = new CSnowModule(m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pPCP, m_nValues, m_pSnowparms[iSBS].T_Rain, m_pSnowparms[iSBS].T_Melt, m_pSnowparms[iSBS].DD_FAC); m_pSubbasin[iSBS].m_pMeltRate = m_p_SnowModule->Get_MeltRate(m_pSubbasin[iSBS].m_pMeltRate, m_nValues); m_pSubbasin[iSBS].m_pSnowStorage = m_p_SnowModule->Get_SnowStorage(m_pSubbasin[iSBS].m_pSnowStorage, m_nValues); delete m_p_SnowModule; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- void Cihacres_basin::_Simulate_NonLinearModule(int iSBS) { double eR_init = 0.0; double WI_init = 0.5; //---------------------------------------------------------- // calculate excess rainfall time series //---------------------------------------------------------- switch(m_IHAC_version) { case 0: // Jakeman & Hornberger (1993) // The parameter index (fourth parameter) is zero here, because // the parameter settings of the non-linear module are in all elevationbands equal. // If they should be different the index parameter can be used to identify the // corresponding elevation band. ihacres.CalcWetnessTimeConst(m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pTw, m_p_nonlinparms, iSBS, m_nValues); // 0 = index (only one instance of m_p_nonlinparms) if (m_bSnowModule) { ihacres.CalcWetnessIndex(m_pSubbasin[iSBS].m_pTw, m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pWI, WI_init, m_p_nonlinparms->mp_c[iSBS], m_bSnowModule, m_pSnowparms[iSBS].T_Rain, m_nValues); ihacres.CalcExcessRain(m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pWI, m_pSubbasin[iSBS].m_pER, eR_init, m_pSubbasin[iSBS].m_sum_eRainGTpcp, m_nValues, m_bSnowModule, m_pSnowparms[iSBS].T_Rain, m_pSnowparms[iSBS].T_Melt, m_pSubbasin[iSBS].m_pMeltRate); } else { ihacres.CalcWetnessIndex(m_pSubbasin[iSBS].m_pTw, m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pWI, WI_init, m_p_nonlinparms->mp_c[iSBS], m_bSnowModule, 0, m_nValues); ihacres.CalcExcessRain(m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pWI, m_pSubbasin[iSBS].m_pER, eR_init, m_pSubbasin[iSBS].m_sum_eRainGTpcp, m_nValues, m_bSnowModule, 0,0,0); } break; case 1: // Croke et al. (2005) ihacres.CalcWetnessTimeConst_Redesign(m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pTw, m_p_nonlinparms, iSBS, m_nValues); // 0 = index (only one instance of m_p_nonlinparms) if (m_bSnowModule) { ihacres.CalcWetnessIndex_Redesign(m_pSubbasin[iSBS].m_pTw, m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pWI, WI_init, m_bSnowModule, m_pSnowparms[iSBS].T_Rain, m_nValues); ihacres.CalcExcessRain_Redesign(m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pWI, m_pSubbasin[iSBS].m_pER, eR_init, m_pSubbasin[iSBS].m_sum_eRainGTpcp, m_nValues, m_p_nonlinparms->mp_c[iSBS], m_p_nonlinparms->mp_l[iSBS], m_p_nonlinparms->mp_p[iSBS], m_bSnowModule, m_pSnowparms[iSBS].T_Rain, m_pSnowparms[iSBS].T_Melt, m_pSubbasin[iSBS].m_pMeltRate); } else { ihacres.CalcWetnessIndex_Redesign(m_pSubbasin[iSBS].m_pTw, m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pWI, WI_init, m_bSnowModule, 0, m_nValues); ihacres.CalcExcessRain_Redesign(m_pSubbasin[iSBS].m_pPCP, m_pSubbasin[iSBS].m_pTMP, m_pSubbasin[iSBS].m_pWI, m_pSubbasin[iSBS].m_pER, eR_init, m_pSubbasin[iSBS].m_sum_eRainGTpcp, m_nValues, m_p_nonlinparms->mp_c[iSBS], m_p_nonlinparms->mp_l[iSBS], m_p_nonlinparms->mp_p[iSBS], m_bSnowModule, 0,0,0); } break; } // end switch(m_IHAC_vers) } //--------------------------------------------------------------------- //--------------------------------------------------------------------- void Cihacres_basin::_Simulate_Streamflow(int iSBS, double Q_init) { //---------------------------------------------------------- //---------------------------------------------------------- // calculate streamflow //---------------------------------------------------------- switch(m_StorConf) { case 0: // single storage ihacres.SimStreamflowSingle(m_pSubbasin[iSBS].m_pER, Q_init, m_pSubbasin[iSBS].m_p_Q_sim_mmday, m_pSubbasin[iSBS].m_delay, m_p_linparms->a[iSBS], m_p_linparms->b[iSBS], m_nValues); break; case 1: // two storages in parallel ihacres.SimStreamflow2Parallel(m_pSubbasin[iSBS].m_pER, m_pSubbasin[iSBS].m_p_Q_sim_mmday, Q_init, m_p_linparms, iSBS, m_vq, m_vs, m_nValues, m_pSubbasin[iSBS].m_delay); break; case 2: // two storages in series break; } // end switch(m_StorConf) } //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // CREATE TABLE // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- void Cihacres_basin::_CreateTableSim() { int i = 0; // used in function Get_Record(i) CSG_Table_Record *pRecord; CSG_String tmpName; double sim_sbs, sim; // creating the column titles m_pTable->Add_Field("Date", SG_DATATYPE_String); m_pTable->Add_Field("Flow_OBS", SG_DATATYPE_Double); for (int sbs = 0; sbs < m_nSubbasins; sbs++) { tmpName = "SBS_"; tmpName += convert_sl::Int2String(sbs+1).c_str(); m_pTable->Add_Field(tmpName.c_str(), SG_DATATYPE_Double); } m_pTable->Add_Field("Flow_SIM", SG_DATATYPE_Double); for (int j = 0; j < m_nValues; j++) { m_pTable->Add_Record(); pRecord = m_pTable->Get_Record(i); // writing the data into the rows pRecord->Set_Value(0,CSG_String(m_vec_date[j].c_str())); pRecord->Set_Value(1,m_p_Q_obs_m3s[j]); sim_sbs = 0.0; sim = 0.0; for (int sbs = 0; sbs < m_nSubbasins; sbs++) { sim_sbs = model_tools::mmday_to_m3s(m_pSubbasin[sbs].m_p_Q_sim_mmday[j],m_pSubbasin[sbs].m_area); //pRecord->Set_Value(3+eb,model_tools::mmday_to_m3s(m_p_elevbands[eb].m_p_streamflow_sim[j],m_p_elevbands[eb].m_area)); pRecord->Set_Value(2+sbs, sim_sbs); sim += sim_sbs; } pRecord->Set_Value(2+m_nSubbasins,sim); i++; } } /////////////////////////////////////////////////////////////////////// // // DIALOGS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // DIALOG 1 //--------------------------------------------------------------------- void Cihacres_basin::_CreateDialog1() { CSG_Parameter *pNode; CSG_String s; pNode = Parameters.Add_Choice( NULL , "NSUBBASINS" , _TL("Number of sub-basins"), _TL(""), SG_T("2|3|4|5|6|7|8|9|10") ); s.Printf(SG_T("Node1"), 1); pNode = Parameters.Add_Node(NULL,s,_TL("IHACRES Version"),_TL("")); Parameters.Add_Choice( pNode , "IHACVERS" , _TL("IHACRES Version"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Jakeman & Hornberger (1993)"), // 0 _TL("Croke et al. (2005) !!! not yet implemented !!!") // 1 ) ); s.Printf(SG_T("Node2"), 2); pNode = Parameters.Add_Node(NULL,s,_TL("Storage Configuration"),_TL("")); Parameters.Add_Choice( pNode , "STORAGE" , _TL("Storage"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Single Storage"), // 0 _TL("Two Parallel Storages"), // 1 _TL("Two Storages in Series !!! not yet implemented !!!") // 2 ) ); Parameters.Add_Value( pNode, "SNOW_MODULE", _TL("Using the snow-melt module?"), _TL("If checked, snow-melt module is used."), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------------------- // DIALOG 2 //--------------------------------------------------------------------- bool Cihacres_basin::_CreateDialog2() { //std::ofstream f("_out_elev.txt"); int i; CSG_Parameters P; // used to add Parameters in the second dialog CSG_Parameter *pNode, *pNode1; CSG_String s; CSG_String tmpNode, tmpName; P.Set_Name(_TL("IHACRES Basin (Dialog 2)")); // Input file ---------------------------------------------- pNode = P.Add_Table( NULL , "TABLE" , _TL("IHACRES Input Table"), _TL(""), PARAMETER_INPUT ); P.Add_Table_Field( pNode , "DATE_Field" , _TL("Date Column"), _TL("Select the column containing the Date") ); P.Add_Table_Field( pNode , "DISCHARGE_Field" , _TL("Streamflow (obs.) Column"), _TL("Select the column containing the observed streamflow time series") ); for (i = 0; i < m_nSubbasins; i++) { tmpNode = convert_sl::Int2String(i+1).c_str(); tmpName = _TL("PCP Column: Subbasin: "); tmpName+=tmpNode; P.Add_Table_Field( pNode , tmpName.c_str(), tmpName.c_str(), _TL("Select Precipitation Column") ); tmpName = _TL("TMP Column: Subbasin: "); tmpName+=tmpNode; P.Add_Table_Field( pNode , tmpName.c_str() , tmpName.c_str(), _TL("Select Temperature Column") ); } // Input file ---------------------------------------------- for (i = 0; i < m_nSubbasins; i++) { tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+100).c_str(); tmpName = _TL("Subbasin "); tmpName+=convert_sl::Int2String(i+1).c_str(); s.Printf(tmpNode.c_str(), i+100); pNode = P.Add_Node(NULL,s,tmpName.c_str(),_TL("")); tmpName = _TL("Area [km2] Subbasin("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode, tmpName, _TL("Area [km2]"), _TL(""), PARAMETER_TYPE_Double ); tmpName = "Lag Subbasin("; tmpName += tmpNode; tmpName += ")"; P.Add_Value( pNode, tmpName, _TL("Lag coefficient"), _TL(""), PARAMETER_TYPE_Int ); // Parameters of non-linear module ------------------------- tmpNode = "Node"; tmpNode+=convert_sl::Int2String(i+150).c_str(); s.Printf(tmpNode.c_str(), i+150); pNode1 = P.Add_Node(pNode,s,_TL("Non-Linear Module"),_TL("")); tmpName = _TL("TwFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Wetness decline time constant (Tw)"), _TW("Tw is approximately the time constant, or inversely," "the rate at which the catchment wetness declines in the absence of rainfall"), PARAMETER_TYPE_Double, 1.0, 0.01, true, 150.0, true ); tmpName = _TL("TFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1 , tmpName , _TL("Temperature Modulation Factor (f)"), _TL("Temperature Modulation Factor f"), PARAMETER_TYPE_Double, 1.0, 0.0001, true, 10.0, true ); tmpName = _TL("CFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Parameter (c)"), _TL("Parameter (c) to fit streamflow volume"), PARAMETER_TYPE_Double, 0.001, 0.0, true, 1.0, true ); switch(m_IHAC_version) { case 0: // Jakeman & Hornberger (1993) break; case 1: // Croke et al. (2005) tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+200).c_str(); s.Printf(tmpNode.c_str(), i+200); pNode1 = P.Add_Node(pNode,s,_TL("Soil Moisture Power Eq."),_TL("")); tmpName = "LFAC("; tmpName += tmpNode; tmpName += ")"; P.Add_Value( pNode1, tmpName, _TL("Parameter (l)"), _TL("Soil moisture index threshold"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); tmpName = "PFAC("; tmpName += tmpNode; tmpName += ")"; P.Add_Value( pNode1, tmpName, _TL("Parameter (p)"), _TL("non-linear response term"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); break; } // Parameters of non-linear module ------------------------- // Parameters of linear module ----------------------------- switch(m_StorConf) { case 0: // single storage tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); s.Printf(tmpNode.c_str(), i+250); pNode1 = P.Add_Node(pNode,s,_TL("Linear Module"),_TL("")); tmpName = _TL("AFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("(a)"), _TL(""), PARAMETER_TYPE_Double, -0.8, -0.99, true, -0.01, true ); tmpName = _TL("BFAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("(b)"), _TL(""), PARAMETER_TYPE_Double, 0.2, 0.001, true, 1.0, true ); break; case 1: // two parallel storages tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); s.Printf(tmpNode.c_str(), i+250); pNode1 = P.Add_Node(pNode,s,_TL("Linear Module"),_TL("")); // Parameter a tmpName = _TL("AQ("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("a(q)"), _TL(""), PARAMETER_TYPE_Double, -0.7, -0.99, true, -0.01, true ); tmpName = _TL("AS("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("a(s)"), _TL(""), PARAMETER_TYPE_Double, -0.9, -0.99, true, -0.01, true ); // Parameter b tmpName = _TL("BQ("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("b(q)"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); break; case 2: // two storages in series break; } // end switch (storconf) // Parameters of linear module ----------------------------- tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+300).c_str(); s.Printf(tmpNode.c_str(), i+300); pNode1 = P.Add_Node(pNode,s,_TL("Time Delay after Start of Rainfall (INTEGER)"),_TL("")); tmpName = _TL("DELAY("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Time Delay (Rain-Runoff)"), _TL("The delay after the start of rainfall, before the discharge starts to rise."), PARAMETER_TYPE_Int, 0, 1, true, 100, true ); // snow module parameters ---------------------------------- if (m_bSnowModule) { tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+350).c_str(); s.Printf(tmpNode.c_str(), i+350); pNode1 = P.Add_Node(pNode,s,_TL("Snow Module Parameters"),_TL("")); tmpName = _TL("T_RAIN("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Temperature Threshold for Rainfall"), _TL("Below this threshold precipitation will fall as snow"), PARAMETER_TYPE_Double, -1.0, -10.0, true, 10.0, true ); tmpName = _TL("T_MELT("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Temperature Threshold for Melting"), _TL("Above this threshold snow will start to melt"), PARAMETER_TYPE_Double, 1.0, -5.0, true, 10.0, true ); tmpName = _TL("DD_FAC("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Day-Degree Factor"), _TL("Day-Degree Factor depends on catchment characteristics"), PARAMETER_TYPE_Double, 0.7, 0.7, true, 9.2, true ); } // snow module parameters ---------------------------------- } if( SG_UI_Dlg_Parameters(&P, _TL("IHACRES Distributed Input Dialog 2")) ) { // input table m_p_InputTable = P("TABLE") ->asTable(); // field numbers m_dateField = P("DATE_Field") ->asInt(); m_streamflowField = P("DISCHARGE_Field") ->asInt(); for (int i = 0; i < m_nSubbasins; i++) { tmpNode = convert_sl::Int2String(i+1).c_str(); // get precipitation column of Subbasin[i] tmpName = _TL("PCP Column: Subbasin: "); tmpName+=tmpNode; m_p_pcpField[i] = P(tmpName) ->asInt(); // get temperature column of Subbasin[i] tmpName = _TL("TMP Column: Subbasin: "); tmpName+=tmpNode; m_p_tmpField[i] = P(tmpName) ->asInt(); tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+100).c_str(); // get area[km2] of Subbasin[i] tmpName = _TL("Area [km2] Subbasin("); tmpName += tmpNode; tmpName += _TL(")"); m_pSubbasin[i].m_area = P(tmpName) ->asDouble(); // get lag coefficient of Subbasin[i] tmpName = _TL("Lag Subbasin("); tmpName += tmpNode; tmpName += _TL(")"); m_pSubbasin[i].m_lag = P(tmpName) ->asInt(); tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+150).c_str(); // get Tw tmpName = _TL("TwFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nonlinparms->mp_tw[i] = P(tmpName) ->asDouble(); // get f tmpName = _TL("TFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nonlinparms->mp_f[i] = P(tmpName) ->asDouble(); // get c tmpName = _TL("CFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nonlinparms->mp_c[i] = P(tmpName) ->asDouble(); switch(m_IHAC_version) { case 0: // Jakeman & Hornberger (1993) break; case 1: // Croke et al. (2005) tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+200).c_str(); // get l tmpName = _TL("LFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nonlinparms->mp_l[i]= P(tmpName) ->asDouble(); // get p tmpName = _TL("PFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nonlinparms->mp_p[i]= P(tmpName) ->asDouble(); } // linear module parameters switch(m_nStorages) { case 1: // single storage tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); // get a tmpName = _TL("AFAC()"); tmpName += tmpNode; tmpName += _TL(")"); m_p_linparms->a[i] = P(tmpName) ->asDouble(); // get b tmpName = _TL("BFAC("); tmpName += tmpNode; tmpName += _TL(")"); m_p_linparms->b[i] = P(tmpName) ->asDouble(); break; case 2: // two storages tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); // get aq tmpName = _TL("AQ("); tmpName += tmpNode; tmpName += _TL(")"); m_p_linparms->aq[i] = P(tmpName) ->asDouble(); // get bq tmpName = _TL("BQ("); tmpName += tmpNode; tmpName += _TL(")"); m_p_linparms->bq[i] = P(tmpName) ->asDouble(); // get as tmpName = _TL("AS("); tmpName += tmpNode; tmpName += _TL(")"); m_p_linparms->as[i] = P(tmpName) ->asDouble(); m_p_linparms->bs[i] = ihacres.Calc_Parm_BS(m_p_linparms->aq[i],m_p_linparms->as[i],m_p_linparms->bq[i]); break; } // get delay tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+300).c_str(); tmpName = _TL("DELAY("); tmpName += tmpNode; tmpName += _TL(")"); m_pSubbasin[i].m_delay = P(tmpName) ->asInt(); if (m_bSnowModule) { tmpNode = _TL("Node"); tmpNode+=convert_sl::Int2String(i+350).c_str(); tmpName = _TL("T_RAIN("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms[i].T_Rain = P(tmpName) ->asDouble(); tmpName = _TL("T_MELT("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms[i].T_Melt = P(tmpName) ->asDouble(); tmpName = _TL("DD_FAC("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms[i].DD_FAC = P(tmpName) ->asDouble(); } } // end for (int i = 0; i < m_nSubbasins; i++) return(true); } return(false); } //--------------------------------------------------------------------- // DIALOG 3 //--------------------------------------------------------------------- bool Cihacres_basin::_CreateDialog3() { CSG_String s; CSG_Parameters P; // used to add Parameters in the second dialog CSG_Parameter *pNode; // Dialog design P.Set_Name(_TL("Choose Time Range")); s.Printf(SG_T("Node"), 1); pNode = P.Add_Node(NULL,s,_TL("Time Range"),_TL("")); s.Printf(SG_T("FDAY") , 1-1); P.Add_String(pNode,s,_TL("First Day"),_TL(""), m_p_InputTable->Get_Record(0)->asString(m_dateField)); s.Printf(SG_T("LDAY") , 1-2); P.Add_String(pNode,s,_TL("Last Day"),_TL(""), m_p_InputTable->Get_Record(m_p_InputTable->Get_Record_Count()-1)->asString(m_dateField)); if( SG_UI_Dlg_Parameters(&P, _TL("Choose Time Range")) ) { /////////////////////////////////////////////////////////////// // // ASSIGN DATA FROM SECOND DIALOG // /////////////////////////////////////////////////////////////// m_date1 = P(CSG_String::Format(SG_T("FDAY"),m_dateField).c_str())->asString(); m_date2 = P(CSG_String::Format(SG_T("LDAY"),m_streamflowField).c_str())->asString(); return(true); } return(false); } saga-2.3.1/src/modules/simulation/sim_ihacres/Makefile.in0000664000175000017500000005741012737447617024575 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/simulation/sim_ihacres ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_ihacres_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_ihacres_la_OBJECTS = convert_sl.lo ihacres_basin.lo \ ihacres_cal2.lo ihacres_elev.lo ihacres_elev_bands.lo \ ihacres_elev_cal.lo ihacres_eq.lo ihacres_v1.lo \ MLB_Interface.lo model_tools.lo snow_module.lo libsim_ihacres_la_OBJECTS = $(am_libsim_ihacres_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_ihacres_la_SOURCES) DIST_SOURCES = $(libsim_ihacres_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_ihacres.la libsim_ihacres_la_SOURCES = \ convert_sl.cpp\ ihacres_basin.cpp\ ihacres_cal2.cpp\ ihacres_elev.cpp\ ihacres_elev_bands.cpp\ ihacres_elev_cal.cpp\ ihacres_eq.cpp\ ihacres_v1.cpp\ MLB_Interface.cpp\ model_tools.cpp\ snow_module.cpp\ convert_sl.h\ ihacres_basin.h\ ihacres_cal2.h\ ihacres_elev.h\ ihacres_elev_bands.h\ ihacres_elev_cal.h\ ihacres_eq.h\ ihacres_v1.h\ MLB_Interface.h\ model_tools.h\ snow_module.h libsim_ihacres_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/simulation/sim_ihacres/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_ihacres/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_ihacres.la: $(libsim_ihacres_la_OBJECTS) $(libsim_ihacres_la_DEPENDENCIES) $(EXTRA_libsim_ihacres_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_ihacres_la_OBJECTS) $(libsim_ihacres_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/convert_sl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_basin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_cal2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_elev.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_elev_bands.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_elev_cal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_eq.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ihacres_v1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/model_tools.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snow_module.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_elev_cal.h0000744000175000017500000001204212737416210026121 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev_cal.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_elev_cal.h // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-02-13 // //-------------------------------------------------------// //*******************************************************// // ToDo // //-------------------------------------------------------// // - //*******************************************************// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ihacres_elev_cal_H #define HEADER_INCLUDED__ihacres_elev_cal_H //--------------------------------------------------------- #include "MLB_Interface.h" #include "ihacres_eq.h" #include "ihacres_elev_bands.h" #include "snow_module.h" #include // used for storing date string values in array //using namespace std; typedef std::vector date_array; class Cihacres_elev_cal : public CSG_Module { public: //-------------------------------------------------------- // CONSTRUCTORS //-------------------------------------------------------- // default Cihacres_elev_cal(); // destructor virtual ~Cihacres_elev_cal(void); virtual bool needs_GUI (void) { return( true ); } protected: // execute module virtual bool On_Execute(void); private: //-------------------------------------------------------- // PRIVATE MEMBER VARIABLES //-------------------------------------------------------- int m_counter; //---------------------------------- // parameters of first module dialog //---------------------------------- int m_nElevBands; // number of used elevation bands int m_nsim; // number of simulations double m_Area_tot; // total catchment area [km2] int m_IHAC_version; // Different versions of IHACRES exist, corresponding // to the version... int m_StorConf; // Storage configuration // 0 = single, 1 = two in parallel, 2 = two in series bool m_bSnowModule; // true if snow module is active int m_nStorages; // number of storages int m_obj_func; double m_NSEmin; //---------------------------------- // parameters of second module dialog //---------------------------------- // time series variables CSG_Table* m_p_InputTable; // IHACRES input table int m_nValues; // number of selected records date_array m_vec_date; double* m_p_Q_obs_m3s; // pointer containing observed streamflow in [m3/s] double* m_p_Q_obs_mmday; // pointer containing observed streamflow in [mm] double* m_p_Q_sim_mmday; Cihacres_elev_bands* m_p_elevbands; // Class Cihacres_elev_cal_bands // Field numbers int m_dateField; // table field numbers int m_streamflowField; // elevation band parameters int* m_p_pcpField; int* m_p_tmpField; //double* m_p_Area; //double* m_p_mean_elev; //---------------------------------- // parameters of third module dialog //---------------------------------- CSG_String m_date1; // first day of time series YYYYMMDD CSG_String m_date2; // last day int m_first; int m_last; //---------------------------------- // Model parameter (in: ihacres_eq.h) //---------------------------------- C_IHAC_LinearParms* m_p_lin_lb; C_IHAC_LinearParms* m_p_lin_ub; C_IHAC_LinearParms* m_p_linparms; // parameters of the linear storage module C_IHAC_NonLinearParms* m_p_nl_lb; C_IHAC_NonLinearParms* m_p_nl_ub; C_IHAC_NonLinearParms* m_p_nonlinparms; // parameters of the non-linear rainfall loss module CSnowParms* m_pSnowparms_lb; CSnowParms* m_pSnowparms_ub; CSnowParms* m_pSnowparms; // 3 snow module paramters CSnowModule* m_p_SnowModule; int m_delay; double* m_vq; double* m_vs; double m_NSE; double m_NSE_highflow; double m_NSE_lowflow; double m_PBIAS; CSG_Table* m_pTable; CSG_Table* m_pTable_parms; //-------------------------------------------------------- // PRIVATE MEMBER FUNCTIONS //-------------------------------------------------------- void _Init_ElevBands(int n); // n = m_nElevBands void _Init_Pointers(int nvals); void _CreateDialog1(); bool _CreateDialog2(); bool _CreateDialog3(); void _ReadInputFile(); void _CalcSnowModule(int elevband); void _Simulate_NonLinearModule(); void _Simulate_Streamflow(); void _Sum_Streamflow(); void _CalcEfficiency(); void _CreateTableSim(); void _CreateTableParms(); void _WriteTableParms(); // Class ihacres_eq Cihacres_eq ihacres; }; #endif /* HEADER_INCLUDED__ihacres_elev_cal_H */ saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_elev_cal.cpp0000744000175000017500000012660312737416207026473 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev_cal.cpp 1261 2011-12-16 15:12:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_elev_cal.cpp // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-01-08 // /////////////////////////////////////////////////////////// #include "ihacres_elev_cal.h" #include "convert_sl.h" #include "model_tools.h" #include // random numbers #include // random numbers // TEST OUTPUT ONLY #include //--------------------------------------------------------------------- Cihacres_elev_cal::Cihacres_elev_cal() { //----------------------------------------------------- // 1. Info... Set_Name(_TL("IHACRES Elevation Bands Calibration")); Set_Author(SG_T("copyrights (c) 2008 Stefan Liersch")); Set_Description(_TW("The Rainfall-Runoff Model IHACRES \n \n \n" "Reference: \n \n" "Jakeman, A.J. / Hornberger, G.M. (1993). \n" "How Much Complexity Is Warranted in a Rainfall-Runoff Model? \n" "Water Resources Research, (29), NO. 8 (2637-2649) \n \n" "Kokkonen, T. S. et al. (2003). \n" "Predicting daily flows in ungauged catchments:" "model regionalization from catchment descriptors" "at the Coweeta Hydrologic Laboratory, North Carolina \n " "Hydrological Processes (17), 2219-2238 \n \n" "Croke, B. F. W., W. S. Merritt, et al. (2004).\n" "A dynamic model for predicting hydrologic response" "to land cover changes in gauged and" "ungauged catchments. \n" "Journal Of Hydrology 291(1-2): 115-131." )); Parameters.Add_Table_Output( NULL , "TABLEout" , _TL("Table"), _TL("") ); Parameters.Add_Table_Output( NULL , "TABLEparms" , _TL("Table"), _TL("") ); /////////////////////////////////////////////////////////////////// // FIRST MODULE DIALOG _CreateDialog1(); /////////////////////////////////////////////////////////////////// } Cihacres_elev_cal::~Cihacres_elev_cal() {} //--------------------------------------------------------------------- bool Cihacres_elev_cal::On_Execute() { double NSE_temp = 0.0; double NSE_max = -9999.9; string nse, nse_text; CSG_Parameters P; //std::ofstream f("_out_elev.txt"); // Assign Parameters from first Module Dialog //--------------------------------------------------------- int eb = Parameters("NELEVBANDS") ->asInt(); m_nElevBands = eb + 2; // because list starts with 2 ! m_nsim = Parameters("NSIM") ->asInt(); m_Area_tot = Parameters("AREA_tot") ->asDouble(); m_IHAC_version = Parameters("IHACVERS") ->asInt(); m_StorConf = Parameters("STORAGE") ->asInt(); m_bSnowModule = Parameters("SNOW_MODULE") ->asBool(); m_obj_func = Parameters("OBJ_FUNC") ->asInt(); m_NSEmin = Parameters("NSEMIN") ->asDouble(); //--------------------------------------------------------- //--------------------------------------------------------- // Assign number of storages m_nStorages = ihacres.Assign_nStorages(m_StorConf); //--------------------------------------------------------- //--------------------------------------------------------- // Initialize pointers _Init_ElevBands(m_nElevBands); m_p_linparms = new C_IHAC_LinearParms(m_nElevBands,m_nStorages); m_p_lin_lb = new C_IHAC_LinearParms(m_nElevBands,m_nStorages); m_p_lin_ub = new C_IHAC_LinearParms(m_nElevBands,m_nStorages); m_p_nonlinparms = new C_IHAC_NonLinearParms(m_nElevBands); m_p_nl_lb = new C_IHAC_NonLinearParms(m_nElevBands); m_p_nl_ub = new C_IHAC_NonLinearParms(m_nElevBands); //--------------------------------------------------------- //--------------------------------------------------------- // open second and third user dialog if ( _CreateDialog2() && _CreateDialog3()) { //--------------------------------------------------------- // searching the first and the last record of the time range ihacres.AssignFirstLastRec(*m_p_InputTable, m_first, m_last, m_date1, m_date2, m_dateField); m_nValues = m_last - m_first + 1; //--------------------------------------------------------- //--------------------------------------------------------- _Init_Pointers(m_nValues); //--------------------------------------------------------- //--------------------------------------------------------- // read input table _ReadInputFile(); //--------------------------------------------------------- //--------------------------------------------------------- // PERFORM STREAMFLOW SIMULATION // FOR EACH ELEVATION BAND //--------------------------------------------------------- // Convert Streamflow vector from m3/s*day-1 to mm/day m_p_Q_obs_mmday = model_tools::m3s_to_mmday(m_p_Q_obs_m3s, m_p_Q_obs_mmday, m_nValues, m_Area_tot); //--------------------------------------------------------- m_pTable_parms = SG_Create_Table(); _CreateTableParms(); m_counter = 0; //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // SIMULATION // /////////////////////////////////////////////////////////// // initialize random function srand((unsigned) time(NULL)); // using time.h for (int sim = 0; sim < m_nsim && Set_Progress(sim, m_nsim); sim++) { _Simulate_NonLinearModule(); _Simulate_Streamflow(); _Sum_Streamflow(); m_NSE = m_NSE_lowflow = m_NSE_highflow = m_PBIAS = 0; _CalcEfficiency(); // write in output table if criterion is fulfilled NSE_temp = ihacres._Assign_NSE_temp(m_obj_func, m_NSE, m_NSE_highflow, m_NSE_lowflow); if (NSE_temp > m_NSEmin) { if (NSE_temp > NSE_max) { NSE_max = NSE_temp; nse = convert_sl::Double2String(NSE_max).c_str(); nse_text = "max. NSE "; nse_text += nse; Process_Set_Text(CSG_String(nse_text.c_str())); } _WriteTableParms(); } } //--------------------------------------------------------- m_pTable_parms->Set_Name(SG_T("ihacres_elevbands_cal")); Parameters("TABLEparms")->Set_Value(m_pTable_parms); //m_pTable = SG_Create_Table(); //_CreateTableSim(); //// add tables to SAGA Workspace //m_pTable->Set_Name("ihacres_elevBands_output"); //Parameters("TABLEout")->Set_Value(m_pTable); delete[] m_p_elevbands; // sämtliche Unter-Pointer noch löschen delete[] m_p_pcpField; delete[] m_p_tmpField; delete[] m_p_Q_obs_m3s; delete[] m_p_Q_obs_mmday; delete[] m_p_Q_sim_mmday; delete m_p_linparms; delete m_p_nonlinparms; delete m_p_lin_lb; delete m_p_lin_ub; delete m_p_nl_lb; delete m_p_nl_ub; if (m_bSnowModule) { delete[] m_pSnowparms; delete[] m_pSnowparms_lb; delete[] m_pSnowparms_ub; } delete[] m_vq; delete[] m_vs; return(true); } // end if ( _CreateDialog2() ) // delete[] m_p_elevbands; // delete[] m_p_pcpFields; // delete[] m_p_tmpFields; // delete m_p_linparms; // delete m_p_nonlinparms; return(false); } //--------------------------------------------------------------------- void Cihacres_elev_cal::_Init_ElevBands(int nvals) { // instantiate elevation bands m_p_elevbands = new Cihacres_elev_bands[nvals]; // instantiate field numbers m_p_pcpField = new int[nvals]; m_p_tmpField = new int[nvals]; if (m_bSnowModule) { m_pSnowparms = new CSnowParms[nvals]; m_pSnowparms_lb = new CSnowParms[nvals]; m_pSnowparms_ub = new CSnowParms[nvals]; } m_vq = new double[nvals]; m_vs = new double[nvals]; } //--------------------------------------------------------------------- void Cihacres_elev_cal::_Init_Pointers(int nvals) { m_vec_date.resize(nvals); m_p_Q_obs_m3s = new double[nvals]; m_p_Q_obs_mmday = new double[nvals]; m_p_Q_sim_mmday = new double[nvals]; for (int eb = 0; eb < m_nElevBands; eb++) { m_p_elevbands[eb].m_p_pcp = new double[nvals]; m_p_elevbands[eb].m_p_tmp = new double[nvals]; m_p_elevbands[eb].m_p_ER = new double[nvals]; m_p_elevbands[eb].m_p_streamflow_sim = new double[nvals]; m_p_elevbands[eb].m_p_Tw = new double[nvals]; m_p_elevbands[eb].m_p_WI = new double[nvals]; if (m_bSnowModule) { m_p_elevbands[eb].m_p_SnowStorage = new double[nvals]; m_p_elevbands[eb].m_p_MeltRate = new double[nvals]; } } } //--------------------------------------------------------------------- void Cihacres_elev_cal::_ReadInputFile() { for (int j = 0, k = m_first; j < m_nValues, k < m_last + 1; j++, k++) { m_vec_date[j].append(CSG_String(m_p_InputTable->Get_Record(k)->asString(m_dateField))); m_p_Q_obs_m3s[j] = m_p_InputTable->Get_Record(k)->asDouble(m_streamflowField); for (int eb = 0; eb < m_nElevBands; eb++) { m_p_elevbands[eb].m_p_pcp[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_pcpField[eb]); m_p_elevbands[eb].m_p_tmp[j] = m_p_InputTable->Get_Record(k)->asDouble(m_p_tmpField[eb]); } } } //--------------------------------------------------------------------- void Cihacres_elev_cal::_CalcSnowModule(int eb) { m_p_SnowModule = new CSnowModule(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_pcp, m_nValues, m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_pSnowparms[eb].DD_FAC); m_p_elevbands[eb].m_p_MeltRate = m_p_SnowModule->Get_MeltRate(m_p_elevbands[eb].m_p_MeltRate, m_nValues); m_p_elevbands[eb].m_p_SnowStorage = m_p_SnowModule->Get_SnowStorage(m_p_elevbands[eb].m_p_SnowStorage, m_nValues); delete m_p_SnowModule; } //--------------------------------------------------------------------- void Cihacres_elev_cal::_Simulate_NonLinearModule() { double eR_init = 0.0; for (int eb = 0; eb < m_nElevBands; eb++) { //------------------------------------------------------------- // Assign random values //------------------------------------------------------------- if (m_bSnowModule) { m_pSnowparms[eb].T_Rain = model_tools::Random_double(m_pSnowparms_lb[eb].T_Rain,m_pSnowparms_ub[eb].T_Rain); m_pSnowparms[eb].T_Melt = model_tools::Random_double(m_pSnowparms_lb[eb].T_Melt,m_pSnowparms_ub[eb].T_Melt); m_pSnowparms[eb].DD_FAC = model_tools::Random_double(m_pSnowparms_lb[eb].DD_FAC,m_pSnowparms_ub[eb].DD_FAC); m_p_SnowModule = new CSnowModule(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_pcp, m_nValues, m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_pSnowparms[eb].DD_FAC); m_p_elevbands[eb].m_p_MeltRate = m_p_SnowModule->Get_MeltRate(m_p_elevbands[eb].m_p_MeltRate, m_nValues); delete m_p_SnowModule; } m_p_nonlinparms->mp_tw[eb] = model_tools::Random_double(m_p_nl_lb->mp_tw[eb], m_p_nl_ub->mp_tw[eb]); m_p_nonlinparms->mp_f[eb] = model_tools::Random_double(m_p_nl_lb->mp_f[eb], m_p_nl_ub->mp_f[eb]); m_p_nonlinparms->mp_c[eb] = model_tools::Random_double(m_p_nl_lb->mp_c[eb], m_p_nl_ub->mp_c[eb]); if (m_IHAC_version == 1) { // Croke etal. (2005) m_p_nonlinparms->mp_l[eb]= model_tools::Random_double(m_p_nl_ub->mp_l[eb],m_p_nl_ub->mp_l[eb]); m_p_nonlinparms->mp_p[eb]= model_tools::Random_double(m_p_nl_ub->mp_p[eb],m_p_nl_ub->mp_p[eb]); } //---------------------------------------------------------- // calculate excess rainfall time series //---------------------------------------------------------- switch(m_IHAC_version) { case 0: // Jakeman & Hornberger (1993) // The parameter index (fourth parameter) is zero here, because // the parameter settings of the non-linear module are in all elevationbands equal. // If they should be different the index parameter can be used to identify the // corresponding elevation band. ihacres.CalcWetnessTimeConst(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_Tw, m_p_nonlinparms, eb, m_nValues); // 0 = index (only one instance of m_p_nonlinparms) if (m_bSnowModule) { ihacres.CalcWetnessIndex(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, 0.5, m_p_nonlinparms->mp_c[eb], m_bSnowModule, m_pSnowparms[eb].T_Rain, m_nValues); ihacres.CalcExcessRain(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_bSnowModule, m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_p_elevbands[eb].m_p_MeltRate); } else { ihacres.CalcWetnessIndex(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, 0.5, m_p_nonlinparms->mp_c[eb], m_bSnowModule, 0, m_nValues); ihacres.CalcExcessRain(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_bSnowModule, 0,0,0); } break; case 1: // Croke et al. (2005) ihacres.CalcWetnessTimeConst_Redesign(m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_Tw, m_p_nonlinparms, eb, m_nValues); // 0 = index (only one instance of m_p_nonlinparms) if (m_bSnowModule) { ihacres.CalcWetnessIndex_Redesign(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_WI, 0.5, m_bSnowModule, m_pSnowparms[eb].T_Rain, m_nValues); ihacres.CalcExcessRain_Redesign(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_p_nonlinparms->mp_c[eb], m_p_nonlinparms->mp_l[eb], m_p_nonlinparms->mp_p[eb], m_bSnowModule, m_pSnowparms[eb].T_Rain, m_pSnowparms[eb].T_Melt, m_p_elevbands[eb].m_p_MeltRate); } else { ihacres.CalcWetnessIndex_Redesign(m_p_elevbands[eb].m_p_Tw, m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_WI, 0.5, m_bSnowModule, 0, m_nValues); ihacres.CalcExcessRain_Redesign(m_p_elevbands[eb].m_p_pcp, m_p_elevbands[eb].m_p_tmp, m_p_elevbands[eb].m_p_WI, m_p_elevbands[eb].m_p_ER, eR_init, m_p_elevbands[eb].m_sum_eRainGTpcp, m_nValues, m_p_nonlinparms->mp_c[eb], m_p_nonlinparms->mp_l[eb], m_p_nonlinparms->mp_p[eb], m_bSnowModule, 0,0,0); } break; } // end switch(m_IHAC_vers) } } //--------------------------------------------------------------------- void Cihacres_elev_cal::_Simulate_Streamflow() { //------------------------------------------------------------- // Assign random values //------------------------------------------------------------- for (int eb = 0; eb < m_nElevBands; eb++) { switch(m_StorConf) { case 0: // single storage m_p_linparms->a[eb] = model_tools::Random_double(m_p_lin_lb->a[eb],m_p_lin_ub->a[eb]); m_p_linparms->b[eb] = model_tools::Random_double(m_p_lin_lb->b[eb],m_p_lin_ub->b[eb]); break; case 1: // two storages in parallel do { m_p_linparms->aq[eb] = model_tools::Random_double(m_p_lin_lb->aq[eb], m_p_lin_ub->aq[eb]); m_p_linparms->as[eb] = model_tools::Random_double(m_p_lin_lb->as[eb], m_p_lin_ub->as[eb]); m_p_linparms->bq[eb] = model_tools::Random_double(m_p_lin_lb->bq[eb], m_p_lin_ub->bq[eb]); // Calculate parameter m_vq to check parms aq and bq // Equation after Jakeman & Hornberger (1993) m_vq[eb] = m_p_linparms->bq[eb] / ( 1 + m_p_linparms->aq[eb] ); } while (m_vq[eb] < 0.0 || m_vq[eb] > 1.0); m_p_linparms->bs[eb] = ihacres.Calc_Parm_BS(m_p_linparms->aq[eb], m_p_linparms->as[eb], m_p_linparms->bq[eb]); break; } //---------------------------------------------------------- // calculate streamflow //---------------------------------------------------------- switch(m_StorConf) { case 0: // single storage ihacres.SimStreamflowSingle(m_p_elevbands[eb].m_p_ER, m_p_Q_obs_mmday[0], m_p_elevbands[eb].m_p_streamflow_sim, m_delay, m_p_linparms->a[eb], m_p_linparms->b[eb], m_nValues); break; case 1: // two storages in parallel ihacres.SimStreamflow2Parallel(m_p_elevbands[eb].m_p_ER, m_p_elevbands[eb].m_p_streamflow_sim, m_p_Q_obs_mmday[0], m_p_linparms, eb, m_vq[eb], m_vs[eb], m_nValues, m_delay); break; case 2: // two storages in series break; } // end switch(m_StorConf) }// end for (int eb... } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Summarize streamflow from elevation bands //--------------------------------------------------------------------- void Cihacres_elev_cal::_Sum_Streamflow() { //std::ofstream f("_cal_elev.txt"); double sum = 0.0; for (int n = 0; n < m_nValues; n++) { for (int eb = 0; eb < m_nElevBands; eb++) { sum += m_p_elevbands[eb].m_p_streamflow_sim[n] * m_p_elevbands[eb].m_area / m_Area_tot; //f << m_p_elevbands[eb].m_p_streamflow_sim[n] << ", "); } //f << std::endl; m_p_Q_sim_mmday[n] = sum; sum = 0.0; } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Nash-Sutcliffe efficiency //--------------------------------------------------------------------- void Cihacres_elev_cal::_CalcEfficiency() { m_NSE = model_tools::CalcEfficiency(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues); m_NSE_highflow = model_tools::Calc_NSE_HighFlow(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues); m_NSE_lowflow = model_tools::Calc_NSE_LowFlow(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues); m_PBIAS = model_tools::Calc_PBIAS(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues); } //--------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////// // // CREATE TABLES // ///////////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Create output table //--------------------------------------------------------------------- void Cihacres_elev_cal::_CreateTableParms() { char c[12]; // creating the column titles m_pTable_parms->Add_Field("NSE", SG_DATATYPE_Double); m_pTable_parms->Add_Field("NSE_high", SG_DATATYPE_Double); m_pTable_parms->Add_Field("NSE_low", SG_DATATYPE_Double); m_pTable_parms->Add_Field("PBIAS", SG_DATATYPE_Double); //m_pTable_parms->Add_Field("eR_ovest", SG_DATATYPE_Double); for (int i = 0; i < m_nElevBands; i++) { sprintf(c,"%s_%d","vq",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","vs",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","T(q)",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","T(s)",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","Tw",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","f",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","c",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); if ( m_IHAC_version == 1 ) // Croke etal. (2005) { sprintf(c,"%s_%d","l",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","p",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); } if (m_bSnowModule) { sprintf(c,"%s_%d","T_Rain",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","T_Melt",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","DD_FAC",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); } switch(m_StorConf) { case 0: // single sprintf(c,"%s_%d","a",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","b",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); break; case 1: // two storages in parallel sprintf(c,"%s_%d","aq",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","as",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","bq",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); sprintf(c,"%s_%d","bs",i+1); m_pTable_parms->Add_Field(c, SG_DATATYPE_Double); break; } } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Create output table //--------------------------------------------------------------------- void Cihacres_elev_cal::_WriteTableParms() { int field = 0; CSG_Table_Record *pRecord; // add a new record to the table m_pTable_parms->Add_Record(); pRecord = m_pTable_parms->Get_Record(m_counter); // writing the data to the current row pRecord->Set_Value(field,m_NSE); field++; pRecord->Set_Value(field,m_NSE_highflow); field++; pRecord->Set_Value(field,m_NSE_lowflow); field++; pRecord->Set_Value(field,m_PBIAS); field++; //pRecord->Set_Value(field,m_sum_eRainGTpcp); field++; for (int eb = 0; eb < m_nElevBands; eb++) { pRecord->Set_Value(field,m_vq[eb]); field++; pRecord->Set_Value(field,m_vs[eb]); field++; pRecord->Set_Value(field,ihacres.Calc_TimeOfDecay(m_p_linparms->aq[eb])); field++; pRecord->Set_Value(field,ihacres.Calc_TimeOfDecay(m_p_linparms->as[eb])); field++; pRecord->Set_Value(field,m_p_nonlinparms->mp_tw[eb]); field++; pRecord->Set_Value(field,m_p_nonlinparms->mp_f[eb]); field++; pRecord->Set_Value(field,m_p_nonlinparms->mp_c[eb]); field++; if ( m_IHAC_version == 1 ) { pRecord->Set_Value(field,m_p_nonlinparms->mp_l[eb]); field++; pRecord->Set_Value(field,m_p_nonlinparms->mp_p[eb]); field++; } if ( m_bSnowModule ) { pRecord->Set_Value(field,m_pSnowparms[eb].T_Rain); field++; pRecord->Set_Value(field,m_pSnowparms[eb].T_Melt); field++; pRecord->Set_Value(field,m_pSnowparms[eb].DD_FAC); field++; } switch ( m_StorConf ) { case 0: // single storage pRecord->Set_Value(field,m_p_linparms->a[eb]); field++; pRecord->Set_Value(field,m_p_linparms->b[eb]); field++; break; case 1: pRecord->Set_Value(field,m_p_linparms->aq[eb]); field++; pRecord->Set_Value(field,m_p_linparms->as[eb]); field++; pRecord->Set_Value(field,m_p_linparms->bq[eb]); field++; pRecord->Set_Value(field,m_p_linparms->bs[eb]); field++; break; } } m_counter++; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- void Cihacres_elev_cal::_CreateTableSim() { int i = 0; // used in function Get_Record(i) CSG_Table_Record *pRecord; CSG_String tmpName; double sim_eb, sim; // creating the column titles m_pTable->Add_Field("Date", SG_DATATYPE_String); m_pTable->Add_Field("Flow_OBS", SG_DATATYPE_Double); for (int eb = 0; eb < m_nElevBands; eb++) { tmpName = SG_T("ELEVB_"); tmpName += convert_sl::Int2String(eb+1).c_str(); m_pTable->Add_Field(tmpName.c_str(), SG_DATATYPE_Double); } m_pTable->Add_Field("Flow_SIM", SG_DATATYPE_Double); for (int j = 0; j < m_nValues; j++) { m_pTable->Add_Record(); pRecord = m_pTable->Get_Record(i); // writing the data into the rows pRecord->Set_Value(0,CSG_String(m_vec_date[j].c_str())); pRecord->Set_Value(1,m_p_Q_obs_m3s[j]); sim_eb = 0.0; sim = 0.0; for (int eb = 0; eb < m_nElevBands; eb++) { sim_eb = model_tools::mmday_to_m3s(m_p_elevbands[eb].m_p_streamflow_sim[j],m_p_elevbands[eb].m_area); //pRecord->Set_Value(3+eb,model_tools::mmday_to_m3s(m_p_elevbands[eb].m_p_streamflow_sim[j],m_p_elevbands[eb].m_area)); pRecord->Set_Value(2+eb, sim_eb); sim += sim_eb; } pRecord->Set_Value(2+m_nElevBands,sim); i++; } } //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // DIALOGS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // DIALOG 1 //--------------------------------------------------------------------- void Cihacres_elev_cal::_CreateDialog1() { CSG_Parameter *pNode; CSG_String s; pNode = Parameters.Add_Choice( NULL , "NELEVBANDS" , SG_T("Number of elevation bands"), _TL(""), SG_T("2|3|4|5|6|7|8|9|10") ); pNode = Parameters.Add_Value( NULL, "NSIM", _TL("Number of Simulations"), _TL("Number of Simulations for Calibration"), PARAMETER_TYPE_Int, 1000, 1, true, 10000000, true ); pNode = Parameters.Add_Value( pNode, "AREA_tot", _TL("Total Catchment Area [km2]"), _TL(""), PARAMETER_TYPE_Double ); s.Printf(SG_T("Node1"), 1); pNode = Parameters.Add_Node(NULL,s,SG_T("IHACRES Version"),_TL("")); Parameters.Add_Choice( pNode , "IHACVERS" , SG_T("IHACRES Version"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Jakeman & Hornberger (1993)"), // 0 _TL("Croke et al. (2005) !!! not yet implemented !!!") // 1 ) ); s.Printf(SG_T("Node2"), 2); pNode = Parameters.Add_Node(NULL,s,SG_T("Storage Configuration"),_TL("")); Parameters.Add_Choice( pNode , "STORAGE" , SG_T("Storage"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Single Storage"), // 0 _TL("Two Parallel Storages"), // 1 _TL("Two Storages in Series !!! not yet implemented !!!") // 2 ) ); Parameters.Add_Value( pNode, "SNOW_MODULE", _TL("Using the snow-melt module?"), _TL("If checked, snow-melt module is used."), PARAMETER_TYPE_Bool, false ); s.Printf(SG_T("Node6"), 6); pNode = Parameters.Add_Node(NULL,s,SG_T("Nash-Sutcliffe Efficiency"),_TL("")); Parameters.Add_Choice( pNode, "OBJ_FUNC" , SG_T("Objective Function"), _TL(""), SG_T("NSE|NSE high flow|NSE low flow") ); Parameters.Add_Value( pNode, "NSEMIN", SG_T("Minimum Nash-Sutcliffe Efficiency"), SG_T("Minimum Nash-Sutcliffe Efficiency required to print simulation to calibration table"), PARAMETER_TYPE_Double, 0.7, 0.1, true, 1.0, true ); } //--------------------------------------------------------------------- // DIALOG 2 //--------------------------------------------------------------------- bool Cihacres_elev_cal::_CreateDialog2() { int i; //std::ofstream f("_out_elev.txt"); CSG_Parameters P; // used to add Parameters in the second dialog CSG_Parameter *pNode, *pNode1; CSG_String s; CSG_String tmpNode, tmpName; P.Set_Name(_TL("IHACRES Elevation Bands (Dialog 2)")); // Input file ---------------------------------------------- pNode = P.Add_Table( NULL , "TABLE" , _TL("IHACRES Input Table"), _TL(""), PARAMETER_INPUT ); P.Add_Table_Field( pNode , "DATE_Field" , _TL("Date Column"), SG_T("Select the column containing the Date") ); P.Add_Table_Field( pNode , "DISCHARGE_Field" , _TL("Streamflow (obs.) Column"), SG_T("Select the column containing the observed streamflow time series") ); for (i = 0; i < m_nElevBands; i++) { tmpNode = convert_sl::Int2String(i+1).c_str(); //s.Printf(tmpNode.c_str(), i); //pNode1 = P.Add_Node(NULL,s,SG_T("Elevation Band Input",_TL("")); tmpName = SG_T("PCP Column: Elevation Band: "); tmpName+=tmpNode; P.Add_Table_Field( pNode , tmpName.c_str(), tmpName.c_str(), SG_T("Select Precipitation Column") ); tmpName = SG_T("TMP Column: Elevation Band: "); tmpName+=tmpNode; P.Add_Table_Field( pNode , tmpName.c_str() , tmpName.c_str(), SG_T("Select Temperature Column") ); } // Input file ---------------------------------------------- for (i = 0; i < m_nElevBands; i++) { tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+100).c_str(); tmpName = SG_T("Elevation Band "); tmpName+=convert_sl::Int2String(i+1).c_str(); s.Printf(tmpNode.c_str(), i+100); pNode = P.Add_Node(NULL,s,tmpName.c_str(),_TL("")); tmpName = SG_T("Area [km2] Elev("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode, tmpName, _TL("Area [km2]"), _TL(""), PARAMETER_TYPE_Double ); tmpName = SG_T("Mean Elevation [m.a.s.l] Elev("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode, tmpName, _TL("Mean Elevation [m.a.s.l]"), _TL(""), PARAMETER_TYPE_Double ); // Parameters of non-linear module ------------------------- tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+150).c_str(); s.Printf(tmpNode.c_str(), i+150); pNode1 = P.Add_Node(pNode,s,SG_T("Non-Linear Module"),_TL("")); tmpName = SG_T("TwFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("(Tw) wetness decline time constant [lower bound]"), _TW("Tw is approximately the time constant, or inversely," "the rate at which the catchment wetness declines in the absence of rainfall"), PARAMETER_TYPE_Double, 1.0, 0.01, true, 150.0, true ); tmpName = SG_T("TwFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("(Tw) wetness decline time constant [upper bound]"), _TW("Tw is approximately the time constant, or inversely," "the rate at which the catchment wetness declines in the absence of rainfall"), PARAMETER_TYPE_Double, 1.0, 0.01, true, 150.0, true ); tmpName = SG_T("TFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, SG_T("(f) Temperature Modulation Factor [lower bound]"), _TL("Temperature Modulation Factor f"), PARAMETER_TYPE_Double, 0.05, 0.0001, true, 5.0, true ); tmpName = SG_T("TFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, SG_T("(f) Temperature Modulation Factor [upper bound]"), _TL("Temperature Modulation Factor f"), PARAMETER_TYPE_Double, 0.5, 0.0001, true, 5.0, true ); tmpName = SG_T("CFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1,tmpName, _TL("(c) Parameter [lower bound]"), _TL("Parameter (c) to fit streamflow volume"), PARAMETER_TYPE_Double, 0.001, 0.0, true, 1.0, true ); tmpName = SG_T("CFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1,tmpName, _TL("(c) Parameter [upper bound]"), _TL("Parameter (c) to fit streamflow volume"), PARAMETER_TYPE_Double, 0.01, 0.0, true, 1.0, true ); switch(m_IHAC_version) { case 0: // Jakeman & Hornberger (1993) break; case 1: // Croke et al. (2005) tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+200).c_str(); s.Printf(tmpNode.c_str(), i+200); pNode1 = P.Add_Node(pNode,s,SG_T("Soil Moisture Power Eq."),_TL("")); tmpName = SG_T("LFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Parameter (l) [lower bound]"), _TL("Soil moisture index threshold"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); tmpName = SG_T("LFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Parameter (l) [upper bound]"), _TL("Soil moisture index threshold"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); tmpName = SG_T("PFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Parameter (p) [lower bound]"), _TL("non-linear response term"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); tmpName = SG_T("PFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("Parameter (p) [upper bound]"), _TL("non-linear response term"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); break; } // Parameters of non-linear module ------------------------- // Parameters of linear module ----------------------------- switch(m_StorConf) { case 0: // single storage tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); s.Printf(tmpNode.c_str(), i+250); pNode1 = P.Add_Node(pNode,s,SG_T("Linear Module"),_TL("")); tmpName = SG_T("AFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("(a) [lower bound]"), _TL(""), PARAMETER_TYPE_Double, -0.8, -0.99, true, -0.01, true ); tmpName = SG_T("AFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("(a) [upper bound]"), _TL(""), PARAMETER_TYPE_Double, -0.8, -0.99, true, -0.01, true ); tmpName = SG_T("BFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("(b) [lower bound]"), _TL(""), PARAMETER_TYPE_Double, 0.2, 0.001, true, 1.0, true ); tmpName = SG_T("BFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("(b) [upper bound]"), _TL(""), PARAMETER_TYPE_Double, 0.2, 0.001, true, 1.0, true ); break; case 1: // two parallel storages tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); s.Printf(tmpNode.c_str(), i+250); pNode1 = P.Add_Node(pNode,s,SG_T("Linear Module"),_TL("")); // Parameter a tmpName = SG_T("AQ_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("a(q) [lower bound]"), _TL(""), PARAMETER_TYPE_Double, -0.7, -0.99, true, -0.01, true ); tmpName = SG_T("AQ_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("a(q) [upper bound]"), _TL(""), PARAMETER_TYPE_Double, -0.7, -0.99, true, -0.01, true ); tmpName = SG_T("AS_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("a(s) [lower bound]"), _TL(""), PARAMETER_TYPE_Double, -0.9, -0.99, true, -0.01, true ); tmpName = SG_T("AS_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("a(s) [upper bound]"), _TL(""), PARAMETER_TYPE_Double, -0.9, -0.99, true, -0.01, true ); // Parameter b tmpName = SG_T("BQ_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("b(q) [lower bound]"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); tmpName = SG_T("BQ_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, _TL("b(q) [upper bound]"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); break; case 2: // two storages in series break; } // end switch (storconf) // Parameters of linear module ----------------------------- tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+300).c_str(); s.Printf(tmpNode.c_str(), i+300); pNode1 = P.Add_Node(pNode,s,SG_T("Time Delay after Start of Rainfall (INTEGER)"),_TL("")); tmpName = SG_T("DELAY("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, SG_T("Time Delay (Rain-Runoff)"), SG_T("The delay after the start of rainfall, before the discharge starts to rise."), PARAMETER_TYPE_Int, 0, 1, true, 100, true ); // snow module parameters ---------------------------------- if (m_bSnowModule) { tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+350).c_str(); s.Printf(tmpNode.c_str(), i+350); pNode1 = P.Add_Node(pNode,s,SG_T("Snow Module Parameters"),_TL("")); tmpName = SG_T("T_RAIN_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, SG_T("Temperature Threshold for Rainfall [lower bound]"), SG_T("Below this threshold precipitation will fall as snow"), PARAMETER_TYPE_Double, -1.0, -10.0, true, 10.0, true ); tmpName = SG_T("T_RAIN_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, SG_T("Temperature Threshold for Rainfall [upper bound]"), SG_T("Below this threshold precipitation will fall as snow"), PARAMETER_TYPE_Double, -1.0, -10.0, true, 10.0, true ); tmpName = SG_T("T_MELT_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, SG_T("Temperature Threshold for Melting [lower bound]"), SG_T("Above this threshold snow will start to melt"), PARAMETER_TYPE_Double, 1.0, -5.0, true, 10.0, true ); tmpName = SG_T("T_MELT_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, SG_T("Temperature Threshold for Melting [upper bound]"), SG_T("Above this threshold snow will start to melt"), PARAMETER_TYPE_Double, 1.0, -5.0, true, 10.0, true ); tmpName = SG_T("DD_FAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, SG_T("Day-Degree Factor [lower bound]"), SG_T("Day-Degree Factor depends on catchment characteristics"), PARAMETER_TYPE_Double, 0.7, 0.7, true, 9.2, true ); tmpName = SG_T("DD_FAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); P.Add_Value( pNode1, tmpName, SG_T("Day-Degree Factor [upper bound]"), SG_T("Day-Degree Factor depends on catchment characteristics"), PARAMETER_TYPE_Double, 0.7, 0.7, true, 9.2, true ); } // snow module parameters ---------------------------------- } if( SG_UI_Dlg_Parameters(&P, _TL("IHACRES Distributed Input Dialog 2")) ) { // input table m_p_InputTable = P("TABLE") ->asTable(); // field numbers m_dateField = P("DATE_Field") ->asInt(); m_streamflowField = P("DISCHARGE_Field") ->asInt(); for (int i = 0; i < m_nElevBands; i++) { tmpNode = convert_sl::Int2String(i+1).c_str(); // get precipitation column of Elevation Band[i] tmpName = SG_T("PCP Column: Elevation Band: "); tmpName+=tmpNode; m_p_pcpField[i] = P(tmpName) ->asInt(); // get temperature column of Elevation Band[i] tmpName = SG_T("TMP Column: Elevation Band: "); tmpName+=tmpNode; m_p_tmpField[i] = P(tmpName) ->asInt(); tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+100).c_str(); // get area[km2] of Elevation Band[i] tmpName = SG_T("Area [km2] Elev("); tmpName += tmpNode; tmpName += _TL(")"); m_p_elevbands[i].m_area = P(tmpName) ->asDouble(); // get mean elevation of Elevation Band[i] tmpName = SG_T("Mean Elevation [m.a.s.l] Elev("); tmpName += tmpNode; tmpName += _TL(")"); m_p_elevbands[i].m_mean_elev =P(tmpName) ->asDouble(); // non-linear module parameters tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+150).c_str(); // get Tw tmpName = SG_T("TwFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nl_lb->mp_tw[i] = P(tmpName) ->asDouble(); tmpName = SG_T("TwFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nl_ub->mp_tw[i] = P(tmpName) ->asDouble(); // get f tmpName = SG_T("TFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nl_lb->mp_f[i] = P(tmpName) ->asDouble(); tmpName = SG_T("TFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nl_ub->mp_f[i] = P(tmpName) ->asDouble(); // get c tmpName = SG_T("CFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nl_lb->mp_c[i] = P(tmpName) ->asDouble(); tmpName = SG_T("CFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nl_ub->mp_c[i] = P(tmpName) ->asDouble(); switch(m_IHAC_version) { case 0: // Jakeman & Hornberger (1993) break; case 1: // Croke et al. (2005) tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+200).c_str(); // get l tmpName = SG_T("LFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nl_lb->mp_l[i]= P(tmpName) ->asDouble(); tmpName = SG_T("LFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nl_ub->mp_l[i]= P(tmpName) ->asDouble(); // get p tmpName = SG_T("PFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nl_lb->mp_p[i]= P(tmpName) ->asDouble(); tmpName = SG_T("PFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_p_nl_ub->mp_p[i]= P(tmpName) ->asDouble(); } // linear module parameters switch(m_nStorages) { case 1: // single storage tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); // get a tmpName = SG_T("AFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_p_lin_lb->a[i] = P(tmpName) ->asDouble(); tmpName = SG_T("AFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_p_lin_ub->a[i] = P(tmpName) ->asDouble(); // get b tmpName = SG_T("BFAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_p_lin_lb->b[i] = P(tmpName) ->asDouble(); tmpName = SG_T("BFAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_p_lin_ub->b[i] = P(tmpName) ->asDouble(); break; case 2: // two storages tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+250).c_str(); // get aq tmpName = SG_T("AQ_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_p_lin_lb->aq[i] = P(tmpName) ->asDouble(); tmpName = SG_T("AQ_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_p_lin_ub->aq[i] = P(tmpName) ->asDouble(); // get bq tmpName = SG_T("BQ_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_p_lin_lb->bq[i] = P(tmpName) ->asDouble(); tmpName = SG_T("BQ_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_p_lin_ub->bq[i] = P(tmpName) ->asDouble(); // get as tmpName = SG_T("AS_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_p_lin_lb->as[i] = P(tmpName) ->asDouble(); tmpName = SG_T("AS_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_p_lin_ub->as[i] = P(tmpName) ->asDouble(); break; } // get delay tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+300).c_str(); tmpName = SG_T("DELAY("); tmpName += tmpNode; tmpName += _TL(")"); m_delay = P(tmpName) ->asInt(); if (m_bSnowModule) { tmpNode = SG_T("Node"); tmpNode+=convert_sl::Int2String(i+350).c_str(); tmpName = SG_T("T_RAIN_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms_lb[i].T_Rain = P(tmpName) ->asDouble(); tmpName = SG_T("T_RAIN_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms_ub[i].T_Rain = P(tmpName) ->asDouble(); tmpName = SG_T("T_MELT_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms_lb[i].T_Melt = P(tmpName) ->asDouble(); tmpName = SG_T("T_MELT_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms_ub[i].T_Melt = P(tmpName) ->asDouble(); tmpName = SG_T("DD_FAC_lb("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms_lb[i].DD_FAC = P(tmpName) ->asDouble(); tmpName = SG_T("DD_FAC_ub("); tmpName += tmpNode; tmpName += _TL(")"); m_pSnowparms_ub[i].DD_FAC = P(tmpName) ->asDouble(); } } // end for (int i = 0; i < m_nSubbasins; i++) return(true); } return(false); } //--------------------------------------------------------------------- // DIALOG 3 //--------------------------------------------------------------------- bool Cihacres_elev_cal::_CreateDialog3() { CSG_String s; CSG_Parameters P; // used to add Parameters in the second dialog CSG_Parameter *pNode; // Dialog design P.Set_Name(_TL("Choose Time Range")); s.Printf(SG_T("Node1"), 1); pNode = P.Add_Node(NULL,s,SG_T("Time Range"),_TL("")); s.Printf(SG_T("FDAY") , 1-1); P.Add_String(pNode,s,_TL("First Day"),_TL(""), m_p_InputTable->Get_Record(0)->asString(m_dateField)); s.Printf(SG_T("LDAY") , 1-2); P.Add_String(pNode,s,_TL("Last Day"),_TL(""), m_p_InputTable->Get_Record(m_p_InputTable->Get_Record_Count()-1)->asString(m_dateField)); if( SG_UI_Dlg_Parameters(&P, _TL("Choose Time Range")) ) { /////////////////////////////////////////////////////////////// // // ASSIGN DATA FROM SECOND DIALOG // /////////////////////////////////////////////////////////////// m_date1 = P(CSG_String::Format(SG_T("FDAY"),m_dateField).c_str())->asString(); m_date2 = P(CSG_String::Format(SG_T("LDAY"),m_streamflowField).c_str())->asString(); return(true); } return(false); } saga-2.3.1/src/modules/simulation/sim_ihacres/Makefile.am0000744000175000017500000000157012737416207024546 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_ihacres.la libsim_ihacres_la_SOURCES =\ convert_sl.cpp\ ihacres_basin.cpp\ ihacres_cal2.cpp\ ihacres_elev.cpp\ ihacres_elev_bands.cpp\ ihacres_elev_cal.cpp\ ihacres_eq.cpp\ ihacres_v1.cpp\ MLB_Interface.cpp\ model_tools.cpp\ snow_module.cpp\ convert_sl.h\ ihacres_basin.h\ ihacres_cal2.h\ ihacres_elev.h\ ihacres_elev_bands.h\ ihacres_elev_cal.h\ ihacres_eq.h\ ihacres_v1.h\ MLB_Interface.h\ model_tools.h\ snow_module.h libsim_ihacres_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_cal2.cpp0000744000175000017500000010515612737416207025542 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_cal2.cpp 1261 2011-12-16 15:12:15Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ihacres_cal2 // // // //-------------------------------------------------------// // // // ihacres_cal.cpp // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // // // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // // // 2008-01-15 // /////////////////////////////////////////////////////////// // //-------------------------------------------------------// // References: // Jakeman, A.J. / Hornberger, G.M (1993). // How Much Complexity Is Warranted in a // Rainfall-Runoff Model? // Water Resources Research, (29), NO. 8 (2637-2649) // Kokkonen, T. S. et al. (2003). // Predicting daily flows in ungauged catchments: // model regionalization from catchment descriptors // at the Coweeta Hydrologic Laboratory, North Carolina // Hydrological Processes (17), 2219-2238 // Croke, B. F. W., W. S. Merritt, et al. (2004). // A dynamic model for predicting hydrologic response // to land cover changes in gauged and // ungauged catchments. // Journal Of Hydrology 291(1-2): 115-131. //-------------------------------------------------------// //--------------------------------------------------------- // ToDo //--------------------------------------------------------- // - beste Simulation automatisch rausschreiben //--------------------------------------------------------- #include // used for textfile output (test only) #include // used for textfile output (test only) #include // random numbers #include // random numbers #include "ihacres_cal2.h" // #include "model_tools.h" // already in ihacres_eq.h #include "convert_sl.h" //--------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // Constructor // /////////////////////////////////////////////////////////////////////// Cihacres_cal2::Cihacres_cal2(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("IHACRES Calibration (2)")); Set_Author(SG_T("copyrights (c) 2008 Stefan Liersch")); Set_Description(_TW("Calibration Tool for the Model IHACRES \n \n \n" "Reference: \n \n" "Jakeman, A.J. / Hornberger, G.M. (1993). \n" "How Much Complexity Is Warranted in a Rainfall-Runoff Model? \n" "Water Resources Research, (29), NO. 8 (2637-2649) \n \n" "Croke, B. F. W., W. S. Merritt, et al. (2004).\n" "A dynamic model for predicting hydrologic response " "to land cover changes in gauged and " "ungauged catchments. \n" "Journal Of Hydrology 291(1-2): 115-131." )); //----------------------------------------------------- // Create First Module Dialog _CreateDialog1(); //----------------------------------------------------- } /////////////////////////////////////////////////////////////////////// // // Destructor // /////////////////////////////////////////////////////////////////////// Cihacres_cal2::~Cihacres_cal2(void) { //if (m_bSnowModule) //{ // delete m_pSnowModule; // delete[] m_pMeltRate; //} } /////////////////////////////////////////////////////////////////////// // // On_Execute() // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------- // This function is executed when the user is pressing the OK button // in the first module dialog bool Cihacres_cal2::On_Execute(void) { int first, last; double NSE_temp = 0.0; double NSE_max = -9999.9; string nse, nse_text; //--------------------------------------------------------- // Assign parameters from First Module Dialog m_pTable = Parameters("TABLE") ->asTable(); // Field numbers m_dateField = Parameters("DATE_Field") ->asInt(); m_dischargeField= Parameters("DISCHARGE_Field") ->asInt(); m_pcpField = Parameters("PCP_Field") ->asInt(); m_tmpField = Parameters("TMP_Field") ->asInt(); m_inflowField = Parameters("INFLOW_Field") ->asInt(); m_bUpstream = Parameters("bUPSTREAM") ->asBool(); m_bTMP = Parameters("USE_TMP") ->asBool(); m_nsim = Parameters("NSIM") ->asInt(); m_area = Parameters("AREA") ->asDouble(); //m_dev_eRainDis = Parameters("DEV_ERAINDIS") ->asDouble(); //m_dev_eRainPCP = Parameters("DEV_ERAINPCP") ->asDouble(); m_storconf = Parameters("STORAGE") ->asInt(); m_IHAC_version = Parameters("IHACVERS") ->asInt(); m_bSnowModule = Parameters("SNOW_MODULE") ->asBool(); first = last = 0; //--------------------------------------------------------- //--------------------------------------------------------- // After pressing OK in the first Dialog Dialog2 appears. // In the sec if ( _CreateDialog2() ) //--------------------------------------------------------- { //--------------------------------------------------------- // Searching the first and the last record of the time range ihacres.AssignFirstLastRec(*m_pTable, first, last, m_date1, m_date2, m_dateField); //--------------------------------------------------------- //--------------------------------------------------------- // Initialize arrays m_nValues = last - first + 1; _InitPointers(); //--------------------------------------------------------- //--------------------------------------------------------- // Assign selected time range to vector m_vec_date, // discharge[], pcp[], and tmp[] _ReadInputTable(first, last); //--------------------------------------------------------- //--------------------------------------------------------- // Convert streamflow from m3/s to mm/day if (m_bUpstream) { // if the subbasin is upstream (without external inflow) then everything // is as it should be. m_p_Q_obs_mmday = model_tools::m3s_to_mmday(m_p_Q_obs_m3s,m_p_Q_obs_mmday,m_nValues,m_area); } else { // if the subbasin is downstream of other subbasins, thus there // are external inflows the array m_p_Q_obs_mmday must be calculated as following: // m_p_Q_obs_mmday = // (observed streamflow at the outlet of the subbasin) - (observed inflow from the upstream subbasin(s)) _Calc_ObsMinInflow(); m_p_Q_obs_mmday = model_tools::m3s_to_mmday(m_p_Q_dif_m3s, m_p_Q_obs_mmday, m_nValues, m_area); } // calculate sum of observed discharge in [mm] m_sum_obsDisMM = ihacres.SumVector(m_p_Q_obs_mmday, m_nValues); //--------------------------------------------------------- //--------------------------------------------------------- m_pTable = SG_Create_Table(); _CreateOutputTable(); m_counter = 0; //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // SIMULATION // /////////////////////////////////////////////////////////// // initialize random function srand((unsigned) time(NULL)); // using time.h for (int sim = 0; sim < m_nsim && Set_Progress(sim, m_nsim); sim++) { _CalcNonLinearModule(); _CalcLinearModule(); _CalcEfficiency(); // write in output table if criterion is fulfilled NSE_temp = ihacres._Assign_NSE_temp(m_obj_func, m_NSE, m_NSE_highflow, m_NSE_lowflow); if (NSE_temp > m_NSEmin) { if (NSE_temp > NSE_max) { NSE_max = NSE_temp; nse = convert_sl::Double2String(NSE_max).c_str(); nse_text = "max. NSE "; nse_text += nse; Process_Set_Text(CSG_String(nse_text.c_str())); } _WriteOutputTable(); } } //--------------------------------------------------------- m_pTable->Set_Name(SG_T("IHACRES_cal2")); Parameters("TABLEout")->Set_Value(m_pTable); //--------------------------------------------------------- _DeletePointers(); //--------------------------------------------------------- return(true); } // end if (_CreateDialog2()) return(false); } /////////////////////////////////////////////////////////////////////// // // PRIVATE FUNCTIONS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // InitPointers() //--------------------------------------------------------------------- void Cihacres_cal2::_InitPointers() { int n = m_nValues; m_vec_date.resize(n); if (!m_bUpstream) { m_p_Q_Inflow_m3s = new double[n]; m_p_Q_dif_m3s = new double[n]; } m_p_Q_obs_m3s = new double[n]; m_p_Q_obs_mmday = new double[n]; m_p_Q_sim_mmday = new double[n]; m_pPCP = new double[n]; m_pTMP = new double[n]; m_pExcessRain = new double[n]; m_pTw = new double[n]; m_pWI = new double[n]; if (m_bSnowModule) m_pMeltRate = new double[n]; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // DeletePointers() //--------------------------------------------------------------------- void Cihacres_cal2::_DeletePointers() { m_vec_date.resize(0); if (!m_bUpstream) { delete[] m_p_Q_Inflow_m3s; delete[] m_p_Q_dif_m3s; } delete[] m_p_Q_obs_m3s; delete[] m_p_Q_obs_mmday; delete[] m_p_Q_sim_mmday; delete[] m_pPCP; delete[] m_pTMP; delete[] m_pExcessRain; delete[] m_pTw; delete[] m_pWI; if (m_bSnowModule) delete[] m_pMeltRate; } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // ReadInputTable() //--------------------------------------------------------------------- void Cihacres_cal2::_ReadInputTable(int first, int last) { int j, k; for (j = 0, k = first; j < m_nValues, k < last + 1; j++, k++) { // put the date string into the vector m_vec_date[j].append(CSG_String(m_pTable->Get_Record(k)->asString(m_dateField))); m_p_Q_obs_m3s[j]= m_pTable->Get_Record(k)->asDouble(m_dischargeField); m_pPCP[j] = m_pTable->Get_Record(k)->asDouble(m_pcpField); m_pTMP[j] = m_pTable->Get_Record(k)->asDouble(m_tmpField); if (!m_bUpstream) m_p_Q_Inflow_m3s[j] = m_pTable->Get_Record(k)->asDouble(m_inflowField); } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Calculate observed streamflow time series if inflow occurs //--------------------------------------------------------------------- void Cihacres_cal2::_Calc_ObsMinInflow() { for (int i = 0; i < m_nValues; i++) { m_p_Q_dif_m3s[i] = m_p_Q_obs_m3s[i] - m_p_Q_Inflow_m3s[i]; if (m_p_Q_dif_m3s[i] < 0.0) m_p_Q_obs_mmday[i] = 0; } } //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // // SIMULATION // // /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// // // NON-LINEAR MODULE // /////////////////////////////////////////////////////////////////////// void Cihacres_cal2::_CalcNonLinearModule() { double eR_init = 0.0; //------------------------------------------------------------- // Assign random values //------------------------------------------------------------- if (m_bSnowModule) { m_SnowParms.T_Rain = model_tools::Random_double(m_T_Rain_lb, m_T_Rain_ub); m_SnowParms.T_Melt = model_tools::Random_double(m_T_Melt_lb, m_T_Melt_ub); m_SnowParms.DD_FAC = model_tools::Random_double(m_DD_FAC_lb, m_DD_FAC_ub); m_pSnowModule = new CSnowModule(m_pTMP, m_pPCP, m_nValues, m_SnowParms.T_Rain, m_SnowParms.T_Melt, m_SnowParms.DD_FAC); m_pMeltRate = m_pSnowModule->Get_MeltRate(m_pMeltRate, m_nValues); delete m_pSnowModule; } m_Tw = model_tools::Random_double(m_TwConst_lb, m_TwConst_ub); m_f = model_tools::Random_double(m_f_lb, m_f_ub); m_c = model_tools::Random_double(m_c_lb, m_c_ub); if (m_IHAC_version == 1) { // Croke etal. (2005) m_l = model_tools::Random_double(m_l_lb, m_l_ub); m_p = model_tools::Random_double(m_p_lb, m_p_ub); } //------------------------------------------------------------- //------------------------------------------------------------- // Simulation (non-linear module) //------------------------------------------------------------- switch(m_IHAC_version) { case 0: // Jakeman & Hornberger (1993) if (m_bTMP) { ihacres.CalcWetnessTimeConst(m_pTMP, m_pTw, m_Tw, m_f, m_nValues); } if (m_bSnowModule) { ihacres.CalcWetnessIndex(m_pTw, m_pPCP, m_pTMP, m_pWI, 0.5, m_c, m_bSnowModule, m_SnowParms.T_Rain, m_nValues); ihacres.CalcExcessRain(m_pPCP, m_pTMP, m_pWI,m_pExcessRain,eR_init, m_sum_eRainGTpcp, m_nValues, m_bSnowModule, m_SnowParms.T_Rain, m_SnowParms.T_Melt, m_pMeltRate); } else { ihacres.CalcWetnessIndex(m_pTw, m_pPCP, m_pTMP, m_pWI, 0.5, m_c, m_bSnowModule, 0, m_nValues); ihacres.CalcExcessRain(m_pPCP, m_pTMP, m_pWI, m_pExcessRain,eR_init, m_sum_eRainGTpcp, m_nValues, m_bSnowModule, 0,0,0); } // end if (m_bSnowModule) break; case 1: // Croke et al. (2005) Redesign if (m_bTMP) { ihacres.CalcWetnessTimeConst_Redesign(m_pTMP, m_pTw, m_Tw, m_f, m_nValues); } if (m_bSnowModule) { ihacres.CalcWetnessIndex_Redesign(m_pTw, m_pPCP, m_pWI, 0.5, m_bSnowModule, m_SnowParms.T_Rain, m_nValues); ihacres.CalcExcessRain_Redesign(m_pPCP, m_pTMP, m_pWI, m_pExcessRain, eR_init, m_sum_eRainGTpcp, m_nValues, m_c, m_l, m_p, m_bSnowModule, m_SnowParms.T_Rain, m_SnowParms.T_Melt, m_pMeltRate); } else { ihacres.CalcWetnessIndex_Redesign(m_pTw, m_pPCP, m_pWI, 0.5, m_bSnowModule, 0, m_nValues); ihacres.CalcExcessRain_Redesign(m_pPCP, m_pTMP, m_pWI, m_pExcessRain, eR_init, m_sum_eRainGTpcp, m_nValues, m_c, m_l, m_p, m_bSnowModule, 0,0,0); } break; } // end switch(m_IHAC_version) } //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // LINEAR MODULE // /////////////////////////////////////////////////////////////////////// void Cihacres_cal2::_CalcLinearModule() { //------------------------------------------------------------- // Assign random values //------------------------------------------------------------- switch(m_storconf) { case 0: // single storage m_a = model_tools::Random_double(m_a_lb, m_a_ub); m_b = model_tools::Random_double(m_b_lb, m_b_ub); break; case 1: // two storages in parallel do { m_aq = model_tools::Random_double(m_aq_lb, m_aq_ub); m_as = model_tools::Random_double(m_as_lb, m_as_ub); m_bq = model_tools::Random_double(m_bq_lb, m_bq_ub); // Calculate parameter m_vq to check parms aq and bq // Equation after Jakeman & Hornberger (1993) m_vq = m_bq / ( 1 + m_aq ); } while (m_vq < 0.0 || m_vq > 1.0); m_bs = ihacres.Calc_Parm_BS(m_aq, m_as, m_bq); break; } //------------------------------------------------------------- //------------------------------------------------------------- // Simulate streamflow (linear module) //------------------------------------------------------------- switch(m_storconf) { case 0: // single storage ihacres.SimStreamflowSingle(m_pExcessRain, m_p_Q_obs_mmday[0], m_p_Q_sim_mmday, m_delay, m_a, m_b, m_nValues); break; case 1: // two storages in parallel ihacres.SimStreamflow2Parallel(m_pExcessRain, m_p_Q_sim_mmday, m_p_Q_obs_mmday[0], m_aq, m_as, m_bq, m_bs, m_vq, m_vs, m_IHAC_version, m_nValues, m_delay); break; case 2: // two storages in series break; } // end switch(m_StorConf) } //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // EFFICIENCY // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Nash-Sutcliffe efficiency //--------------------------------------------------------------------- void Cihacres_cal2::_CalcEfficiency() { m_NSE = model_tools::CalcEfficiency(m_p_Q_obs_mmday, m_p_Q_sim_mmday,m_nValues); m_NSE_highflow = model_tools::Calc_NSE_HighFlow(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues); m_NSE_lowflow = model_tools::Calc_NSE_LowFlow(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues); m_PBIAS = model_tools::Calc_PBIAS(m_p_Q_obs_mmday, m_p_Q_sim_mmday, m_nValues); } //--------------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////// // // CREATE TABLES // ///////////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // Create output table //--------------------------------------------------------------------- void Cihacres_cal2::_CreateOutputTable() { // creating the column titles m_pTable->Add_Field("NSE", SG_DATATYPE_Double); m_pTable->Add_Field("NSE_high", SG_DATATYPE_Double); m_pTable->Add_Field("NSE_low", SG_DATATYPE_Double); m_pTable->Add_Field("PBIAS", SG_DATATYPE_Double); m_pTable->Add_Field("eR_ovest", SG_DATATYPE_Double); m_pTable->Add_Field("vq", SG_DATATYPE_Double); m_pTable->Add_Field("vs", SG_DATATYPE_Double); m_pTable->Add_Field("T(q)", SG_DATATYPE_Double); m_pTable->Add_Field("T(s)", SG_DATATYPE_Double); m_pTable->Add_Field("Tw", SG_DATATYPE_Double); m_pTable->Add_Field("f", SG_DATATYPE_Double); m_pTable->Add_Field("c", SG_DATATYPE_Double); if ( m_IHAC_version == 1 ) // Croke etal. (2005) { m_pTable->Add_Field("l", SG_DATATYPE_Double); m_pTable->Add_Field("p", SG_DATATYPE_Double); } if (m_bSnowModule) { m_pTable->Add_Field("T_Rain", SG_DATATYPE_Double); m_pTable->Add_Field("T_Melt", SG_DATATYPE_Double); m_pTable->Add_Field("DD_FAC", SG_DATATYPE_Double); } switch(m_storconf) { case 0: // single m_pTable->Add_Field("a", SG_DATATYPE_Double); m_pTable->Add_Field("b", SG_DATATYPE_Double); break; case 1: // two storages in parallel m_pTable->Add_Field("aq", SG_DATATYPE_Double); m_pTable->Add_Field("as", SG_DATATYPE_Double); m_pTable->Add_Field("bq", SG_DATATYPE_Double); m_pTable->Add_Field("bs", SG_DATATYPE_Double); break; } } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // Create output table //--------------------------------------------------------------------- void Cihacres_cal2::_WriteOutputTable() { int field = 0; CSG_Table_Record *pRecord; // add a new record to the table m_pTable->Add_Record(); pRecord = m_pTable->Get_Record(m_counter); // writing the data to the current row pRecord->Set_Value(field,m_NSE); field++; pRecord->Set_Value(field,m_NSE_highflow); field++; pRecord->Set_Value(field,m_NSE_lowflow); field++; pRecord->Set_Value(field,m_PBIAS); field++; pRecord->Set_Value(field,m_sum_eRainGTpcp); field++; pRecord->Set_Value(field,m_vq); field++; pRecord->Set_Value(field,m_vs); field++; pRecord->Set_Value(field,ihacres.Calc_TimeOfDecay(m_aq)); field++; pRecord->Set_Value(field,ihacres.Calc_TimeOfDecay(m_as)); field++; pRecord->Set_Value(field,m_Tw); field++; pRecord->Set_Value(field,m_f); field++; pRecord->Set_Value(field,m_c); field++; if ( m_IHAC_version == 1 ) // Croke et al. (2005) { pRecord->Set_Value(field,m_l); field++; pRecord->Set_Value(field,m_p); field++; } if ( m_bSnowModule ) { pRecord->Set_Value(field,m_SnowParms.T_Rain); field++; pRecord->Set_Value(field,m_SnowParms.T_Melt); field++; pRecord->Set_Value(field,m_SnowParms.DD_FAC); field++; } switch(m_storconf) { case 0: // single pRecord->Set_Value(field,m_a); field++; pRecord->Set_Value(field,m_b); field++; break; case 1: // two storages in parallel pRecord->Set_Value(field,m_aq); field++; pRecord->Set_Value(field,m_as); field++; pRecord->Set_Value(field,m_bq); field++; pRecord->Set_Value(field,m_bs); field++; break; } m_counter++; // record counter } //--------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // DIALOGS // /////////////////////////////////////////////////////////////////////// //--------------------------------------------------------------------- // DIALOG 1 //--------------------------------------------------------------------- void Cihacres_cal2::_CreateDialog1() { CSG_Parameter *pNode; CSG_String s; pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "DATE_Field" , _TL("Date Column"), _TL("Select the column containing the Date") ); Parameters.Add_Table_Field( pNode , "DISCHARGE_Field" , _TL("Streamflow Column"), _TL("Select the Column containing Discharge Values") ); Parameters.Add_Table_Field( pNode , "PCP_Field" , _TL("Precipitation Column"), _TL("Select the Column containing precipitation Values") ); Parameters.Add_Table_Field( pNode , "TMP_Field" , _TL("Temperature Column"), _TL("Select the Column containing Temperature Values") ); Parameters.Add_Table_Field( pNode , "INFLOW_Field" , _TL("Subbasin Inflow"), _TL("Select the column containing inflow data to the subbasin") ); Parameters.Add_Value( pNode, "bUPSTREAM", _TL("Is the subbasin upstream (no external inflow)"), _TL("If checked, it means there is no external inflow to the subbasin"), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( pNode, "USE_TMP", _TL("Using temperature data?"), _TL("If checked, then temperature data are used."), PARAMETER_TYPE_Bool, true ); pNode = Parameters.Add_Value( NULL, "NSIM", _TL("Number of Simulations"), _TL("Number of Simulations for Calibration"), PARAMETER_TYPE_Int, 1000, 1, true, 10000000, true ); pNode = Parameters.Add_Value( NULL, "AREA", _TL("Area of the Watershed in [km2]"), _TL("Area of the Watershed in [km2] used for unit conversion"), PARAMETER_TYPE_Double, 100.0, 0.00001, true, 0.0, false ); //s.Printf(SG_T("Node2", 2); // pNode = Parameters.Add_Node(NULL,s,SG_T("Non-Linear Module",_TL("")); //Parameters.Add_Value( // pNode, "DEV_ERAINDIS", _TL("Maximum Deviation: ExcessRain-Streamflow [%]"), // _TL("Maximum Deviation between estimated excess rainfall and observed streamflow volumes"), // PARAMETER_TYPE_Double, // 5.0, 0.0, true, 50.0, true //); //Parameters.Add_Value( // pNode, "DEV_ERAINPCP", _TL("Maximum Overestimation of ExcessRain [%]"), // _TL("Maximum Sum of overestimated ExcessRain to total ExcessRain in [%]"), // PARAMETER_TYPE_Double, // 5.0, 0.0, true, 50.0, true //); s.Printf(SG_T("Node3"), 3); pNode = Parameters.Add_Node(NULL,s,SG_T("Storage Configuration"),_TL("")); Parameters.Add_Choice( pNode , "STORAGE" , _TL("Storage"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Single Storage"), // 0 _TL("Two Parallel Storages"), // 1 _TL("Two Storages in Series") // 2 ) ); s.Printf(SG_T("Node4"), 4); pNode = Parameters.Add_Node(NULL,s,_TL("IHACRES Version"),_TL("")); Parameters.Add_Choice( pNode , "IHACVERS" , _TL("IHACRES Version"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Jakeman & Hornberger (1993)"), // 0 _TL("Croke et al. (2005)") // 1 ) ); Parameters.Add_Value( pNode, "SNOW_MODULE", _TL("Snow Module on/off"), _TL("If checked the snow module is active"), PARAMETER_TYPE_Bool, true ); Parameters.Add_Table_Output( NULL , "TABLEout" , _TL("Table"), _TL("") ); Parameters.Add_Table_Output( NULL , "TABLEparms" , _TL("Table"), _TL("") ); } //--------------------------------------------------------------------- //--------------------------------------------------------------------- // DIALOG 2 //--------------------------------------------------------------------- bool Cihacres_cal2::_CreateDialog2() { CSG_String s; CSG_Parameters P; // used to add Parameters in the second dialog CSG_Parameter *pNode, *pNode1; // Dialog design P.Set_Name(_TL("IHACRES Model Parameters")); s.Printf(SG_T("Node1"), 1); pNode = P.Add_Node(NULL,s,SG_T("Time Range"),_TL("")); s.Printf(SG_T("FDAY") , 1-1); P.Add_String(pNode,s,_TL("First Day"),_TL(""), m_pTable->Get_Record(0)->asString(m_dateField)); s.Printf(SG_T("LDAY") , 1-2); P.Add_String(pNode,s,_TL("Last Day"),_TL(""), m_pTable->Get_Record(m_pTable->Get_Record_Count()-1)->asString(m_dateField)); //----------------------------------------------------------------- // Non-linear parameters //----------------------------------------------------------------- s.Printf(SG_T("Node2"), 2); pNode = P.Add_Node(NULL,s,SG_T("Non-Linear Module"),_TL("")); P.Add_Value( pNode, "TwFAC_lb", _TL("(Tw) wetness decline time constant [lower bound]"), _TW("Tw is approximately the time constant, or inversely," "the rate at which the catchment wetness declines in the absence of rainfall"), PARAMETER_TYPE_Double, 1.0, 0.01, true, 150.0, true ); P.Add_Value( pNode, "TwFAC_ub", _TL("(Tw) wetness decline time constant [upper bound]"), _TW("Tw is approximately the time constant, or inversely,SG_T(" "the rate at which the catchment wetness declines in the absence of rainfall"), PARAMETER_TYPE_Double, 50.0, 0.01, true, 150.0, true ); if (m_bTMP) // if observed temperature data are used { P.Add_Value( pNode , "TFAC_lb" , _TL("(f) Temperature Modulation Factor [lower bound]"), _TL("Temperature Modulation Factor f"), PARAMETER_TYPE_Double, 0.05, 0.0001, true, 5.0, true ); P.Add_Value( pNode , "TFAC_ub" , _TL("(f) Temperature Modulation Factor [upper bound]"), _TL("Temperature Modulation Factor f"), PARAMETER_TYPE_Double, 0.5, 0.0001, true, 5.0, true ); } P.Add_Value( pNode, "CFAC_lb", _TL("(c) Parameter [lower bound]"), _TL("Parameter (c) to fit streamflow volume"), PARAMETER_TYPE_Double, 0.001, 0.0, true, 1.0, true ); P.Add_Value( pNode, "CFAC_ub", _TL("(c) Parameter [upper bound]"), _TL("Parameter (c) to fit streamflow volume"), PARAMETER_TYPE_Double, 0.01, 0.0, true, 1.0, true ); if (m_IHAC_version == 1) // Croke et al. (2005) Redesign { s.Printf(SG_T("Node2-2"), 2-2); pNode1 = P.Add_Node(pNode,s,SG_T("Soil moisture index threshold"),_TL("")); P.Add_Value( pNode1 , "SMI_L_lb" , _TL("Soil moisture index (l) [lower bound]"), _TL("Soil moisture index threshold (l), lower bound"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); P.Add_Value( pNode1 , "SMI_L_ub" , _TL("Soil moisture index (l) [upper bound]"), _TL("Soil moisture index threshold (l), upper bound"), PARAMETER_TYPE_Double, 5.0, 0.0, true, 5.0, true ); s.Printf(SG_T("Node2-3"), 2-3); pNode1 = P.Add_Node(pNode,s,_TL("Power on soil moisture"),_TL("")); P.Add_Value( pNode1 , "SM_P_lb" , _TL("Power on soil (p) [lower bound]"), _TL("Power on soil moisture (p), lower bound"), PARAMETER_TYPE_Double, 0.0, 0.0, true, 5.0, true ); P.Add_Value( pNode1 , "SM_P_ub" , _TL("Power on soil (p) [upper bound]"), _TL("Power on soil moisture (p), upper bound"), PARAMETER_TYPE_Double, 5.0, 0.0, true, 5.0, true ); } //----------------------------------------------------------------- // Linear module //----------------------------------------------------------------- switch(m_storconf) { case 0: // single storage s.Printf(SG_T("Node3"), 3); pNode = P.Add_Node(NULL,s,_TL("Linear Module"),_TL("")); s.Printf(SG_T("Node3-1"), 3-1); pNode1 = P.Add_Node(pNode,s,_TL("Parameter (a)"),_TL("")); P.Add_Value( pNode1, "AFAC_lb", _TL("(a) [lower bound]"), _TL(""), PARAMETER_TYPE_Double, -0.5, -0.99, true, -0.01, true ); P.Add_Value( pNode1, "AFAC_ub", _TL("(a) [upper bound]"), _TL(""), PARAMETER_TYPE_Double, -0.9, -0.99, true, -0.01, true ); s.Printf(SG_T("Node3-2"), 3-2); pNode1 = P.Add_Node(pNode,s,_TL("Parameter (b)"),_TL("")); P.Add_Value( pNode1, "BFAC_lb", _TL("(b) [lower bound]"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.001, true, 1.0, true ); P.Add_Value( pNode1, "BFAC_ub", _TL("(b) [upper bound]"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.001, true, 1.0, true ); break; case 1: // two parallel storages s.Printf(SG_T("Node3"), 3); pNode = P.Add_Node(NULL,s,_TL("Linear Module"),_TL("")); // Parameter a s.Printf(SG_T("Node3-1"), 3-1); pNode1 = P.Add_Node(pNode,s,_TL("Parameter (a)"),_TL("")); P.Add_Value( pNode1, "AQ_lb", _TL("a(q) [lower bound]"), _TL(""), PARAMETER_TYPE_Double, -0.5, -0.99, true, -0.01, true ); P.Add_Value( pNode1, "AQ_ub", _TL("a(q) [upper bound]"), _TL(""), PARAMETER_TYPE_Double, -0.7, -0.99, true, -0.01, true ); P.Add_Value( pNode1, "AS_lb", _TL("a(s) [lower bound]"), _TL(""), PARAMETER_TYPE_Double, -0.7, -0.99, true, -0.01, true ); P.Add_Value( pNode1, "AS_ub", _TL("a(s) [upper bound]"), _TL(""), PARAMETER_TYPE_Double, -0.99, -0.99, true, -0.01, true ); // Parameter b s.Printf(SG_T("Node3-2"), 3-2); pNode1 = P.Add_Node(pNode,s,SG_T("Parameter (b)"),_TL("")); P.Add_Value( pNode1, "BQ_lb", _TL("b(q) [lower bound]"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); P.Add_Value( pNode1, "BQ_ub", _TL("b(q) [upper bound]"), _TL(""), PARAMETER_TYPE_Double, 0.5, 0.0, true, 1.0, true ); break; case 2: // two storages in series break; } // end switch (m_storconf) //----------------------------------------------------------------- // Snow module //----------------------------------------------------------------- if (m_bSnowModule) // if snow module is active { s.Printf(SG_T("Node2-4"), 2-4); pNode = P.Add_Node(NULL,s,SG_T("Snow Module"),_TL("")); P.Add_Value( pNode, "T_RAIN_lb", _TL("Temperature Threshold for Rainfall (lower bound)"), _TL("Below this threshold precipitation will fall as snow"), PARAMETER_TYPE_Double, -1.0, -10.0, true, 10.0, true ); P.Add_Value( pNode, "T_RAIN_ub", _TL("Temperature Threshold for Rainfall (upper bound)"), _TL("Below this threshold precipitation will fall as snow"), PARAMETER_TYPE_Double, 1.0, -10.0, true, 10.0, true ); P.Add_Value( pNode, "T_MELT_lb", _TL("Temperature Threshold for Melting (lower bound)"), _TL("Above this threshold snow will start to melt"), PARAMETER_TYPE_Double, -1.0, -5.0, true, 10.0, true ); P.Add_Value( pNode, "T_MELT_ub", _TL("Temperature Threshold for Melting (upper bound)"), _TL("Above this threshold snow will start to melt"), PARAMETER_TYPE_Double, 1.0, -5.0, true, 10.0, true ); P.Add_Value( pNode, "DD_FAC_lb", _TL("Day-Degree Factor (lower bound)"), _TL("Day-Degree Factor depends on catchment characteristics"), PARAMETER_TYPE_Double, 0.7, 0.7, true, 9.2, true ); P.Add_Value( pNode, "DD_FAC_ub", _TL("Day-Degree Factor (upper bound)"), _TL("Day-Degree Factor depends on catchment characteristics"), PARAMETER_TYPE_Double, 9.2, 0.7, true, 9.2, true ); } s.Printf(SG_T("Node4"), 4); pNode = P.Add_Node(NULL,s,SG_T("Time Delay after Start of Rainfall (INTEGER)"),_TL("")); P.Add_Value( pNode1, "DELAY", _TL("Time Delay (Rain-Runoff)"), _TL("The delay after the start of rainfall, before the discharge starts to rise."), PARAMETER_TYPE_Int, 1, 1, true, 100, true ); s.Printf(SG_T("Node6"), 6); pNode = P.Add_Node(NULL,s,SG_T("Nash-Sutcliffe Efficiency"),_TL("")); P.Add_Choice( pNode, "OBJ_FUNC" , _TL("Objective Function"), _TL(""), _TL("NSE|NSE high flow|NSE low flow") ); P.Add_Value( pNode, "NSEMIN", _TL("Minimum Nash-Sutcliffe Efficiency"), _TL("Minimum Nash-Sutcliffe Efficiency required to print simulation to calibration table"), PARAMETER_TYPE_Double, 0.7, 0.1, true, 1.0, true ); // End of second dialog design if( SG_UI_Dlg_Parameters(&P, _TL("Choose Time Range")) ) { // assign data from second dialog m_date1 = P(CSG_String::Format(SG_T("FDAY"),m_dateField).c_str())->asString(); m_date2 = P(CSG_String::Format(SG_T("LDAY"),m_dischargeField).c_str())->asString(); //------------------------------------------------- // assign non-linear module parameters //------------------------------------------------- m_TwConst_lb = P("TwFAC_lb") ->asDouble(); m_TwConst_ub = P("TwFAC_ub") ->asDouble(); m_c_lb = P("CFAC_lb") ->asDouble(); m_c_ub = P("CFAC_ub") ->asDouble(); if (m_bTMP) // if observed temperature data are used { m_f_lb = P("TFAC_lb") ->asDouble(); m_f_ub = P("TFAC_ub") ->asDouble(); } if (m_IHAC_version == 1) { m_l_lb = P("SMI_L_lb") ->asDouble(); m_l_ub = P("SMI_L_ub") ->asDouble(); m_p_lb = P("SM_P_lb") ->asDouble(); m_p_ub = P("SM_P_ub") ->asDouble(); } //------------------------------------------------- //------------------------------------------------- // assign linear module parameters //------------------------------------------------- switch (m_storconf) { case 0: m_a_lb = P("AFAC_lb") ->asDouble(); m_a_ub = P("AFAC_ub") ->asDouble(); m_b_lb = P("BFAC_lb") ->asDouble(); m_b_ub = P("BFAC_ub") ->asDouble(); m_delay = P("DELAY") ->asInt(); m_NSEmin = P("NSEMIN") ->asDouble(); break; case 1: // two parallel storages m_aq_lb = P("AQ_lb") ->asDouble(); m_aq_ub = P("AQ_ub") ->asDouble(); m_as_lb = P("AS_lb") ->asDouble(); m_as_ub = P("AS_ub") ->asDouble(); m_bq_lb = P("BQ_lb") ->asDouble(); m_bq_ub = P("BQ_ub") ->asDouble(); m_delay = P("DELAY") ->asInt(); m_obj_func = P("OBJ_FUNC") ->asInt(); m_NSEmin = P("NSEMIN") ->asDouble(); break; case 2: // two storages in series break; } // end switch //------------------------------------------------- if (m_bSnowModule) { m_T_Rain_lb = P("T_RAIN_lb") ->asDouble(); m_T_Rain_ub = P("T_RAIN_ub") ->asDouble(); m_T_Melt_lb = P("T_MELT_lb") ->asDouble(); m_T_Melt_ub = P("T_MELT_ub") ->asDouble(); m_DD_FAC_lb = P("DD_FAC_lb") ->asDouble(); m_DD_FAC_ub = P("DD_FAC_ub") ->asDouble(); } return(true); } else { return(false); } } saga-2.3.1/src/modules/simulation/sim_ihacres/MLB_Interface.h0000744000175000017500000000774312737416207025265 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // IHACRES // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Author // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: author@email.de // // // // contact: Author // // Sesame Street. 7 // // 12345 Metropolis // // Nirvana // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /* $Log: not supported by cvs2svn $ /* Revision 1.1 2009/10/20 07:40:39 oconrad /* no message /* /* Revision 1.1.1.1 2005/08/31 14:00:48 oconrad /* no message /* /* Revision 1.1.1.1 2005/08/17 08:25:03 oconrad /* no message /* /* Revision 1.1.1.1 2005/08/15 13:35:24 oconrad /* no message /* */ //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ihacres_H #define HEADER_INCLUDED__ihacres_H //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ihacres_H saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_eq.h0000744000175000017500000004215712737416210024766 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_eq.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_eq.h // // // // Copyright (C) 2006 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2006-08-27 // // modified: 2008-01-28 // //-------------------------------------------------------// // // References: // Jakeman, A.J. / Hornberger, G.M (1993). // How Much Complexity Is Warranted in a // Rainfall-Runoff Model? // Water Resources Research, (29), NO. 8 (2637-2649) // Kokkonen, T. S. et al. (2003). // Predicting daily flows in ungauged catchments: // model regionalization from catchment descriptors // at the Coweeta Hydrologic Laboratory, North Carolina // Hydrological Processes (17), 2219-2238 // Croke, B. F. W., W. S. Merritt, et al. (2004). // A dynamic model for predicting hydrologic response // to land cover changes in gauged and // ungauged catchments. // Journal Of Hydrology 291(1-2): 115-131. // Croke, B. F. W., Andrews, F., Jakeman, A. J., Cuddy, S., Luddy, A.: // (2005). Redesign of the IHACRES rainfall-runoff model /////////////////////////////////////////////////////////// //*******************************************************// // NOTES // //*******************************************************// // This class provides functions of the rainfall-runoff // model IHACRES. On the one hand the class can be used as // a provider of functions using the standard constructor // or the class can be instantiated and then performs the // calculations automatically. // // Every function working with fields can be provided with // arrays (pointer) or vector. You find for both solutions // the appropriate function. //*******************************************************// //*******************************************************// // ToDo // //-------------------------------------------------------// // - Difference eRain-streamflow_obs // - Tau(q) and Tau(s) // - Tau-values for different storages // - if TMP_data_exist = false ??? // - hourly data (not only daily) // // - SNOW MODULE // - snow module on/off // - snow module integration in CalcExcessRain (add bool variable) // - implementation of an instanteneous store // - implement more efficiency criterions //*******************************************************// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ihacres_eq_H #define HEADER_INCLUDED__ihacres_eq_H //--------------------------------------------------------- #include // CSG_Table #include // used for storing date string values in array // and double arrays (streamflow, pcp, tmp ...) #include using namespace std; #include "snow_module.h" #include "model_tools.h" typedef std::vector date_array; typedef vector vector_d; //--------------------------------------------------------- //--------------------------------------------------------- // A CLASS TO DEAL WITH PARAMETERS OF THE // LINEAR STORAGE MODULE //--------------------------------------------------------- class C_IHAC_LinearParms { public: C_IHAC_LinearParms() { _ZeroPointers(); } C_IHAC_LinearParms(int size, int nStorages) { _ZeroPointers(); this->nStorages = nStorages; if (nStorages == 1) { a = new double[size]; b = new double[size]; } if (nStorages == 2) { aq = new double[size]; as = new double[size]; bq = new double[size]; bs = new double[size]; } } ~C_IHAC_LinearParms(void) { if (nStorages == 1) { if (a) delete[] a; if (b) delete[] b; } if (nStorages == 2) { if (aq) delete[] aq; if (as) delete[] as; if (bq) delete[] bq; if (bs) delete[] bs; } } // linear module parameters int nStorages; double* a; double* b; double* aq; double* as; double* bq; double* bs; private: void _ZeroPointers() { a = NULL; b = NULL; aq = NULL; as = NULL; bq = NULL; bs = NULL; } }; //--------------------------------------------------------- //--------------------------------------------------------- // A CLASS TO DEAL WITH PARAMETERS OF THE // NON-LINEAR RAINFALL-LOSSES MODULE //--------------------------------------------------------- class C_IHAC_NonLinearParms { public: C_IHAC_NonLinearParms() { mp_tw = NULL; mp_f = NULL; mp_c = NULL; mp_l = NULL; mp_p = NULL; mp_eR_flow_dif = NULL; }; C_IHAC_NonLinearParms(int size) { mp_tw = new double[size]; mp_f = new double[size]; mp_c = new double[size]; mp_l = new double[size]; mp_p = new double[size]; mp_eR_flow_dif = new double[size]; }; ~C_IHAC_NonLinearParms(void) { if (mp_tw) delete[] mp_tw; if (mp_f) delete[] mp_f; if (mp_c) delete[] mp_c; if (mp_l) delete[] mp_l; if (mp_p) delete[] mp_p; if (mp_eR_flow_dif) delete[] mp_eR_flow_dif; }; // non-linear module parms double* mp_tw; double* mp_f; double* mp_c; double* mp_l; double* mp_p; double* mp_eR_flow_dif; }; //--------------------------------------------------------- /////////////////////////////////////////////////////////////////////// // // CLASS Cihacres_eq // /////////////////////////////////////////////////////////////////////// class Cihacres_eq { public: /////////////////////////////////////////////////////////////////// // // CONSTRUCTORS // /////////////////////////////////////////////////////////////////// // default Cihacres_eq(); // two storages // using vector as input // if no temperature data are available Cihacres_eq (date_array date, vector_d streamflow_obs, vector_d precipitation, double Tw, double f, double c, double l, double p, double aq, double as, double bq, double bs); // two storages // using vector as input // if temperature data are available Cihacres_eq (date_array date, vector_d streamflow_obs, vector_d precipitation, vector_d temperature, double Tw, double f, double c, double l, double p, double aq, double as, double bq, double bs, double area, bool TMP_data_exist, int IHAC_vers, int storconf, bool bSnowModule, CSnowModule *SnowMod, //double T_Rain, //double T_Melt, //double DD_FAC, int delay); // two storages // using double arrays as input // if no temperature data are available Cihacres_eq (int size, // array size date_array date, double *streamflow_obs, double *precipitation, double Tw, double f, double c, double aq, double as, double bq, double bs); // two storages // if temperature data are available // using double arrays as input Cihacres_eq (int size, // array size date_array date, double *streamflow_obs, double *precipitation, double *temperature, double Tw, double f, double c, double aq, double as, double bq, double bs); // end constructors /////////////////////////////////////////////// // destructor ~Cihacres_eq(void); /////////////////////////////////////////////////////////////////// // // PUBLIC MEMBER VARIABLES // /////////////////////////////////////////////////////////////////// // Variables int sizeAll; // incoming data array size (number of records in input data) CSnowModule *m_pSnowMod; // class Snow Module double* m_pMeltRate; /////////////////////////////////////////////////////////////////// // // PUBLIC MEMBER FUNCTIONS // /////////////////////////////////////////////////////////////////// //-------------------------------------------------------- void RunNonLinearModule (bool TMP_data_exist, bool bSnowModule, double T_Rain); // simulate streamflow (single storage) void SimStreamflowSingle (vector_d &excessRain, double initVal, vector_d &streamflow_sim, int delay, double a, double b); void SimStreamflowSingle (double *excessRain, double initVal, double *streamflow_sim, int delay, double a, double b, int size); // simulate streamflow with two parallel storages void SimStreamflow2Parallel (vector_d &excessRain, vector_d &streamflow_sim, double initVal, // first observed streamflow value double aq, double as, double bq, double bs, double &vq, double &vs, int IHAC_vers, int delay); void SimStreamflow2Parallel (double *excessRain, double *streamflow_sim, double initVal, // first observed streamflow value double aq, double as, double bq, double bs, double &vq, double &vs, int IHAC_vers, int size, int delay); void SimStreamflow2Parallel (double *excessRain, double *streamflow_sim, double initVal, // first observed streamflow value C_IHAC_LinearParms* linparms, int index, double &vq, double &vs, int size, int delay); double Calc_Parm_BS (double aq, double as, double bq); // calculate time of decay for quick or slow component (aq or bq) double Calc_TimeOfDecay (double a); //-------------------------------------------------------- // calculating the time constant, or inversely the rate at which // the catchment wetness declines in the absence of rainfall void CalcWetnessTimeConst (vector_d &temperature, vector_d &Tw, double TwConst, double f); void CalcWetnessTimeConst (double *temperature, double *Tw, double TwConst, double f, int size); void CalcWetnessTimeConst (double* temperature, double* Tw, C_IHAC_NonLinearParms* nonlinparms, int index, int size); // For ihacres_climate_scen void CalcWetnessTimeConst_scen(double* temperature, double* Tw, C_IHAC_NonLinearParms* nonlinparms, int index, int size); // modified version after Croke et al. (2005) void CalcWetnessTimeConst_Redesign(vector_d &temperature, vector_d &Tw, double TwConst, double f); // modified version after Croke et al. (2005) void CalcWetnessTimeConst_Redesign(double *temperature, double *Tw, double TwConst, double f, int size); void CalcWetnessTimeConst_Redesign(double *temperature, double *Tw, C_IHAC_NonLinearParms* nonlinparms, int index, int size); // calculating the catchment wetness index, // or antecedent precipitation index void CalcWetnessIndex (vector_d &Tw, vector_d &precipitation, vector_d &temperature, vector_d &WetnessIndex, double WI_init, double c, bool bSnowModule, double T_Rain); void CalcWetnessIndex (double *Tw, double *precipitation, double *temperature, double *WetnessIndex, double WI_init, double c, bool bSnowModule, double T_Rain, int size); // modified version after Croke et al. (2005) void CalcWetnessIndex_Redesign(vector_d &Tw, vector_d &precipitation, vector_d &WetnessIndex, bool bSnowModule,double T_Rain); // modified version after Croke et al. (2005) void CalcWetnessIndex_Redesign(double *Tw, double *precipitation, double *WetnessIndex, double WI_init, bool bSnowModule,double T_Rain, int size); // calculate the effecive or excess rainfall and // calculate total effective rainfall over the period in [mm] double CalcExcessRain (vector_d &precipitation, vector_d &temperature, vector_d &WetnessIndex, vector_d &excessRain, double eR_init, double &sum_eRainGTpcp, bool bSnowModule, CSnowModule* pSnowModule); double CalcExcessRain (double *precipitation, double *temperature, double *WetnessIndex, double *excessRain, double eR_init, double &sum_eRainGTpcp, int size, bool bSnowModule, double T_Rain, double T_Melt, double* MeltRate); // modified version after Croke et al. (2005) double CalcExcessRain_Redesign (vector_d &precipitation, vector_d &temperature, vector_d &WetnessIndex, vector_d &excessRain, double eR_init, double &sum_eRainGTpcp, double c, // mass balance parameter double l, // soil moisture index threshold double p, // power on soil moisture bool bSnowModule, CSnowModule* m_pSnowMod); // modified version after Croke et al. (2005) double CalcExcessRain_Redesign (double *precipitation, double *temperature, double *WetnessIndex, double *excessRain, double eR_init, double &sum_eRainGTpcp, int size, double c, // mass balance parameter double l, // soil moisture index threshold double p, // power on soil moisture bool bSnowModule, double T_Rain, double T_Melt, double* MeltRate); //-------------------------------------------------------- //-------------------------------------------------------- void AssignFirstLastRec (CSG_Table &pTable, int &first, int &last, CSG_String date1,CSG_String date2, int dateField); int Assign_nStorages (int storconf); double SumVector (vector_d &input); double SumVector (double *input, int size); double _Assign_NSE_temp (int obj_func, double NSE, double NSE_highflow, double NSE_lowflow); //-------------------------------------------------------- // Get Functions //-------------------------------------------------------- double get_vq(); // fraction of quick flow double get_vs(); // fraction of slow flow double get_sum_streamflowMM_obs(int size); // sum of observed streamflow in [mm] double get_sum_precipitation(int size); double get_NSE(); vector_d get_streamflow_sim(); vector_d get_excessRain(); vector_d get_WetnessIndex(); vector_d get_Tw(); private: /////////////////////////////////////////////////////////////////// // Private Member Variables /////////////////////////////////////////////////////////////////// // incoming arrays / vectors date_array date; // Vector containing date values vector_d streamflow_obs; // Vector containing observed streamflow data vector_d precipitation; // Vector containing measured precipitation vector_d temperature; // Vector containing measured temperature vector_d streamflowMM_obs; // Streamflow time series in [mm] // double sum_eRainGTpcp; // sum of excess rainfall that is greater // than precipitation in one simulation // Vectors (arrays) vector_d streamflow_sim; // Vector containing simulated streamflow data vector_d excessRain; // Vector containing estimated excess or effective rainfall vector_d WetnessIndex; // catchment wetness index vector_d Tw; // parameters bool TMP_data_exist; // if temperature data are available (TMP_data_exist = true) double RainRunoffCoef; // Rainfall-Runoff coefficient double NSE; // Nash-Sutcliffe Efficiency double sum_streamflow_obs; double sum_streamflow_sim; double sum_eRainMM; // sum of estimated effective rainfall [mm] // non-linear IHACRES module parameters double c; double f; double TwConst; // Tw is approximately the time constant, or inversely, // the rate at which the catchment wetness declines // in the absence of rainfall. // Additional parameters for Croke et al. (2005) Redesign version double l; // soil moisture index threshold double p; // power on soil moisture // linear IHACRES module parameters double a; double b; double aq; double as; double bq; double bs; double vq; // fraction of quick flow double vs; // fraction of slow flow int delay; // The delay after the start of rainfall, // before the discharge starts to rise. double area; // area of the watershed in [km2] int IHAC_version; // Different versions of IHACRES exist, corresponding // to the version... bool bSnowModule; // if true, snow module is active /* // snow module parameters vector_d SnowStorage; vector_d MeltRate; double T_Rain; double T_Melt; double DD_FAC; */ /////////////////////////////////////////////////////////////////// // Private Member Functions /////////////////////////////////////////////////////////////////// // initialize Vectors void _InitVectorsStart (int size); // Resize all vectors *.resize(0) void _ZeroAllVectors (); }; // end class ihacres_eq //--------------------------------------------------------- #endif /* #ifndef HEADER_INCLUDED__ihacres_eq_H */ saga-2.3.1/src/modules/simulation/sim_ihacres/MLB_Interface.cpp0000744000175000017500000002207312737416207025611 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // ihacres // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Author // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: author@email.de // // // // contact: Author // // Sesame Street. 7 // // 12345 Metropolis // // Nirvana // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Hydrology: IHACRES") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("Stefan Liersch (c) 2008") ); case MLB_INFO_Description: return( _TW( "The metric conceptual rainfall-runoff model IHACRES " "(Identification of unit Hydrographs and Component flows " "from Rainfall, Evaporation and Streamflow data) has been " "implemented as a module library. The IHACRES model was " "developed by: Jakeman, A.J. and G.M. Hornberger (1993); Jakeman et al. (1990).\n" "\n" "Purpose\n" "The module can be used to simulate streamflow (catchment runoff) " "on the basis of daily rainfall and temperature data. No spatial " "data, such as elevation models, soil or land use maps are required.\n" "\n" "IHACRES has been applied to catchments with a wide range of climatologies " "and sizes (Croke et al., 2004). It has been used to predict streamflow in " "ungauged catchments (Kokkonen et al., 2003; Post and Jakeman, 1999; " "Post et al., 1998), to study land cover effects on hydrologic processes " "(Croke et al., 2004; Kokkonen and Jakeman, 2002), and to investigate dynamic " "response characteristics and physical catchment descriptors (Kokkonen et al., " "2003; Sefton and Howarth, 1998).\n" "\n" "More recently, the model has been used to develop a " "rainfall-runoff database " "for flood risk assessment and forecasting by Liersch, S. and M. Volk (2008) " "(pdf).\n" "\n" "References\n
      " "
    • Croke, B.F.W., Merritt, W.S., Jakeman, A.J., 2004. A dynamic model for predicting hydrologic response to land cover changes in gauged and ungauged catchments. Journal Of Hydrology 291 (1), 115-31.
    • \n" "
    • Jakeman, A.J., Littlewood, I.G., Whitehead, P.G., 1990. Computation of the instantaneous unit hydrograph and identifiable component flows with application to two small upland catchments. Journal of Hydrology 117 (1-4), 275-300.
    • \n" "
    • Jakeman, A.J. and Hornberger, G.M., 1993. How Much Complexity Is Warranted in a Rainfall-Runoff Model?. Water Resources Research 29 (8), 2637-49.
    • \n" "
    • Kokkonen, T.S., Jakeman, A.J., Young, P.C., Koivusalo, H.J., 2003. Predicting daily flows in ungauged catchments: model regionalization from catchment descriptors at the Coweeta Hydrologic Laboratory. North Carolina Hydrological Processes 17 (11), 2219-38.
    • \n" "
    • Kokkonen, T.S. and Jakeman, A.J., 2002. Structural Effects of Landscape and Land Use on Streamflow Response. In: Environmental Foresight and Models: A Manifesto, 303-321.
    • \n" "
    • Liersch, S. and M. Volk, 2008. A rainfall-runoff database to support flood risk assessment. iEMSs 2008: International Congress on Environmental Modelling and Software. In: M. Sanchez-Marre, J. Bejar, J. Comas, A. Rizzoli and G. Guariso (Eds.): Proceedings of the iEMSs Fourth Biennial Meeting: International Congress on Environmental Modelling and Software (iEMSs 2008). International Environmental Modelling and Software Society, Barcelona, Catalonia, July 2008. Vol. 1: 494-502. ISBN: 978-84-7653-074-0. (PEER reviewed).
    • \n" "
    • Post, D.A. and Jakeman, A.J., 1999. Predicting the daily streamflow of ungauged catchments in S.E. Australia by regionalising the parameters of a lumped conceptual rainfall-runoff model. Ecological Modelling 123 (2-3), 91-104.
    • \n" "
    • Post, D.A., Jones, J.A. and Grant, G.E., 1998. An improved methodology for predicting the daily hydrologic response of ungauged catchments. Environmental Modelling & Software 13 (3-4), 395-403.
    • \n" "
    • Sefton, C.E.M. and Howarth, S.M., 1998. Relationships between dynamic response characteristics and physical descriptors of catchments in England and Wales. Journal of Hydrology 211 (1-4), 1-16.
    • \n" "
    " )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Hydrology|IHACRES") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... //#include "ihacres_cal.h" #include "ihacres_cal2.h" #include "ihacres_v1.h" #include "ihacres_elev.h" #include "ihacres_elev_cal.h" //#include "ihacres_climate_scen.h" //#include "ihacres_climate_scen_db.h" #include "ihacres_basin.h" //#include "ihacres_auto_cal.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { // Don't forget to continuously enumerate the case switches // when adding new modules! Also bear in mind that the // enumeration always has to start with [case 0:] and // that [default:] must return NULL!... CSG_Module *pModule; switch( i ) { //case 0: // pModule = new Cihacres_cal; // break; case 0: pModule = new Cihacres_cal2; break; case 1: pModule = new Cihacres_v1; break; case 2: pModule = new Cihacres_basin; break; case 3: pModule = new Cihacres_elev; break; case 4: pModule = new Cihacres_elev_cal; break; //case 6: // pModule = new Cihacres_climate_scen; // break; //case 7: // pModule = new Cihacres_climate_scen_db; // break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/simulation/sim_ihacres/ihacres_elev.h0000744000175000017500000001123012737416207025306 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ihacres_elev.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // ihacres_elev.h // // // // Copyright (C) 2008 by // // Stefan Liersch // //-------------------------------------------------------// // e-mail: stefan.liersch@ufz.de // // stefan.liersch@gmail.com // // 2008-01-08 // //-------------------------------------------------------// //*******************************************************// // ToDo // //-------------------------------------------------------// // - m_delay is not yet implemented for each elevation band // as it is suggested by the user dialog. The delay value // of the last elevation band is used instead for all bands. //*******************************************************// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ihacres_elev_H #define HEADER_INCLUDED__ihacres_elev_H //--------------------------------------------------------- #include "MLB_Interface.h" #include "ihacres_eq.h" #include "ihacres_elev_bands.h" #include "snow_module.h" #include // used for storing date string values in array //using namespace std; typedef std::vector date_array; class Cihacres_elev : public CSG_Module { public: //-------------------------------------------------------- // CONSTRUCTORS //-------------------------------------------------------- // default Cihacres_elev(); // destructor virtual ~Cihacres_elev(void); virtual bool needs_GUI (void) { return( true ); } protected: // execute module virtual bool On_Execute(void); private: //-------------------------------------------------------- // PRIVATE MEMBER VARIABLES //-------------------------------------------------------- //---------------------------------- // parameters of first module dialog //---------------------------------- int m_nElevBands; // number of used elevation bands double m_Area_tot; // total catchment area [km2] int m_IHAC_version; // Different versions of IHACRES exist, corresponding // to the version... int m_StorConf; // Storage configuration // 0 = single, 1 = two in parallel, 2 = two in series bool m_bSnowModule; // true if snow module is active int m_nStorages; // number of storages //---------------------------------- // parameters of second module dialog //---------------------------------- // time series variables CSG_Table* m_p_InputTable; // IHACRES input table int m_nValues; // number of selected records date_array m_vec_date; double* m_p_Q_obs_m3s; // pointer containing observed streamflow in [m3/s] double* m_p_Q_obs_mmday; // pointer containing observed streamflow in [mm] Cihacres_elev_bands* m_p_elevbands; // Class Cihacres_elev_bands // Field numbers int m_dateField; // table field numbers int m_streamflowField; // elevation band parameters int* m_p_pcpField; int* m_p_tmpField; //double* m_p_Area; //double* m_p_mean_elev; //---------------------------------- // parameters of third module dialog //---------------------------------- CSG_String m_date1; // first day of time series YYYYMMDD CSG_String m_date2; // last day int m_first; int m_last; //---------------------------------- // Model parameter (in: ihacres_eq.h) //---------------------------------- C_IHAC_LinearParms* m_p_linparms; // parameters of the linear storage module C_IHAC_NonLinearParms* m_p_nonlinparms; // parameters of the non-linear rainfall loss module CSnowParms* m_pSnowparms; // 3 snow module parameters CSnowModule* m_p_SnowModule; int m_delay; double m_vq; double m_vs; CSG_Table* m_pTable; //-------------------------------------------------------- // PRIVATE MEMBER FUNCTIONS //-------------------------------------------------------- void _Init_ElevBands(int n); // n = m_nElevBands void _Init_Pointers(int nvals); void _CreateDialog1(); bool _CreateDialog2(); bool _CreateDialog3(); void _ReadInputFile(); void _CalcSnowModule(int elevband); void _Simulate_NonLinearModule(int elevband); void _Simulate_Streamflow(int elevband); void _CreateTableSim(); // Class ihacres_eq Cihacres_eq ihacres; }; #endif /* HEADER_INCLUDED__ihacres_elev_H */ saga-2.3.1/src/modules/simulation/sim_cellular_automata/0000775000175000017500000000000012737740007024566 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/simulation/sim_cellular_automata/Wator.cpp0000744000175000017500000003377512737416206026405 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Wator.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // Wator.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Wator.h" //--------------------------------------------------------- #define FISH 1 #define SHARK 2 /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWator::CWator(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Wa-Tor")); Set_Author ("O.Conrad (c) 2003"); Set_Description (_TW( "Wa-Tor - an ecological simulation of predator-prey populations - " "is based upon A. K. Dewdney's 'Computer Recreations' article " "in the December 1984 issue of Scientific American." )); //----------------------------------------------------- m_Grid_Target.Create(&Parameters, false, NULL, "TARGET_"); m_Grid_Target.Add_Grid("GRID", _TL("Wa-Tor"), false); //----------------------------------------------------- pNode = Parameters.Add_Value( NULL , "REFRESH" , _TL("Refresh"), _TL(""), PARAMETER_TYPE_Bool , true ); Parameters.Add_Value( pNode , "INIT_FISH" , _TL("Initial Number of Fishes [%]"), _TL(""), PARAMETER_TYPE_Double , 30.0, 0.0, true, 100.0, true ); Parameters.Add_Value( pNode , "INIT_SHARK" , _TL("Initial Number of Sharks [%]"), _TL(""), PARAMETER_TYPE_Double , 7.5, 0.0, true, 100.0, true ); Parameters.Add_Table( NULL , "TABLE" , _TL("Cycles"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "FISH_BIRTH" , _TL("Birth Rate of Fishes"), _TL(""), PARAMETER_TYPE_Int , 3.0, 0.0, true ); Parameters.Add_Value( NULL , "SHARK_BIRTH" , _TL("Birth Rate of Sharks"), _TL(""), PARAMETER_TYPE_Int , 12.0, 0.0, true ); Parameters.Add_Value( NULL , "SHARK_STARVE" , _TL("Max. Starvation Time for Sharks"), _TL(""), PARAMETER_TYPE_Int , 4.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CWator::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Grid_Target.On_Parameters_Enable(pParameters, pParameter); return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWator::On_Execute(void) { //----------------------------------------------------- m_pWator = m_Grid_Target.Get_Grid("GRID", SG_DATATYPE_Byte); if( !m_pWator ) { Error_Set(_TL("could not create target grid")); return( false ); } //----------------------------------------------------- m_pWator->Set_Name(_TL("Wa-Tor")); m_pWator->Set_NoData_Value(-1); CSG_Colors Colors(3); Colors.Set_Color(0, SG_COLOR_BLACK); Colors.Set_Color(1, SG_COLOR_GREEN); Colors.Set_Color(2, SG_COLOR_RED ); DataObject_Add (m_pWator); DataObject_Set_Colors(m_pWator, Colors); DataObject_Update (m_pWator, 0, 2, SG_UI_DATAOBJECT_SHOW); //----------------------------------------------------- if( Parameters("REFRESH")->asBool() ) { double Fish_perc = Parameters("INIT_FISH" )->asDouble(); double Shark_perc = Parameters("INIT_SHARK")->asDouble() + Fish_perc; #pragma omp parallel for for(int y=0; yGet_NY(); y++) { for(int x=0; xGet_NX(); x++) { double perc = CSG_Random::Get_Uniform(0, 100); if( perc <= Fish_perc ) { m_pWator->Set_Value(x, y, FISH); } else if( perc <= Shark_perc ) { m_pWator->Set_Value(x, y, SHARK); } else { m_pWator->Set_Value(x, y, 0); } } } } //----------------------------------------------------- CSG_Table *pTable = Parameters("TABLE")->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("Wa-Tor")); pTable->Add_Field("Cycle" , SG_DATATYPE_Int); pTable->Add_Field("Fishes", SG_DATATYPE_Int); pTable->Add_Field("Sharks", SG_DATATYPE_Int); //----------------------------------------------------- m_Fish_Birth = Parameters("FISH_BIRTH" )->asInt(); m_Shark_Birth = Parameters("SHARK_BIRTH" )->asInt(); m_Shark_Starve = Parameters("SHARK_STARVE")->asInt(); m_Next .Create(m_pWator, SG_DATATYPE_Byte); m_Age .Create(m_pWator, SG_DATATYPE_Byte); m_Starve.Create(m_pWator, SG_DATATYPE_Byte); #pragma omp parallel for for(int y=0; yGet_NY(); y++) { for(int x=0; xGet_NX(); x++) { switch( m_pWator->asByte(x, y) ) { case FISH: m_Age .Set_Value(x, y, CSG_Random::Get_Uniform(0.0, m_Fish_Birth )); break; case SHARK: m_Age .Set_Value(x, y, CSG_Random::Get_Uniform(0.0, m_Shark_Birth )); m_Starve.Set_Value(x, y, CSG_Random::Get_Uniform(0.0, m_Shark_Starve)); break; } } } //----------------------------------------------------- int i; SG_UI_Progress_Lock(true); for(i=1; Process_Get_Okay(true) && Next_Cycle(); i++) { Process_Set_Text(CSG_String::Format("%s: %d", _TL("Life Cycle"), i)); CSG_Table_Record *pRecord = pTable->Add_Record(); pRecord->Set_Value(0, i); pRecord->Set_Value(1, m_nFishes); pRecord->Set_Value(2, m_nSharks); DataObject_Update(m_pWator, 0, 2); DataObject_Update(pTable); } SG_UI_Progress_Lock(false); //----------------------------------------------------- m_Next .Destroy(); m_Age .Destroy(); m_Starve.Destroy(); if( is_Progress() ) { Message_Add(CSG_String::Format("%s %d %s", _TL("Dead after"), i, _TL("Life Cycles"))); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_NEIGHBOR { ix = m_pWator->Get_System().Get_xTo(i, x); if( ix < 0 ) ix = m_pWator->Get_NX() - 1; else if( ix >= m_pWator->Get_NX() ) ix = 0;\ iy = m_pWator->Get_System().Get_yTo(i, y); if( iy < 0 ) iy = m_pWator->Get_NY() - 1; else if( iy >= m_pWator->Get_NY() ) iy = 0; } #define GET_NEIGHBOR_RANDOMLY { i = iNeighbor[(int)((double)rand() * nNeighbors / (double)RAND_MAX)];\ ix = m_pWator->Get_System().Get_xTo(i, x); if( ix < 0 ) ix = m_pWator->Get_NX() - 1; else if( ix >= m_pWator->Get_NX() ) ix = 0;\ iy = m_pWator->Get_System().Get_yTo(i, y); if( iy < 0 ) iy = m_pWator->Get_NY() - 1; else if( iy >= m_pWator->Get_NY() ) iy = 0; } //--------------------------------------------------------- bool CWator::Next_Cycle(void) { static int iDir = 0; int x, y, i, ix, iy, xx, yy, ax, ay, dx, dy, iNeighbor[8], nNeighbors, Age, Starve; //----------------------------------------------------- m_nFishes = 0; m_nSharks = 0; m_Next.Assign(0.0); switch( iDir ) { default: ay = m_pWator->Get_NY() - 1; dy = -1; ax = m_pWator->Get_NX() - 1; dx = -1; iDir=0; break; case 2: ay = 0; dy = 1; ax = m_pWator->Get_NX() - 1; dx = -1; iDir++; break; case 1: ay = m_pWator->Get_NY() - 1; dy = -1; ax = 0; dx = 1; iDir++; break; case 0: ay = 0; dy = 1; ax = 0; dx = 1; iDir++; break; } //----------------------------------------------------- for(yy=0, y=ay; yyGet_NY(); yy++, y+=dy) { for(xx=0, x=ax; xxGet_NX(); xx++, x+=dx) { if( m_pWator->asByte(x, y) == FISH ) { m_nFishes++; Age = m_Age.asInt(x, y) + 1; m_Age.Set_Value(x, y, 0); for(i=0, nNeighbors=0; i<8; i++) { GET_NEIGHBOR; if( m_pWator->asByte(ix, iy) == 0 && m_Next.asByte(ix, iy) == 0 ) { iNeighbor[nNeighbors++] = i; } } if( nNeighbors > 0 ) { GET_NEIGHBOR_RANDOMLY; m_Next.Set_Value(ix, iy, FISH); m_Age .Set_Value(ix, iy, Age >= m_Fish_Birth ? 0 : Age); if( Age >= m_Fish_Birth ) { m_Next.Set_Value(x, y, FISH); m_Age .Set_Value(x, y, CSG_Random::Get_Uniform(0, m_Fish_Birth)); } else { m_pWator->Set_Value(x, y, 0); } } else { m_Next.Set_Value(x, y, FISH); m_Age .Set_Value(x, y, Age >= m_Fish_Birth ? 0 : m_Fish_Birth); } } } } //----------------------------------------------------- for(yy=0, y=ay; yyGet_NY(); yy++, y+=dy) { for(xx=0, x=ax; xxGet_NX(); xx++, x+=dx) { if( m_pWator->asByte(x, y) == SHARK ) { m_nSharks++; Age = m_Age.asInt(x, y) + 1; m_Age.Set_Value(x, y, 0); Starve = m_Starve.asInt(x, y) + 1; m_Starve.Set_Value(x, y, 0); for(i=0, nNeighbors=0; i<8; i++) { GET_NEIGHBOR; if( m_Next.asByte(ix, iy) == FISH ) { iNeighbor[nNeighbors++] = i; } } if( nNeighbors > 0 ) { GET_NEIGHBOR_RANDOMLY; m_nFishes--; m_pWator->Set_Value(ix, iy, 0); m_Next .Set_Value(ix, iy, SHARK); m_Age .Set_Value(ix, iy, Age >= m_Shark_Birth ? 0 : Age); m_Starve .Set_Value(ix, iy, 0); if( Age >= m_Shark_Birth ) { m_Next .Set_Value(x, y, SHARK); m_Age .Set_Value(x, y, CSG_Random::Get_Uniform(0, m_Shark_Birth)); m_Starve .Set_Value(x, y, 0); } else { m_pWator->Set_Value(x, y, 0); } } else if( Starve <= m_Shark_Starve ) { for(i=0, nNeighbors=0; i<8; i++) { GET_NEIGHBOR; if( m_pWator->asByte(ix, iy) == 0 && m_Next.asByte(ix, iy) == 0 ) { iNeighbor[nNeighbors++] = i; } } if( nNeighbors > 0 ) { GET_NEIGHBOR_RANDOMLY; m_Next .Set_Value(ix, iy, SHARK); m_Age .Set_Value(ix, iy, Age >= m_Shark_Birth ? 0 : Age); m_Starve.Set_Value(ix, iy, Starve); if( Age >= m_Shark_Birth ) { m_Next .Set_Value(x, y, SHARK); m_Age .Set_Value(x, y, CSG_Random::Get_Uniform(0, m_Shark_Birth)); m_Starve .Set_Value(x, y, Starve); } else { m_pWator ->Set_Value( x, y, 0); } } else { m_Next .Set_Value(x, y, SHARK); m_Age .Set_Value(x, y, Age >= m_Shark_Birth ? 0 : m_Shark_Birth); m_Starve.Set_Value(x, y, Starve); } } else { m_nSharks--; } } } } //----------------------------------------------------- #pragma omp parallel for private(x, y) for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { m_pWator->Set_Value(x, y, m_Next.asByte(x, y)); } } return( (m_nFishes > 0 && m_nFishes < m_pWator->Get_NCells()) || m_nSharks > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_cellular_automata/Life.cpp0000744000175000017500000002031412737416206026151 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Life.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // Life.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Life.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLife::CLife(void) { //----------------------------------------------------- Set_Name (_TL("Conway's Game of Life")); Set_Author ("O.Conrad (c) 2003"); Set_Description (_TW( "Conway's Game of Life - a classical cellular automat.\n" "\n" "Reference:\n" "- Eigen, M., Winkler, R. (1985): " "'Das Spiel - Naturgesetze steuern den Zufall', " "Muenchen, 404p.\n" )); //----------------------------------------------------- m_Grid_Target.Create(&Parameters, false, NULL, "TARGET_"); m_Grid_Target.Add_Grid("LIFE", _TL("Life"), false); //----------------------------------------------------- Parameters.Add_Value( NULL , "FADECOLOR" , _TL("Fade Color Count"), _TL(""), PARAMETER_TYPE_Int, 64, 1, true, 255, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CLife::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { m_Grid_Target.On_Parameters_Enable(pParameters, pParameter); return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLife::On_Execute(void) { //----------------------------------------------------- m_pLife = m_Grid_Target.Get_Grid("LIFE", SG_DATATYPE_Byte); if( !m_pLife ) { Error_Set(_TL("could not create target grid")); return( false ); } //----------------------------------------------------- m_nColors = Parameters("FADECOLOR")->asInt(); for(int y=0; yGet_NY(); y++) { for(int x=0; xGet_NX(); x++) { m_pLife->Set_Value(x, y, CSG_Random::Get_Uniform(0, 100) < 50 ? 0 : m_nColors); } } //----------------------------------------------------- m_pLife->Set_Name(_TL("Conway's Game of Life")); m_pLife->Set_NoData_Value(-1); DataObject_Add (m_pLife); DataObject_Set_Colors(m_pLife, 11, SG_COLORS_WHITE_BLUE); DataObject_Update (m_pLife, 0, m_nColors, SG_UI_DATAOBJECT_SHOW); //----------------------------------------------------- int i; m_Count.Create(m_pLife->Get_System(), SG_DATATYPE_Byte); for(i=1; Process_Get_Okay(true) && Next_Cycle(i > m_nColors); i++) { Process_Set_Text(CSG_String::Format("%s: %d", _TL("Life Cycle"), i)); DataObject_Update(m_pLife, 0, m_nColors); } m_Count.Destroy(); //----------------------------------------------------- if( is_Progress() ) { Message_Add(CSG_String::Format("\n%s %d %s\n", _TL("Dead after"), i, _TL("Life Cycles")), false); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLife::Next_Cycle(bool bCheck4Change) { //----------------------------------------------------- bool bContinue = bCheck4Change ? false : true; int y; //----------------------------------------------------- #pragma omp parallel for private(y) for(y=0; yGet_NY(); y++) { for(int x=0; xGet_NX(); x++) { int n = 0; for(int i=0; i<8; i++) { int ix = CSG_Grid_System::Get_xTo(i, x);; int iy = CSG_Grid_System::Get_yTo(i, y);; if( ix < 0 ) ix = m_pLife->Get_NX() - 1; else if( ix >= m_pLife->Get_NX() ) ix = 0; if( iy < 0 ) iy = m_pLife->Get_NY() - 1; else if( iy >= m_pLife->Get_NY() ) iy = 0; if( m_pLife->asByte(ix, iy) == m_nColors ) { n++; } } m_Count.Set_Value(x, y, n); if( bCheck4Change && m_pLife->asByte(x, y) > 0 && m_pLife->asByte(x, y) < m_nColors - 1 ) { bContinue = true; } } } //----------------------------------------------------- #pragma omp parallel for private(y) for(y=0; yGet_NY(); y++) { for(int x=0; xGet_NX(); x++) { int n = m_Count.asByte(x, y); switch( n ) { case 2: // keep status if( m_pLife->asByte(x, y) > 0 && m_pLife->asByte(x, y) < m_nColors ) { m_pLife->Add_Value(x, y, -1); } break; case 3: // birth { m_pLife->Set_Value(x, y, m_nColors); } break; default: // death if( m_pLife->asByte(x, y) > 0 ) { m_pLife->Add_Value(x, y, -1); } } } } //----------------------------------------------------- return( bContinue ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_cellular_automata/Wator.h0000744000175000017500000001124512737416206026036 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Wator.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // Wator.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Wator_H #define HEADER_INCLUDED__Wator_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWator : public CSG_Module { public: CWator(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_Fish_Birth, m_Shark_Birth, m_Shark_Starve; sLong m_nFishes, m_nSharks; CSG_Parameters_Grid_Target m_Grid_Target; CSG_Grid *m_pWator, m_Next, m_Age, m_Starve; bool Next_Cycle (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Wator_H saga-2.3.1/src/modules/simulation/sim_cellular_automata/Makefile.in0000664000175000017500000005557212737447617026664 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/simulation/sim_cellular_automata ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_cellular_automata_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_cellular_automata_la_OBJECTS = Life.lo MLB_Interface.lo \ Wator.lo libsim_cellular_automata_la_OBJECTS = \ $(am_libsim_cellular_automata_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_cellular_automata_la_SOURCES) DIST_SOURCES = $(libsim_cellular_automata_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_cellular_automata.la libsim_cellular_automata_la_SOURCES = \ Life.cpp\ MLB_Interface.cpp\ Wator.cpp\ Life.h\ MLB_Interface.h\ Wator.h libsim_cellular_automata_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/simulation/sim_cellular_automata/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_cellular_automata/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_cellular_automata.la: $(libsim_cellular_automata_la_OBJECTS) $(libsim_cellular_automata_la_DEPENDENCIES) $(EXTRA_libsim_cellular_automata_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_cellular_automata_la_OBJECTS) $(libsim_cellular_automata_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Life.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Wator.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/simulation/sim_cellular_automata/Makefile.am0000744000175000017500000000114212737416206026620 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_cellular_automata.la libsim_cellular_automata_la_SOURCES =\ Life.cpp\ MLB_Interface.cpp\ Wator.cpp\ Life.h\ MLB_Interface.h\ Wator.h libsim_cellular_automata_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/simulation/sim_cellular_automata/MLB_Interface.h0000744000175000017500000001001112737416206027322 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__sim_cellular_automata_H #define HEADER_INCLUDED__sim_cellular_automata_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef sim_cellular_automata_EXPORTS #define sim_cellular_automata_EXPORT _SAGA_DLL_EXPORT #else #define sim_cellular_automata_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__sim_cellular_automata_H saga-2.3.1/src/modules/simulation/sim_cellular_automata/MLB_Interface.cpp0000744000175000017500000001162612737416206027672 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Cellular Automata") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2002") ); case MLB_INFO_Description: return( _TL("Cellular Automata") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Cellular Automata") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Life.h" #include "Wator.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { // Don't forget to continuously enumerate the case switches // when adding new modules! Also bear in mind that the // enumeration always has to start with [case 0:] and // that [default:] must return NULL!... CSG_Module *pModule; switch( i ) { case 0: pModule = new CLife; break; case 1: pModule = new CWator; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/simulation/sim_cellular_automata/Life.h0000744000175000017500000001112712737416206025620 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Life.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Cellular_Automata // // // //-------------------------------------------------------// // // // Life.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__LIFE_H #define HEADER_INCLUDED__LIFE_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLife : public CSG_Module { public: CLife(void); virtual bool needs_GUI (void) { return( true ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_nColors; CSG_Parameters_Grid_Target m_Grid_Target; CSG_Grid *m_pLife, m_Count; bool Next_Cycle (bool bCheck4Change); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__LIFE_H saga-2.3.1/src/modules/simulation/sim_fire_spreading/0000775000175000017500000000000012737740007024051 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/simulation/sim_fire_spreading/Forecasting.cpp0000744000175000017500000004173012737416206027026 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Forecasting.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Forecasting.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ //#include "../../../modules/grid/grid_tools/Grid_Gaps.h" #include "Forecasting.h" #include #define MS2FTMIN (60.0 / 0.3048) #define FTMIN2MMIN 0.3048 #define MIN_RATIO_BURNT_AREA 2. CForecasting::CForecasting(void){ Set_Name (_TL("Fire Risk Analysis")); Set_Author (SG_T("(c) 2004 Victor Olaya")); Set_Description (_TW( "Fire risk analysis based on the BEHAVE fire modeling system " "supported by the U.S. Forest Service, Fire and Aviation Management. " "Find more information on BEHAVE at the Public Domain Software for the Wildland Fire Community at " "http://fire.org\n" "\n" "Reference:\n" "Andrews, P.L. (1986): BEHAVE: Fire Behavior Prediction and Fuel Modeling System - " "Burn Subsystem, Part 1. U.S. Department of Agriculture, Forest Service General, Technical Report INT-194. " )); Parameters.Add_Grid(NULL, "DEM", _TL("DEM"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "FUEL", _TL("Fuel Model"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "WINDSPD", _TL("Wind Speed"), _TL("Wind Speed (m/s)"), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "WINDDIR", _TL("Wind Direction"), _TL("Wind Direction (degrees clockwise from north)"), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "M1H", _TL("Dead Fuel Moisture 1H"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "M10H", _TL("Dead Fuel Moisture 10H"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "M100H", _TL("Dead Fuel Moisture 100H"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "MHERB", _TL("Herbaceous Fuel Moisture"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "MWOOD", _TL("Wood Fuel Moisture"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "VALUE", _TL("Value"), _TL(""), PARAMETER_INPUT_OPTIONAL); Parameters.Add_Grid(NULL, "BASEPROB", _TL("Base Probability"), _TL(""), PARAMETER_INPUT_OPTIONAL); Parameters.Add_Grid(NULL, "DANGER", _TL("Danger"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "COMPPROB", _TL("Compound Probability"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "PRIORITY", _TL("Priority Index"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "MONTECARLO", _TL("Number of Events"), _TL("N\xc3\xbamero of Monte-Carlo events"), PARAMETER_TYPE_Int, 1000, 1., true); Parameters.Add_Value(NULL, "INTERVAL", _TL("Fire Length"), _TL("Fire Length (min)"), PARAMETER_TYPE_Double, 100, 1., true); }//constructor CForecasting::~CForecasting(void) { }//destructor bool CForecasting::On_Execute(void){ AssignParameters(); CalculateGrids(); delete m_pSlopeGrid; delete m_pAspectGrid; return true; }//method bool CForecasting::AssignParameters(){ int x,y; m_pDEM = Parameters("DEM")->asGrid(); m_pFuelGrid = Parameters("FUEL")->asGrid(); m_pWindDirGrid = Parameters("WINDDIR")->asGrid(); m_pWindSpdGrid = Parameters("WINDSPD")->asGrid(); m_pM1Grid = Parameters("M1H")->asGrid(); m_pM10Grid = Parameters("M10H")->asGrid(); m_pM100Grid = Parameters("M100H")->asGrid(); m_pMHerbGrid = Parameters("MHERB")->asGrid(); m_pMWoodGrid = Parameters("MWOOD")->asGrid(); m_pDangerGrid = Parameters("DANGER")->asGrid(); m_pValueGrid = Parameters("VALUE")->asGrid(); m_pBaseProbabilityGrid = Parameters("BASEPROB")->asGrid(); m_pCompoundProbabilityGrid = Parameters("COMPPROB")->asGrid(); m_pPriorityIndexGrid = Parameters("PRIORITY")->asGrid(); m_iInterval = Parameters("INTERVAL")->asInt(); m_iNumEvents = Parameters("MONTECARLO")->asInt(); /* create a standard fuel model catalog and a flame length table. */ m_Catalog = Fire_FuelCatalogCreateStandard("Standard", 13); Fire_FlameLengthTable(m_Catalog, 500, 0.1); if (!m_pBaseProbabilityGrid){ m_pBaseProbabilityGrid = SG_Create_Grid(m_pDEM, SG_DATATYPE_Double); m_pBaseProbabilityGrid->Assign(1); }//if if (!m_pValueGrid){ m_pValueGrid = SG_Create_Grid(m_pDEM, SG_DATATYPE_Double); m_pValueGrid->Assign(1); }//if //substitute no-data values for(y=0; yis_NoData(x, y)){ m_pWindSpdGrid->Set_Value(x, y, 0.); }//if if (m_pWindDirGrid->is_NoData(x, y)){ m_pWindDirGrid->Set_Value(x, y, 0.); }//if if (m_pM1Grid->is_NoData(x, y)){ m_pM1Grid->Set_Value(x, y, 0.); }//if if (m_pM10Grid->is_NoData(x, y)){ m_pM10Grid->Set_Value(x, y, 0.); }//if if (m_pM100Grid->is_NoData(x, y)){ m_pM100Grid->Set_Value(x, y, 0.); }//if if (m_pMHerbGrid->is_NoData(x, y)){ m_pMHerbGrid->Set_Value(x, y, 0.); }//if if (m_pMWoodGrid->is_NoData(x, y)){ m_pMWoodGrid->Set_Value(x, y, 0.); }//if if (m_pBaseProbabilityGrid->is_NoData(x, y)){ m_pBaseProbabilityGrid->Set_Value(x, y, 0.); }//if }//for }//for //----------------------------------------------------- // calculate slope and aspect using CSG_Grid class' // built-in function (after Zevenbergen & Thorne)... m_pSlopeGrid = SG_Create_Grid(m_pDEM, SG_DATATYPE_Double); m_pAspectGrid = SG_Create_Grid(m_pDEM, SG_DATATYPE_Double); for(y=0; yGet_Gradient(x, y, slope, aspect) ) { m_pSlopeGrid ->Set_Value(x, y, slope); m_pAspectGrid ->Set_Value(x, y, aspect); } else { m_pSlopeGrid ->Set_NoData(x, y); m_pAspectGrid ->Set_NoData(x, y); } } } //----------------------------------------------------- m_pTimeGrid = SG_Create_Grid(m_pDEM, SG_DATATYPE_Double); m_pTimeGrid->Assign((double)0); m_pDangerGrid->Assign((double)0); m_pCompoundProbabilityGrid->Assign((double)0); //m_pPriorityIndexGrid = Get_SafeNew_Grid(m_pDEM, SG_DATATYPE_Double); return true; }//method void CForecasting::CalculateGrids(){ int x,y; int i; int iRecommendedNumFires; double dDanger; double dTotalBurntArea = 0; CSG_String sMessage; m_CentralPoints .Clear(); m_AdjPoints .Clear(); srand((unsigned int)time(NULL)); Process_Set_Text(_TL("Calculating danger...")); for(i=0; iGet_NX()-1); y = rand() % (m_pDEM->Get_NY()-1); m_CentralPoints.Clear(); m_CentralPoints.Add(x,y); m_pTimeGrid->Set_Value(x,y,0.0); dDanger = CalculateFireSpreading(); dTotalBurntArea += dDanger; m_pDangerGrid->Set_Value(x, y, dDanger); }//for m_CentralPoints .Clear(); m_AdjPoints .Clear(); m_pDangerGrid->Set_NoData_Value(0.0); m_pDangerGrid->Set_Unit(_TL("m2/h")); Process_Set_Text(_TL("Closing Gaps...")); if( !Gaps_Close(m_pDangerGrid) ) { return; }//if for (y=0; ySet_Value(x,y, m_pCompoundProbabilityGrid->asFloat(x,y) / (float)m_iNumEvents); m_pPriorityIndexGrid->Set_Value(x, y, m_pCompoundProbabilityGrid->asFloat(x,y)* m_pDangerGrid->asFloat(x,y)); }//for }//for float dRatio = (float)(dTotalBurntArea / (m_pDEM->Get_Cellsize() * m_pDEM->Get_Cellsize())); if (dRatio < MIN_RATIO_BURNT_AREA){ iRecommendedNumFires =(int)((float) m_iNumEvents / dRatio * (float) MIN_RATIO_BURNT_AREA); sMessage.Printf( _TL("** Warning : Number of events might not be representative.\nMinimum number recommended: ") ); sMessage += SG_Get_String(iRecommendedNumFires, 0); sMessage += SG_T("\n"); Message_Add(sMessage.c_str()); }//if }//method double CForecasting::CalculateFireSpreading(){ int x,y; int x2,y2; int n; bool bReturn = false; /* neighbor's address*/ /* N NE E SE S SW W NW */ static int nX[8] = { 0, 1, 1, 1, 0, -1, -1, -1}; static int nY[8] = { 1, 1, 0, -1, -1, -1, 0, 1}; double nDist[8]; /* distance to each neighbor */ double nAzm[8]; /* compass azimuth to each neighbor (0=N) */ size_t modelNumber; /* fuel model number at current cell */ double moisture[6]; /* fuel moisture content at current cell */ double dSpreadRate; /* spread rate in direction of neighbor */ double dSpreadTime; /* time to spread from cell to neighbor */ double dIgnTime; /* time neighbor is ignited by current cell */ double dWindSpd; double dBurntValue = 0; double dProbability; m_pTimeGrid->Assign(0.0); for (n=0; n<8; n++){ nDist[n] = sqrt ( nX[n] * m_pDEM->Get_Cellsize() * nX[n] * m_pDEM->Get_Cellsize() + nY[n] * m_pDEM->Get_Cellsize() * nY[n] * m_pDEM->Get_Cellsize() ); nAzm[n] = n * 45.; }//for x = m_CentralPoints.Get_X(0); y = m_CentralPoints.Get_Y(0); dProbability = (float)(rand()) / (float)(RAND_MAX); if (m_pBaseProbabilityGrid->asFloat(x,y) < dProbability){ return 0; }//if while (m_CentralPoints.Get_Count()!=0){ for (int iPt=0; iPtis_NoData(x,y) && !m_pFuelGrid->is_NoData(x,y)){ modelNumber = (size_t) m_pFuelGrid->asInt(x, y); moisture[0] = m_pM1Grid->asFloat(x, y); moisture[1] = m_pM10Grid->asFloat(x, y); moisture[2] = m_pM100Grid->asFloat(x, y); moisture[3] = m_pM100Grid->asFloat(x, y); moisture[4] = m_pMHerbGrid->asFloat(x, y);; moisture[5] = m_pMWoodGrid->asFloat(x, y); dWindSpd = m_pWindSpdGrid->asFloat(x,y) * MS2FTMIN; Fire_SpreadNoWindNoSlope(m_Catalog, modelNumber, moisture); Fire_SpreadWindSlopeMax(m_Catalog, modelNumber, dWindSpd, m_pWindDirGrid->asFloat(x,y), tan(m_pSlopeGrid->asFloat(x,y)), m_pAspectGrid->asFloat(x,y)); for (n=0; n<8; n++){ x2 = x + nX[n]; y2 = y + nY[n]; if (m_pTimeGrid->is_InGrid(x2,y2,false)){ Fire_SpreadAtAzimuth(m_Catalog, modelNumber, nAzm[n], FIRE_NONE); dSpreadRate = Fuel_SpreadAny(m_Catalog, modelNumber); // in ft/min (awkward...) dSpreadRate *= FTMIN2MMIN; //a bit better... if (dSpreadRate > Smidgen){ dSpreadTime = nDist[n] / dSpreadRate; dIgnTime = m_pTimeGrid->asDouble(x,y) + dSpreadTime; if (dIgnTime < m_iInterval){ if (m_pTimeGrid->asDouble(x2,y2) == 0.0 || m_pTimeGrid->asDouble(x2, y2)>dIgnTime){ if (m_pTimeGrid->asDouble(x2, y2)==0.0){ dBurntValue += m_pValueGrid->asDouble(x2, y2); m_pCompoundProbabilityGrid->Set_Value(x2,y2, m_pCompoundProbabilityGrid->asFloat(x2,y2) + 1); }//if m_pTimeGrid->Set_Value(x2, y2, dIgnTime); m_AdjPoints.Add(x2,y2); }//if }//if }//if }//if }//for }//if }//for m_CentralPoints.Clear(); for (int i=0; iAssign(pResult); //----------------------------------------------------- Threshold = 0.1; n = Get_NX() > Get_NY() ? Get_NX() : Get_NY(); iStep = 0; do { iStep++; } while( pow(2.0, iStep + 1) < n ); iStart = (int)pow(2.0, iStep); pTension_Keep = new CSG_Grid(pResult, SG_DATATYPE_Byte); pTension_Temp = new CSG_Grid(pResult); pResult->Assign_NoData(); for(iStep=iStart; iStep>=1; iStep/=2) { Gaps_Tension_Init(iStep, pTension_Temp, pTension_Keep, pResult, pInput); do { max = Gaps_Tension_Step(iStep, pTension_Temp, pTension_Keep, pResult); } while( max > Threshold && Process_Get_Okay(true) ); } //----------------------------------------------------- delete(pTension_Keep); delete(pTension_Temp); delete(pInput); return( true ); } //--------------------------------------------------------- void CForecasting::Gaps_Tension_Init(int iStep, CSG_Grid *pTension_Temp, CSG_Grid *pTension_Keep, CSG_Grid *pResult, CSG_Grid *pInput) { int x, y, i, ix, iy, nx, ny, nz; double z; //----------------------------------------------------- // 1. Channels... pTension_Temp->Assign_NoData(); pTension_Keep->Assign(); for(y=0; yis_NoData(x, y) ) { pTension_Temp->Set_Value(x, y, pInput->asDouble(x, y) ); pTension_Keep->Set_Value(x, y, 1.0); } else { nx = x + iStep < Get_NX() ? x + iStep : Get_NX(); nz = 0; z = 0.0; for(iy=y; iyis_InGrid(ix, iy) ) { z += pInput->asDouble(ix, iy); nz++; } } } if( nz > 0 ) { pTension_Temp->Set_Value(x, y, z / (double)nz ); pTension_Keep->Set_Value(x, y, 1.0); } } } } //----------------------------------------------------- // 2. Previous Iteration... for(y=0; yasByte(x, y) == false ) { if( !pResult->is_NoData(x, y) ) { pTension_Temp->Set_Value(x, y, pResult->asDouble(x, y)); } else { nz = 0; z = 0.0; for(i=0; i<8; i++) { ix = x + iStep * Get_System()->Get_xTo(i); iy = y + iStep * Get_System()->Get_yTo(i); if( pResult->is_InGrid(ix, iy) ) { z += pResult->asDouble(ix, iy); nz++; } } if( nz > 0.0 ) { pTension_Temp->Set_Value(x, y, z / (double)nz); } else { pTension_Temp->Set_Value(x, y, pInput->asDouble(x, y)); } } } } } //----------------------------------------------------- // 3. ... pResult->Assign(pTension_Temp); } //--------------------------------------------------------- double CForecasting::Gaps_Tension_Step(int iStep, CSG_Grid *pTension_Temp, CSG_Grid *pTension_Keep, CSG_Grid *pResult) { int x, y; double d, dMax; dMax = 0.0; for(y=0; yasByte(x, y) == false ) { d = Gaps_Tension_Change(x, y, iStep, pResult); pTension_Temp->Set_Value(x, y, d); d = fabs(d - pResult->asDouble(x, y)); if( d > dMax ) { dMax = d; } } } } for(y=0; yasByte(x, y) == false ) { pResult->Set_Value(x, y, pTension_Temp->asDouble(x, y)); } } } return( dMax ); } //--------------------------------------------------------- double CForecasting::Gaps_Tension_Change(int x, int y, int iStep, CSG_Grid *pResult) { int i, ix, iy; double n, d, dz; for(i=0, d=0.0, n=0.0; i<8; i++) { ix = x + iStep * Get_System()->Get_xTo(i); iy = y + iStep * Get_System()->Get_yTo(i); if( pResult->is_InGrid(ix, iy) ) { dz = 1.0 / Get_System()->Get_UnitLength(i); d += dz * pResult->asDouble(ix, iy); n += dz; } } if( n > 0.0 ) { d /= n; return( d ); } return( pResult->asDouble(x, y) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_fire_spreading/Forecasting.h0000744000175000017500000000574612737416206026502 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Forecasting.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Forecasting.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" #include "fireLib.h" class CForecasting : public CSG_Module_Grid { private: CSG_Grid *m_pDEM; CSG_Grid *m_pWindSpdGrid; /* ptr to wind speed map (m/s) */ CSG_Grid *m_pWindDirGrid; /* ptr to wind direction map (deg from north) */ CSG_Grid *m_pM1Grid; /* ptr to 1-hr dead fuel moisture map */ CSG_Grid *m_pM10Grid; /* ptr to 10-hr dead fuel moisture map */ CSG_Grid *m_pM100Grid; /* ptr to 100-hr dead fuel moisture map */ CSG_Grid *m_pMHerbGrid; /* ptr to live herbaceous fuel moisture map */ CSG_Grid *m_pMWoodGrid; /* ptr to live stem fuel moisture map */ CSG_Grid *m_pFuelGrid; /* ptr to fuel model map */ CSG_Grid *m_pValueGrid; /* ptr to cell value map */ CSG_Grid *m_pDangerGrid; /* ptr to danger map (in burnt m2 / h) */ CSG_Grid *m_pBaseProbabilityGrid; CSG_Grid *m_pCompoundProbabilityGrid; CSG_Grid *m_pPriorityIndexGrid; CSG_Grid *m_pSlopeGrid; /* ptr to slope map (rise/reach) */ CSG_Grid *m_pAspectGrid; /* ptr to aspect map (degrees from north) */ CSG_Grid *m_pTimeGrid; FuelCatalogPtr m_Catalog; /* fuel catalog handle */ CSG_Points_Int m_CentralPoints; CSG_Points_Int m_AdjPoints; int m_iInterval; int m_iNumEvents; bool AssignParameters(); void CalculateGrids(); double CalculateFireSpreading(); bool Gaps_Close (CSG_Grid *pInput); void Gaps_Tension_Init (int iStep, CSG_Grid *pTension_Temp, CSG_Grid *pTension_Keep, CSG_Grid *pResult, CSG_Grid *pInput); double Gaps_Tension_Step (int iStep, CSG_Grid *pTension_Temp, CSG_Grid *pTension_Keep, CSG_Grid *pResult); double Gaps_Tension_Change (int x, int y, int iStep, CSG_Grid *pResult); public: CForecasting(void); virtual ~CForecasting(void); protected: virtual bool On_Execute(void); }; saga-2.3.1/src/modules/simulation/sim_fire_spreading/Makefile.in0000664000175000017500000006076612737447617026150 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/simulation/sim_fire_spreading ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_fire_spreading_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_fire_spreading_la_OBJECTS = fireLib.lo Forecasting.lo \ MLB_Interface.lo Simulate.lo libsim_fire_spreading_la_OBJECTS = \ $(am_libsim_fire_spreading_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(libsim_fire_spreading_la_SOURCES) DIST_SOURCES = $(libsim_fire_spreading_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core -I$(top_srcdir)/src/modules/grid/grid_tools AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_fire_spreading.la libsim_fire_spreading_la_SOURCES = \ fireLib.c\ Forecasting.cpp\ MLB_Interface.cpp\ Simulate.cpp\ fireLib.h\ Forecasting.h\ MLB_Interface.h\ Simulate.h libsim_fire_spreading_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .c .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/simulation/sim_fire_spreading/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_fire_spreading/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_fire_spreading.la: $(libsim_fire_spreading_la_OBJECTS) $(libsim_fire_spreading_la_DEPENDENCIES) $(EXTRA_libsim_fire_spreading_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_fire_spreading_la_OBJECTS) $(libsim_fire_spreading_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Forecasting.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Simulate.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fireLib.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/simulation/sim_fire_spreading/Simulate.cpp0000744000175000017500000002405512737416206026346 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Simulate.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Simulate.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "Simulate.h" #define MS2FTMIN (60.0 / 0.3048) #define FTMIN2MMIN 0.3048 #define BTU2KCAL 0.252164401 #define FT2M 0.3048 #define NO_TIME_LIMIT -1 #define THRESHOLD_FOR_DIFFERENCE 0.1 CSimulate::CSimulate(void){ Set_Name (_TL("Simulation")); Set_Author (SG_T("(c) 2004 Victor Olaya")); Set_Description (_TW( "Fire simulation based on the BEHAVE fire modeling system " "supported by the U.S. Forest Service, Fire and Aviation Management. " "Find more information on BEHAVE at the Public Domain Software for the Wildland Fire Community at " "http://fire.org\n" "\n" "Reference:\n" "Andrews, P.L. (1986): BEHAVE: Fire Behavior Prediction and Fuel Modeling System - " "Burn Subsystem, Part 1. U.S. Department of Agriculture, Forest Service General, Technical Report INT-194. " )); Parameters.Add_Grid(NULL, "DEM", _TL("DEM"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "FUEL", _TL("Fuel Model"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "WINDSPD", _TL("Wind Speed"), _TL("Wind speed (m/s)"), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "WINDDIR", _TL("Wind Direction"), _TL("Wind direction (degrees clockwise from north)"), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "M1H", _TL("Dead Fuel Moisture 1H"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "M10H", _TL("Dead Fuel Moisture 10H"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "M100H", _TL("Dead Fuel Moisture 100H"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "MHERB", _TL("Herbaceous Fuel Moisture"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "MWOOD", _TL("Wood Fuel Moisture"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "IGNITION", _TL("Ignition Points"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "TIME", _TL("Time"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "FLAME", _TL("Flame Length"), _TL("Flame Length (m)"), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "INTENSITY", _TL("Intensity"), _TL("Intensity (Kcal/m)"), PARAMETER_OUTPUT); Parameters.Add_Value(NULL, "UPDATEVIEW", _TL("Update View"), _TL("Update view during simulation."), PARAMETER_TYPE_Bool, true); }//constructor CSimulate::~CSimulate(void){} bool CSimulate::On_Execute(void){ AssignParameters(); CalculateFire(); DeleteObjects(); return true; }//method void CSimulate::DeleteObjects(){ delete m_pAspectGrid; delete m_pSlopeGrid; m_CentralPoints .Clear(); m_AdjPoints .Clear(); }//method bool CSimulate::AssignParameters(){ int x,y; m_pDEM = Parameters("DEM")->asGrid(); m_pFuelGrid = Parameters("FUEL")->asGrid(); m_pIgnGrid = Parameters("IGNITION")->asGrid(); m_pWindDirGrid = Parameters("WINDDIR")->asGrid(); m_pWindSpdGrid = Parameters("WINDSPD")->asGrid(); m_pM1Grid = Parameters("M1H")->asGrid(); m_pM10Grid = Parameters("M10H")->asGrid(); m_pM100Grid = Parameters("M100H")->asGrid(); m_pMHerbGrid = Parameters("MHERB")->asGrid(); m_pMWoodGrid = Parameters("MWOOD")->asGrid(); m_pTimeGrid = Parameters("TIME")->asGrid(); m_pFlameGrid = Parameters("FLAME")->asGrid(); m_pIntensityGrid = Parameters("INTENSITY")->asGrid(); m_Catalog = Fire_FuelCatalogCreateStandard("Standard", 13); Fire_FlameLengthTable(m_Catalog, 500, 0.1); //substitute no-data values for(y=0; yis_NoData(x, y)){ m_pWindSpdGrid->Set_Value(x, y, 0.); }//if if (m_pWindDirGrid->is_NoData(x, y)){ m_pWindDirGrid->Set_Value(x, y, 0.); }//if if (m_pM1Grid->is_NoData(x, y)){ m_pM1Grid->Set_Value(x, y, 0.); }//if if (m_pM10Grid->is_NoData(x, y)){ m_pM10Grid->Set_Value(x, y, 0.); }//if if (m_pM100Grid->is_NoData(x, y)){ m_pM100Grid->Set_Value(x, y, 0.); }//if if (m_pMHerbGrid->is_NoData(x, y)){ m_pMHerbGrid->Set_Value(x, y, 0.); }//if if (m_pMWoodGrid->is_NoData(x, y)){ m_pMWoodGrid->Set_Value(x, y, 0.); }//if }//for }//for //----------------------------------------------------- // calculate slope and aspect using CSG_Grid class' // built-in function (after Zevenbergen & Thorne)... m_pSlopeGrid = SG_Create_Grid(m_pDEM, SG_DATATYPE_Double); m_pAspectGrid = SG_Create_Grid(m_pDEM, SG_DATATYPE_Double); for(y=0; yGet_Gradient(x, y, slope, aspect) ) { m_pSlopeGrid ->Set_Value(x, y, slope); m_pAspectGrid ->Set_Value(x, y, aspect); } else { m_pSlopeGrid ->Set_NoData(x, y); m_pAspectGrid ->Set_NoData(x, y); } } } //----------------------------------------------------- m_pTimeGrid->Assign((double)0); return true; }//method void CSimulate::CalculateFire(){ int x,y; Process_Set_Text(_TL("Simulating...")); m_CentralPoints .Clear(); m_AdjPoints .Clear(); m_CentralPoints.Clear(); for(y=0; yis_NoData(x,y)){ m_CentralPoints.Add(x,y); m_pTimeGrid->Set_Value(x,y,0.0); }//if }//for }//for CalculateFireSpreading(NO_TIME_LIMIT); m_pTimeGrid->Set_NoData_Value(0.); }//method int CSimulate::CalculateFireSpreading(float fTimeLimit){ int x,y; int x2,y2; int n; bool bReturn = false; /* neighbor's address*/ /* N NE E SE S SW W NW */ static int nX[8] = { 0, 1, 1, 1, 0, -1, -1, -1}; static int nY[8] = { 1, 1, 0, -1, -1, -1, 0, 1}; double nDist[8]; /* distance to each neighbor */ double nAzm[8]; /* compass azimuth to each neighbor (0=N) */ size_t modelNumber; /* fuel model number at current cell */ double moisture[6]; /* fuel moisture content at current cell */ double dSpreadRate; /* spread rate in direction of neighbor */ double dSpreadTime; /* time to spread from cell to neighbor */ double dIgnTime; /* time neighbor is ignited by current cell */ double dWindSpd; int iBurntCells = 0; bool bUpdate = Parameters("UPDATEVIEW")->asBool(); for (n=0; n<8; n++){ nDist[n] = sqrt ( nX[n] * m_pDEM->Get_Cellsize() * nX[n] * m_pDEM->Get_Cellsize() + nY[n] * m_pDEM->Get_Cellsize() * nY[n] * m_pDEM->Get_Cellsize() ); nAzm[n] = n * 45.; }//for while (m_CentralPoints.Get_Count()!=0){ for (int iPt=0; iPtis_NoData(x,y) && !m_pFuelGrid->is_NoData(x,y)){ modelNumber = (size_t) m_pFuelGrid->asInt(x, y); moisture[0] = m_pM1Grid->asFloat(x, y); moisture[1] = m_pM10Grid->asFloat(x, y); moisture[2] = m_pM100Grid->asFloat(x, y); moisture[3] = m_pM100Grid->asFloat(x, y); moisture[4] = m_pMHerbGrid->asFloat(x, y);; moisture[5] = m_pMWoodGrid->asFloat(x, y); dWindSpd = m_pWindSpdGrid->asFloat(x,y) * MS2FTMIN; Fire_SpreadNoWindNoSlope(m_Catalog, modelNumber, moisture); Fire_SpreadWindSlopeMax(m_Catalog, modelNumber, dWindSpd, m_pWindDirGrid->asFloat(x,y), tan(m_pSlopeGrid->asFloat(x,y)), m_pAspectGrid->asFloat(x,y)); for (n=0; n<8; n++){ x2 = x + nX[n]; y2 = y + nY[n]; if (m_pTimeGrid->is_InGrid(x2,y2,false)){ Fire_SpreadAtAzimuth(m_Catalog, modelNumber, nAzm[n], FIRE_BYRAMS); dSpreadRate = Fuel_SpreadAny(m_Catalog, modelNumber); // in ft/min (awkward...) dSpreadRate *= FTMIN2MMIN; //a bit better... if (dSpreadRate > Smidgen){ dSpreadTime = nDist[n] / dSpreadRate; if (fTimeLimit == NO_TIME_LIMIT){ dIgnTime = m_pTimeGrid->asDouble(x,y) + dSpreadTime; if (m_pTimeGrid->asDouble(x2,y2) == 0.0 || m_pTimeGrid->asDouble(x2, y2) > dIgnTime + THRESHOLD_FOR_DIFFERENCE ){ m_pTimeGrid->Set_Value(x2, y2, dIgnTime); m_AdjPoints.Add(x2,y2); Fire_FlameScorch(m_Catalog, modelNumber, FIRE_FLAME); m_pFlameGrid->Set_Value(x2, y2, Fuel_FlameLength(m_Catalog, modelNumber) * FT2M); m_pIntensityGrid->Set_Value(x2, y2, Fuel_ByramsIntensity(m_Catalog, modelNumber) * BTU2KCAL / FT2M ); }//if }//if }//if }//if }//for }//if }//for m_CentralPoints.Clear(); for (int i=0; i 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" #include "fireLib.h" class CSimulate : public CSG_Module_Grid { private: CSG_Grid *m_pDEM; CSG_Grid *m_pIgnGrid; /* ptr to ignition time map (minutes) */ CSG_Grid *m_pWindSpdGrid; /* ptr to wind speed map (m/s) */ CSG_Grid *m_pWindDirGrid; /* ptr to wind direction map (deg from north) */ CSG_Grid *m_pM1Grid; /* ptr to 1-hr dead fuel moisture map */ CSG_Grid *m_pM10Grid; /* ptr to 10-hr dead fuel moisture map */ CSG_Grid *m_pM100Grid; /* ptr to 100-hr dead fuel moisture map */ CSG_Grid *m_pMHerbGrid; /* ptr to live herbaceous fuel moisture map */ CSG_Grid *m_pMWoodGrid; /* ptr to live stem fuel moisture map */ CSG_Grid *m_pFuelGrid; /* ptr to fuel model map */ CSG_Grid *m_pValueGrid; CSG_Grid *m_pFlameGrid; /* ptr to flame length map (m) */ CSG_Grid *m_pIntensityGrid; CSG_Grid *m_pSlopeGrid; /* ptr to slope map (rise/reach) */ CSG_Grid *m_pAspectGrid; /* ptr to aspect map (degrees from north) */ CSG_Grid *m_pTimeGrid; //CSG_Grid *m_pVolatileTimeGrid; FuelCatalogPtr m_Catalog; /* fuel catalog handle */ int m_iLength; CSG_Points_Int m_CentralPoints; CSG_Points_Int m_AdjPoints; int *m_pLength; int m_iMaxTime; //in s int m_iTimeInterval; //in s bool AssignParameters(); void CalculateFire(); int CalculateFireSpreading(float); void DeleteObjects(); public: CSimulate(void); virtual ~CSimulate(void); protected: virtual bool On_Execute(void); }; saga-2.3.1/src/modules/simulation/sim_fire_spreading/MLB_Interface.h0000744000175000017500000000713712737416206026624 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Terrain_Analysis // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // // e-mail: oconrad@saga-gis.org // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__MLB_INTERFACE_H #define HEADER_INCLUDED__MLB_INTERFACE_H //--------------------------------------------------------- #include //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__MLB_INTERFACE_H saga-2.3.1/src/modules/simulation/sim_fire_spreading/MLB_Interface.cpp0000744000175000017500000001100612737416206027145 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for an Automated Geo-Scientific Analysis // // // // Module Library: // // Fire_Spreading // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for an Automated // // Geo-Scientific Analysis'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: volaya@saga-gis.org // // // // contact: Victor Olaya // // Spain // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// #include "MLB_Interface.h" CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Fire Spreading Analysis") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("Victor Olaya (c) 2004") ); case MLB_INFO_Description: return( _TW( "Fire spreading analyses based on the BEHAVE fire modeling system " "supported by the U.S. Forest Service, Fire and Aviation Management. " "Find more information on BEHAVE at the Public Domain Software for the Wildland Fire Community at " "http://fire.org\n" "\n" "Reference:\n" "Andrews, P.L. (1986): BEHAVE: Fire Behavior Prediction and Fuel Modeling System - " "Burn Subsystem, Part 1. U.S. Department of Agriculture, Forest Service General, Technical Report INT-194. " )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Fire Spreading") ); } } #include "Simulate.h" #include "Forecasting.h" CSG_Module * Create_Module(int i) { CSG_Module *pModule; switch( i ) { case 0: pModule = new CForecasting; break; case 1: pModule = new CSimulate; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/simulation/sim_hydrology/0000775000175000017500000000000012737740007023110 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/simulation/sim_hydrology/idw.h0000744000175000017500000000263612737416207024054 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: idw.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* Isochrones.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include class CIDW { public: CIDW(); virtual ~CIDW(); void setParameters(CSG_Grid*,CSG_Shapes*,int); void Interpolate(); private: CSG_Grid* m_pGrid; CSG_Shapes *m_pPoints; int m_iField; bool Get_Grid_Value(int,int); }; saga-2.3.1/src/modules/simulation/sim_hydrology/diffuse_pollution_risk.h0000744000175000017500000001120412737416207030042 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: diffuse_pollution_risk.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // diffuse_pollution_risk.h // // // // Copyright (C) 2015 by // // Cosima Berger // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Cosima Berger // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__diffuse_pollution_risk_H #define HEADER_INCLUDED__diffuse_pollution_risk_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDiffuse_Pollution_Risk : public CSG_Module_Grid { public: CDiffuse_Pollution_Risk(void); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool m_bSingle; CSG_Grid *m_pDEM, m_FlowDir, m_RainAcc, m_TWI, *m_pDelivery, *m_pRisk_Point, *m_pRisk_Diffuse; bool Get_Flow_Proportions (int x, int y, double Proportion[8]); bool Set_Flow (void); bool Set_Flow (int x, int y, double Rain); bool Set_Delivery_Index (void); bool Get_Risk_Diffuse (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__diffuse_pollution_risk_H saga-2.3.1/src/modules/simulation/sim_hydrology/DVWK_SoilMoisture.h0000744000175000017500000001137412737416207026561 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: DVWK_SoilMoisture.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // DVWK_SoilMoisture.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__DVWK_SoilMoisture_H #define HEADER_INCLUDED__DVWK_SoilMoisture_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDVWK_SoilMoisture : public CSG_Module_Grid { public: CDVWK_SoilMoisture(void); virtual ~CDVWK_SoilMoisture(void); protected: virtual bool On_Execute (void); private: double FK_mm_Def, PWP_mm_Def; CSG_Grid *pWi_mm, *pFK_mm, *pPWP_mm, *pLandUse; CSG_Table *pClimate, *pCropCoeff; int Get_Month (int Day); double Get_kc (int Bestand, int Day); double Get_ETP_Haude (int Day); double Get_Pi (int Day); double Get_Wi (double Wi, double Pi, double ETP, double kc, double FK, double PWP); void Step_Day (int Day); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__DVWK_SoilMoisture_H saga-2.3.1/src/modules/simulation/sim_hydrology/WaterRetentionCapacity.h0000744000175000017500000000334012737416207027712 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: WaterRetentionCapacity.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /******************************************************************************* WaterRetentionCapacity.h Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "MLB_Interface.h" class CWaterRetentionCapacity : public CSG_Module_Grid { public: CWaterRetentionCapacity(void); virtual ~CWaterRetentionCapacity(void); private: CSG_Grid *m_pSlope; CSG_Grid *m_pRetention; CSG_Shapes *m_pOutput; void CalculateWaterRetention(float**,int, float, CSG_Table_Record*); void CorrectWithSlope(); float CalculateCCC(float*); float CalculateCIL(float*); int CalculatePermeability(float, float); float CalculateHe(float*); float CalculateK(int,int,float); protected: virtual bool On_Execute(void); }; saga-2.3.1/src/modules/simulation/sim_hydrology/diffuse_pollution_risk.cpp0000744000175000017500000003620412737416207030404 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: diffuse_pollution_risk.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // diffuse_pollution_risk.cpp // // // // Copyright (C) 2015 by // // Cosima Berger // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Cosima Berger // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "diffuse_pollution_risk.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDiffuse_Pollution_Risk::CDiffuse_Pollution_Risk(void) { //----------------------------------------------------- Set_Name (_TL("Diffuse Pollution Risk")); Set_Author ("Cosima Berger, Olaf Conrad (c) 2014"); Set_Description (_TW( "Diffuse Pollution Risk Mapping.\n" "This tool tries to reproduce in parts the methodology of the " "SCIMAP - Diffuse Pollution Risk Mapping - Framework.\n" "\nReferences:\n" "Lane, S.N.; Brookes, C.J.; Kirkby, M.J.; Holden, J. (2004): " "A network-index-based version of TOPMODEL for use with high-resolution digital topographic data. " "In: Hydrological processes. Vol. 18, S. 191-201.\n" "\n" "Milledge, D.G.; Lane, N.S.; Heathwait, A.L.; Reaney, S.M. (2012): " "A monte carlo approach to the invers problem of diffuse pollution risk in agricultural catchments. " "In: Science of the Total Environment. Vol. 433, S. 434-449.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CHANNEL" , _TL("Channel Network"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid_or_Const( NULL , "WEIGHT" , _TL("Land Cover Weights"), _TL(""), 1.0, 0.0, true ); Parameters.Add_Grid_or_Const( NULL , "RAIN" , _TL("Rainfall"), _TL(""), 500.0, 0.0, true ); Parameters.Add_Grid( NULL , "DELIVERY" , _TL("Delivery Index"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "RISK_POINT" , _TL("Locational Risk"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "RISK_DIFFUSE" , _TL("Diffuse Pollution Risk"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- Parameters.Add_Choice( NULL , "METHOD" , _TL("Flow Direction Algorithm"), _TL(""), CSG_String::Format("%s|%s|", _TL("single"), _TL("multiple") ), 1 ); Parameters.Add_Value( NULL , "CHANNEL_START" , _TL("Channel Initiation Threshold"), _TL("minimum number of upslope contributing cells to start a channel"), PARAMETER_TYPE_Int, 150, 1, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CDiffuse_Pollution_Risk::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "CHANNEL") ) { pParameters->Set_Enabled("CHANNEL_START", pParameter->asGrid() == NULL); } return( CSG_Module_Grid::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::On_Execute(void) { //----------------------------------------------------- m_pDEM = Parameters("DEM" )->asGrid(); m_pDelivery = Parameters("DELIVERY" )->asGrid(); m_pRisk_Point = Parameters("RISK_POINT" )->asGrid(); m_pRisk_Diffuse = Parameters("RISK_DIFFUSE")->asGrid(); m_bSingle = Parameters("METHOD" )->asInt() == 0; DataObject_Set_Colors(m_pDelivery , 11, SG_COLORS_RED_GREY_GREEN, true); DataObject_Set_Colors(m_pRisk_Point , 11, SG_COLORS_RED_GREY_GREEN, true); DataObject_Set_Colors(m_pRisk_Diffuse, 11, SG_COLORS_RED_GREY_GREEN, true); //----------------------------------------------------- bool bResult = false; if( !Set_Flow() ) { Error_Set(_TL("initialization failed")); } else if( !Set_Delivery_Index() ) { Error_Set(_TL("delivery index calculation failed")); } else if( !Get_Risk_Diffuse() ) { Error_Set(_TL("diffuse pollution risk calculation failed")); } else { bResult = true; } //----------------------------------------------------- m_FlowDir.Destroy(); m_RainAcc.Destroy(); m_TWI .Destroy(); return( bResult ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::Get_Flow_Proportions(int x, int y, double Proportion[8]) { if( m_pDEM->is_InGrid(x, y) ) { double Sum = 0.0; for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && m_pDEM->asDouble(x, y) > m_pDEM->asDouble(ix, iy) ) { Sum += (Proportion[i] = ((m_pDEM->asDouble(x, y) - m_pDEM->asDouble(ix, iy)) / Get_Length(i))); } else { Proportion[i] = 0.0; } } if( Sum > 0.0 ) { for(int i=0; i<8; i++) { if( Proportion[i] > 0.0 ) { Proportion[i] /= Sum; } } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::Set_Flow(void) { Process_Set_Text(_TL("initialization")); CSG_Grid *pWeight = Parameters("WEIGHT")->asGrid (); double Weight = Parameters("WEIGHT")->asDouble(); CSG_Grid *pRain = Parameters("RAIN" )->asGrid (); double Rain = Parameters("RAIN" )->asDouble(); m_FlowDir.Create(*Get_System(), SG_DATATYPE_Char); m_RainAcc.Create(*Get_System()); m_TWI .Create(*Get_System()); for(sLong n=0; nGet_Sorted(n, x, y, true) || (pRain && pRain->is_NoData(x, y)) || !Set_Flow(x, y, pRain ? pRain->asDouble(x, y) : Rain) ) { m_FlowDir .Set_NoData(x, y); m_RainAcc .Set_NoData(x, y); m_TWI .Set_NoData(x, y); m_pRisk_Point->Set_NoData(x, y); } else { double s, a; m_pDEM->Get_Gradient(x, y, s, a); s = tan(s); // tangens of slope a = (fabs(sin(a)) + fabs(cos(a))) * Get_Cellsize(); // flow width double SCA = m_RainAcc.asDouble(x, y) / a; // rain * specific catchment area m_TWI.Set_Value(x, y, log(SCA / (s < M_ALMOST_ZERO ? M_ALMOST_ZERO : s))); if( pWeight && pWeight->is_NoData(x, y) ) { m_pRisk_Point->Set_NoData(x, y); } else { m_pRisk_Point->Set_Value(x, y, SCA * s * (pWeight ? pWeight->asDouble(x, y) : Weight)); // Point Scale Risk Calculation according to Milledge et al. 2012 } } } return( true ); } //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::Set_Flow(int x, int y, double Rain) { //----------------------------------------------------- if( m_pDEM->is_NoData(x, y) ) { return( false ); } double d[8]; m_FlowDir.Set_Value(x, y, m_pDEM->Get_Gradient_NeighborDir(x, y)); m_RainAcc.Set_Value(x, y, Rain = Rain * Get_Cellarea() + m_RainAcc.asDouble(x, y)); //----------------------------------------------------- if( m_bSingle ) { if( Get_System()->Get_Neighbor_Pos(m_FlowDir.asInt(x, y), x, y, x, y) && m_pDEM->is_InGrid(x, y) ) { m_RainAcc.Add_Value(x, y, Rain); } } else if( Get_Flow_Proportions(x, y, d) ) { for(int i=0; i<8; i++) { if( d[i] > 0.0 ) { m_RainAcc.Add_Value(Get_xTo(i, x), Get_yTo(i, y), Rain * d[i]); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // Calculation according to Lane et al. 2004, p. 198. //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::Set_Delivery_Index(void) { //----------------------------------------------------- CSG_Grid Channel, *pChannel = Parameters("CHANNEL")->asGrid(); if( !pChannel ) // no channel network is provided, so create a tempory channel network out of the box! { Process_Set_Text(_TL("Channel Network")); int Threshold = Parameters("CHANNEL_START")->asInt(); pChannel = &Channel; Channel.Create(*Get_System(), SG_DATATYPE_Word); Channel.Assign(0.0); Channel.Set_NoData_Value(0.0); for(sLong n=0; nGet_Sorted(n, x, y, true) ) { if( Get_System()->Get_Neighbor_Pos(m_FlowDir.asInt(x, y), x, y, ix, iy) && m_FlowDir.is_InGrid(ix, iy) ) { Channel.Add_Value(ix, iy, 1.0 + Channel.asDouble(x, y)); } Channel.Set_Value(x, y, Channel.asInt(x, y) > Threshold ? 1.0 : 0.0); } } } //----------------------------------------------------- Process_Set_Text(_TL("Delivery Index")); for(sLong n=0; nGet_Sorted(n, x, y, false) ) // bottom up { if( m_TWI.is_InGrid(x, y) ) { TWI_min = m_TWI.asDouble(x, y); } if( m_FlowDir.is_InGrid(x, y) && Get_System()->Get_Neighbor_Pos(m_FlowDir.asInt(x, y), x, y, ix, iy) && m_TWI.is_InGrid(ix, iy) ) { if( TWI_min < 0.0 || TWI_min > m_TWI.asDouble(ix, iy) ) { TWI_min = m_TWI.asDouble(ix, iy); } } } if( TWI_min < 0.0 ) { m_pDelivery->Set_NoData(x, y); } else { m_pDelivery->Set_Value(x, y, TWI_min); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // Calculation according to Milledge et al. 2012 //--------------------------------------------------------- bool CDiffuse_Pollution_Risk::Get_Risk_Diffuse(void) { Process_Set_Text(_TL("Difuse Pollution Risk")); m_pRisk_Diffuse->Assign(0.0); //----------------------------------------------------- for(sLong n=0; nGet_Sorted(n, x, y, true) || m_pDelivery->is_NoData(x, y) || m_pRisk_Point->is_NoData(x, y) || m_RainAcc.asDouble(x, y) <= 0.0 ) { m_pRisk_Diffuse->Set_NoData(x, y); } else { double d[8], Risk; m_pRisk_Point->Mul_Value(x, y, m_pDelivery->asDouble(x, y)); // locational risk = generation risk * connection risk Risk = m_pRisk_Diffuse->asDouble(x, y) + m_pRisk_Point->asDouble(x, y); // risk load = sum of upslope locational risk m_pRisk_Diffuse->Set_Value(x, y, Risk / m_RainAcc.asDouble(x, y)); // risk concentration = risk load / sum of upslope rain if( m_bSingle ) { int i = !m_FlowDir.is_NoData(x, y) ? m_FlowDir.asInt(x, y) : -1; if( i > 0 && m_pDEM->is_InGrid(Get_xTo(i, x), Get_yTo(i, y)) ) { m_pRisk_Diffuse->Add_Value(Get_xTo(i, x), Get_yTo(i, y), Risk); } } else if( Get_Flow_Proportions(x, y, d) ) { for(int i=0; i<8; i++) { if( d[i] > 0.0 ) { m_pRisk_Diffuse->Add_Value(Get_xTo(i, x), Get_yTo(i, y), Risk * d[i]); } } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_hydrology/KinWav_D8.cpp0000744000175000017500000003420712737416207025355 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: KinWav_D8.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Kinematic_Wave // // // //-------------------------------------------------------// // // // KinWav_D8.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "KinWav_D8.h" //--------------------------------------------------------- #define Beta_0 (3.0 / 5.0) #define Beta_1 (3.0 / 5.0 - 1.0) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CKinWav_D8::CKinWav_D8(void) { CSG_Parameter *pNode; Set_Name (_TL("Overland Flow - Kinematic Wave D8")); Set_Author (SG_T("O. Conrad (c) 2003")); Set_Description (_TW( "Overland Flow - Kinematic Wave D8" "\n\n" "Reference:\n" "Johnson, D.L., Miller, A.C. (1997):" " A spatially distributed hydrological model utilizing raster data structures," " Computers & Geosciences, Vol.23, No.3, pp.267-272" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "FLOW" , _TL("Runoff"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Shapes( NULL , "GAUGES" , _TL("Gauges"), _TL(""), PARAMETER_INPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_Table( NULL , "GAUGES_FLOW" , _TL("Flow at Gauges"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); //----------------------------------------------------- Parameters.Add_Value( NULL , "TIME_SPAN" , _TL("Simulation Time [h]"), _TL(""), PARAMETER_TYPE_Double, 24.0, 0.0, true ); Parameters.Add_Value( NULL , "TIME_STEP" , _TL("Simulation Time Step [h]"), _TL(""), PARAMETER_TYPE_Double, 0.1, 0.0, true ); Parameters.Add_Value( NULL , "ROUGHNESS" , _TL("Manning's Roughness"), _TL(""), PARAMETER_TYPE_Double, 0.03, 0.0, true ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NEWTON", _TL("Newton-Raphson"), _TL("")); Parameters.Add_Value( pNode , "NEWTON_MAXITER" , _TL("Max. Iterations"), _TL(""), PARAMETER_TYPE_Int , 100 , 1 , true ); Parameters.Add_Value( pNode , "NEWTON_EPSILON" , _TL("Epsilon"), _TL(""), PARAMETER_TYPE_Double , 0.0001 , 0.0 , true ); //----------------------------------------------------- pNode = Parameters.Add_Choice( NULL , "PRECIP" , _TL("Precipitation"), _TL("Kind of initializing Precipitation Event"), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("Homogenous"), _TL("Above Elevation"), _TL("Left Half") ) ); Parameters.Add_Value( pNode , "THRESHOLD" , _TL("Threshold Elevation"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKinWav_D8::On_Execute(void) { double Roughness; //----------------------------------------------------- m_pDEM = Parameters("DEM") ->asGrid(); m_pFlow = Parameters("FLOW") ->asGrid(); m_pGauges = Parameters("GAUGES") ->asShapes(); m_pGauges_Flow = Parameters("GAUGES_FLOW") ->asTable(); Newton_MaxIter = Parameters("NEWTON_MAXITER") ->asInt(); Newton_Epsilon = Parameters("NEWTON_EPSILON") ->asDouble(); Roughness = Parameters("ROUGHNESS") ->asDouble(); if( !m_pDEM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } //----------------------------------------------------- if( Initialize(Roughness) ) { int x, y; double Time, Time_Span; Gauges_Initialise(); Time_Span = Parameters("TIME_SPAN") ->asDouble(); m_dTime = Parameters("TIME_STEP") ->asDouble(); for(Time=0.0; Time<=Time_Span && Process_Get_Okay(false); Time+=m_dTime) { Process_Set_Text(CSG_String::Format(SG_T("%s [h]: %f (%f)"), _TL("Simulation Time"), Time, Time_Span)); Get_Precipitation(Time); m_Flow_Last.Assign(m_pFlow); m_pFlow->Assign(0.0); for(sLong n=0; nGet_NCells() && Process_Get_Okay(false); n++) { if( m_pDEM->Get_Sorted(n, x, y) ) { Get_Runoff(x, y); } else { m_pFlow->Set_NoData(x, y); } } DataObject_Update(m_pFlow, 0.0, 100.0); Gauges_Set_Flow(Time); } //------------------------------------------------- Finalize(); return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CKinWav_D8::Get_Runoff(int x, int y) { int Direction = m_Direction.asChar(x, y); if( Direction >= 0 ) { m_pFlow->Set_Value(x, y, Get_Runoff( m_pFlow ->asDouble(x, y), m_Flow_Last .asDouble(x, y), m_Alpha .asDouble(x, y), Get_UnitLength(Direction), 0.0, 0.0 ) ); m_pFlow->Add_Value(Get_xTo(Direction, x), Get_yTo(Direction, y), m_Flow_Last.asDouble(x, y)); } } //--------------------------------------------------------- double CKinWav_D8::Get_Runoff(double q_Up, double q_Last, double alpha, double dL, double r, double r_Last) { double dTdL, d, c, q, Res, dRes, dR; //----------------------------------------------------- dTdL = m_dTime / dL; dR = m_dTime / 2.0 * (r + r_Last); //----------------------------------------------------- // 1. Initial estimation of q... if( q_Last + q_Up != 0.0 ) { d = alpha * Beta_0 * pow((q_Last + q_Up) / 2.0, Beta_1); q = ( dTdL * q_Up + q_Last * d + dR ) / ( dTdL + d ); } else { q = dR; } //----------------------------------------------------- // 2. Newton-Raphson... c = dTdL * q_Up + alpha * pow(q_Last, Beta_0) + dR; for(int i=0; iAssign(0.0); DataObject_Set_Colors(m_pFlow, 100, SG_COLORS_WHITE_BLUE); DataObject_Update(m_pFlow, 0.0, 100.0, SG_UI_DATAOBJECT_SHOW); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { int i, ix, iy, iMax; double z, d, dMax; for(i=0, iMax=-1, dMax=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( is_InGrid(ix, iy) && (d = (z - m_pDEM->asDouble(ix, iy)) / Get_Length(i)) > dMax ) { dMax = d; iMax = i; } } if( iMax < 0 ) { m_Direction .Set_NoData(x, y); } else { m_Direction .Set_Value(x, y, iMax); m_Alpha .Set_Value(x, y, pow(Roughness / sqrt(dMax), Beta_0)); if( m_Alpha.asDouble(x, y) > 10 ) m_Alpha.Set_Value(x, y, 10); } } } } return( true ); } //--------------------------------------------------------- bool CKinWav_D8::Finalize(void) { m_Direction .Destroy(); m_Alpha .Destroy(); m_Flow_Last .Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CKinWav_D8::Gauges_Initialise(void) { if( m_pGauges_Flow != NULL ) { if( m_pGauges == NULL ) { DataObject_Add(m_pGauges = SG_Create_Shapes(SHAPE_TYPE_Point, _TL("Gauges"))); Parameters("GAUGES")->Set_Value(m_pGauges); m_pGauges->Add_Field(_TL("ID"), SG_DATATYPE_Int); for(int y=0; yis_InGrid(ix, iy) ) { bBorder = true; } else if( m_pDEM->asDouble(ix, iy) < m_pDEM->asDouble(x, y) ) { bLowest = false; } } if( bLowest && bBorder ) { CSG_Shape *pGauge = m_pGauges->Add_Shape(); pGauge->Add_Point(Get_System()->Get_Grid_to_World(x, y)); pGauge->Set_Value(0, m_pGauges->Get_Count() + 1); } } } } m_pGauges_Flow->Destroy(); m_pGauges_Flow->Set_Name(_TL("Outlet Hydrographs")); m_pGauges_Flow->Add_Field("TIME", SG_DATATYPE_Double); for(int i=0; iGet_Count(); i++) { m_pGauges_Flow->Add_Field(CSG_String::Format(SG_T("GAUGE_%02d"), i + 1), SG_DATATYPE_Double); } return( true ); } return( false ); } //--------------------------------------------------------- bool CKinWav_D8::Gauges_Set_Flow(double Time) { if( m_pGauges_Flow && m_pGauges_Flow->Get_Field_Count() == m_pGauges->Get_Count() + 1 ) { CSG_Table_Record *pRecord = m_pGauges_Flow->Add_Record(); pRecord->Set_Value(0, Time); for(int i=0; iGet_Count(); i++) { double Flow; if( m_pFlow->Get_Value(m_pGauges->Get_Shape(i)->Get_Point(0), Flow) ) { pRecord->Set_Value(i + 1, Flow); } } DataObject_Update(m_pGauges_Flow); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CKinWav_D8::Get_Precipitation(double Time) { if( Time == 0.0 ) { int x, y; double t; switch( Parameters("PRECIP")->asInt() ) { case 0: (*m_pFlow) += 100.0; break; case 1: t = Parameters("THRESHOLD")->asDouble(); for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX(); x++) { if( !m_pDEM->is_NoData(x, y) && m_pDEM->asDouble(x, y) > t ) { m_pFlow->Add_Value(x, y, 100.0); } } } break; case 2: for(y=0; yGet_NY(); y++) { for(x=0; xGet_NX() / 2; x++) { if( !m_pDEM->is_NoData(x, y) ) { m_pFlow->Add_Value(x, y, 100.0); } } } break; } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_hydrology/diffusion_gradient_concentration.cpp0000744000175000017500000005332712737416207032420 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // diffusion_gradient_concentration.cpp // // // // Copyright (C) 2007 by // // O.Conrad, R.Heinrich // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // contact: Ralph Heinrich // // // // e-mail: heinrich-ralph@web.de // // // // phone: +49-35603-152006 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "diffusion_gradient_concentration.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define MASK_LAKE 1 #define MASK_INLET 2 #define MASK_OUTLET 3 //--------------------------------------------------------- static const CSG_String Description = _TW( "Cellular automata are simple computational operators, but despite their simplicity, " "they allow the simulation of highly complex processes. This tool has been created to " "apply the concept of cellular automata to simulate diffusion and flow processes in " "shallow water bodies with in- and outflow, where monitoring data show concentration " "growth or decrease between the inflow and the outflow points. Parameters are for " "example nutrients like nitrate, which is reduced by denitrification process inside " "the water body.\n" "Values of mask grid are expected to be 1 for water area, 2 for inlet, 3 for outlet and " "0 for non water.\n" "\n" "References:\n
      " "
    • Heinrich, R. / Conrad, O. (2008):" " Diffusion, Flow and Concentration Gradient Simulation with SAGA GIS using Cellular Automata Methods." " In: Boehner, J. / Blaschke, T. / Montanarella, L. [Eds.]:" " SAGA - Seconds Out. Hamburger Beitraege zur Physischen Geographie und Landschaftsoekologie, Vol.19, p59-70," " online.
    \n" ); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSim_Diffusion_Gradient::CSim_Diffusion_Gradient(void) { //----------------------------------------------------- Set_Name (_TL("Surface and Gradient")); Set_Author ("R.Heinrich, O.Conrad (c) 2007"); Set_Description (Description); //----------------------------------------------------- Parameters.Add_Grid( NULL , "MASK" , _TL("Mask"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SURF" , _TL("Surface"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "GRAD" , _TL("Gradient"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- Parameters.Add_Value( NULL , "SURF_E" , _TL("Surface Approximation Threshold"), _TL(""), PARAMETER_TYPE_Double, 0.001, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSim_Diffusion_Gradient::On_Execute(void) { m_pMask = Parameters("MASK")->asGrid(); CSG_Grid *pSurface = Parameters("SURF")->asGrid(); CSG_Grid *pGradient = Parameters("GRAD")->asGrid(); m_Tmp.Create(*Get_System()); //----------------------------------------------------- bool bResult = Surface_Initialise(pSurface); if( bResult ) { Surface_Interpolate (pSurface); Surface_Get_Gradient(pSurface, pGradient); } //----------------------------------------------------- m_Tmp.Destroy(); return( bResult ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CSim_Diffusion_Gradient::is_Lake(int x, int y) { if( is_InGrid(x, y) ) { int Mask = m_pMask->asInt(x, y); return( Mask == MASK_LAKE || Mask == MASK_INLET || Mask == MASK_OUTLET ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSim_Diffusion_Gradient::Surface_Initialise(CSG_Grid *pSurface) { int nIn = 0, nOut = 0; for(int y=0; yasInt(x, y) ) { case MASK_INLET : nIn++; pSurface->Set_Value (x, y, 100.0); break; case MASK_LAKE : pSurface->Set_Value (x, y, 50.0); break; case MASK_OUTLET: nOut++; pSurface->Set_Value (x, y, 0.0); break; default : pSurface->Set_NoData(x, y ); break; } } } return( nIn > 0 && nOut > 0 ); } //--------------------------------------------------------- bool CSim_Diffusion_Gradient::Surface_Interpolate(CSG_Grid *pSurface) { int n, nMax; double d, dEpsilon; nMax = 100000; dEpsilon = Parameters("SURF_E")->asDouble(); DataObject_Update(pSurface, true); for(n=0, d=Surface_Set_Means(pSurface); ndEpsilon && Process_Get_Okay(false); n++) { d = Surface_Set_Means(pSurface); Process_Set_Text(CSG_String::Format(SG_T("%d, %f"), n + 1, d)); if( n % 25 == 0 ) DataObject_Update(pSurface, 0.0, 100.0); } Message_Add(CSG_String::Format("%d iterations", n)); return( true ); } //--------------------------------------------------------- double CSim_Diffusion_Gradient::Surface_Set_Means(CSG_Grid *pSurface) { int y, in = 1; //----------------------------------------------------- #pragma omp parallel for private(y) for(y=0; yasDouble(ix, iy); } } } m_Tmp.Set_Value(x, y, s.Get_Mean()); } } } //----------------------------------------------------- double dMax = 0.0; for(y=0; yasInt(x, y) ) { case MASK_INLET : pSurface->Set_Value(x, y, 100.0); break; case MASK_OUTLET: pSurface->Set_Value(x, y, 0.0); break; case MASK_LAKE : { double s = m_Tmp.asDouble(x, y); double d = fabs(pSurface->asDouble(x, y) - s); if( d > 0.0 ) { if( dMax <= 0.0 || d > dMax ) { dMax = d; } pSurface->Set_Value(x, y, s); } } break; } } } return( dMax ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSim_Diffusion_Gradient::Surface_Get_Gradient(CSG_Grid *pSurface, CSG_Grid *pGradient) { #pragma omp parallel for for(int y=0; yasDouble(x, y); zMin = zMax; for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( is_Lake(ix, iy) ) { if( zMin > (z = pSurface->asDouble(ix, iy)) ) { zMin = z; } else if( zMax < z ) { zMax = z; } } } switch( m_pMask->asInt(x, y) ) { case MASK_INLET : case MASK_LAKE : pGradient->Set_Value(x, y, zMax - zMin ); break; case MASK_OUTLET: pGradient->Set_Value(x, y, (zMax - zMin) * 2.0); break; } } else { pGradient->Set_NoData(x, y); } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSim_Diffusion_Concentration::CSim_Diffusion_Concentration(void) { Parameters.Create(NULL, SG_T(""), SG_T(""), SG_T(""), true); //----------------------------------------------------- Set_Name (_TL("Concentration")); Set_Author ("R.Heinrich, O.Conrad (c) 2007"); Set_Description (Description); //----------------------------------------------------- Parameters.Add_Grid( NULL , "MASK" , _TL("Mask"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "GRAD" , _TL("Gradient"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CONC" , _TL("Concentration"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- Parameters.Add_Value( NULL , "CONC_IN" , _TL("Inlet Concentration"), _TL(""), PARAMETER_TYPE_Double, 5.0, 0.0, true ); Parameters.Add_Value( NULL , "CONC_OUT" , _TL("Outlet Concentration"), _TL(""), PARAMETER_TYPE_Double, 3.0, 0.0, true ); Parameters.Add_Value( NULL , "CONC_E" , _TL("Concentration Approximation Threshold"), _TL(""), PARAMETER_TYPE_Double, 0.001, 0.0, true ); Parameters.Add_Value( NULL , "GRAD_MIN" , _TL("Minimum Gradient"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Choice( NULL , "NEIGHBOURS" , _TL("Neighbourhood"), _TL(""), CSG_String::Format("%s|%s|%s|", _TL("Moore (8)"), _TL("Neumann (4)"), _TL("Optimised") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSim_Diffusion_Concentration::On_Execute(void) { m_pMask = Parameters("MASK")->asGrid(); CSG_Grid *pGradient = Parameters("GRAD")->asGrid(); CSG_Grid *pConcentration = Parameters("CONC")->asGrid(); m_Conc_In = Parameters("CONC_IN" )->asDouble(); m_Conc_Out = Parameters("CONC_OUT")->asDouble(); m_MinGradient = Parameters("GRAD_MIN")->asDouble(); //----------------------------------------------------- m_Tmp.Create(*Get_System()); Concentration_Interpolate(pConcentration, pGradient); m_Tmp.Destroy(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSim_Diffusion_Concentration::Concentration_Interpolate(CSG_Grid *pConcentration, CSG_Grid *pGradient) { switch( Parameters("NEIGHBOURS") ? Parameters("NEIGHBOURS")->asInt() : 2 ) { case 0: // Moore { _Concentration_Interpolate (pConcentration, pGradient, false); } break; case 1: // Neumann { _Concentration_Interpolate (pConcentration, pGradient, true); } break; case 2: // Optimised { _Concentration_Interpolate (pConcentration, pGradient, false); CSG_Grid Concentration(*pConcentration); _Concentration_Interpolate (pConcentration, pGradient, true); for(int y=0; yis_NoData(x, y) || Concentration.is_NoData(x, y) ) { pConcentration->Set_NoData(x, y); } else { pConcentration->Set_Value(x, y, (pConcentration->asDouble(x, y) + Concentration.asDouble(x, y)) / 2.0); } } } } break; } return( true ); } //--------------------------------------------------------- bool CSim_Diffusion_Concentration::_Concentration_Interpolate(CSG_Grid *pConcentration, CSG_Grid *pGradient, bool bNeumann) { double d, d_lo, d_hi, f, f_lo, f_hi, d_Max; DataObject_Update(pConcentration, true); d_Max = Parameters("CONC_E")->asDouble(); d_lo = _Concentration_Interpolate(pConcentration, pGradient, bNeumann, f_lo = 0.0); d_hi = _Concentration_Interpolate(pConcentration, pGradient, bNeumann, f_hi = 0.01); while( d_hi > m_Conc_Out && Process_Get_Okay(false) ) { f_hi *= 10.0; d_hi = _Concentration_Interpolate(pConcentration, pGradient, bNeumann, f_hi); } do { d = _Concentration_Interpolate(pConcentration, pGradient, bNeumann, f = f_lo + 0.5 * (f_hi - f_lo)); Process_Set_Text(CSG_String::Format(SG_T("f: %f, AK: %f, dif: %f"), f, d, m_Conc_Out - d)); Message_Add (CSG_String::Format(SG_T("f: %f, AK: %f, dif: %f"), f, d, m_Conc_Out - d)); DataObject_Update(pConcentration, m_Conc_Out, m_Conc_In); if( fabs(d - m_Conc_Out) > d_Max ) { if( SG_IS_BETWEEN(d_lo, m_Conc_Out, d) ) { f_hi = f; d_hi = d; } else if( SG_IS_BETWEEN(d_hi, m_Conc_Out, d) ) { f_lo = f; d_lo = d; } else { return( false ); } } } while( fabs(d - m_Conc_Out) > d_Max && f_hi > f_lo && Process_Get_Okay(false) ); Message_Add(CSG_String::Format(SG_T("f: %f"), f)); //----------------------------------------------------- _Concentration_Initialise(pConcentration); for(int nChanges=1; nChanges>0 && Process_Get_Okay(false); ) { nChanges = _Concentration_Set_Means(pConcentration, pGradient, bNeumann, f, d); } return( true ); } //--------------------------------------------------------- double CSim_Diffusion_Concentration::_Concentration_Interpolate(CSG_Grid *pConcentration, CSG_Grid *pGradient, bool bNeumann, double f) { double Conc_Out = 0.0; _Concentration_Initialise(pConcentration); for(int nChanges=1; Conc_Out<=0.0 && nChanges>0 && Process_Get_Okay(false); ) { nChanges = _Concentration_Set_Means(pConcentration, pGradient, bNeumann, f, Conc_Out); } return( Conc_Out ); } //--------------------------------------------------------- int CSim_Diffusion_Concentration::_Concentration_Set_Means(CSG_Grid *pConcentration, CSG_Grid *pGradient, bool bNeumann, double f, double &Conc_Out) { int y, n, iStep = bNeumann ? 2 : 1; //----------------------------------------------------- #pragma omp parallel for private(y) for(y=0; yasDouble(x, y) == 0.0 ) { double d, dMax = 0.0; for(int i=0; i<8; i+=iStep) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( is_Lake(ix, iy) && dMax < (d = pConcentration->asDouble(ix, iy)) ) { dMax = d; } } if( dMax > 0.0 ) { if( (d = pGradient->asDouble(x, y)) < m_MinGradient ) { d = m_MinGradient; } m_Tmp.Set_Value(x, y, dMax / (1.0 + (f / d))); } } } } //----------------------------------------------------- for(y=0, n=0, Conc_Out=0.0; yasInt(x, y) ) { case MASK_INLET: pConcentration->Set_Value(x, y, m_Conc_In); break; case MASK_OUTLET: if( pConcentration->asDouble(x, y) == 0.0 && (d = m_Tmp.asDouble(x, y)) > 0.0 ) { pConcentration->Set_Value(x, y, Conc_Out = d); n++; } break; case MASK_LAKE: if( pConcentration->asDouble(x, y) == 0.0 && (d = m_Tmp.asDouble(x, y)) > 0.0 ) { pConcentration->Set_Value(x, y, d); n++; } break; } } } return( n ); } //--------------------------------------------------------- bool CSim_Diffusion_Concentration::_Concentration_Initialise(CSG_Grid *pConcentration) { m_Tmp.Assign(0.0); #pragma omp parallel for for(int y=0; yasInt(x, y) ) { case MASK_LAKE : pConcentration->Set_Value (x, y, 0.0 ); break; case MASK_OUTLET: pConcentration->Set_Value (x, y, 0.0 ); break; case MASK_INLET : pConcentration->Set_Value (x, y, m_Conc_In); break; default : pConcentration->Set_NoData(x, y ); break; } } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSim_Diffusion_Gradient_And_Concentration::CSim_Diffusion_Gradient_And_Concentration(void) { Parameters.Create(NULL, SG_T(""), SG_T(""), SG_T(""), true); //----------------------------------------------------- Set_Name (_TL("Surface, Gradient and Concentration")); Set_Author ("R.Heinrich, O.Conrad (c) 2007"); Set_Description (Description); //----------------------------------------------------- Parameters.Add_Grid( NULL , "MASK" , _TL("Mask"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "SURF" , _TL("Surface"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "GRAD" , _TL("Gradient"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "CONC" , _TL("Concentration"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- Parameters.Add_Value( NULL , "SURF_E" , _TL("Surface Approximation Threshold"), _TL(""), PARAMETER_TYPE_Double, 0.001, 0.0, true ); Parameters.Add_Value( NULL , "CONC_IN" , _TL("Inlet Concentration"), _TL(""), PARAMETER_TYPE_Double, 5.0, 0.0, true ); Parameters.Add_Value( NULL , "CONC_OUT" , _TL("Outlet Concentration"), _TL(""), PARAMETER_TYPE_Double, 3.0, 0.0, true ); Parameters.Add_Value( NULL , "CONC_E" , _TL("Concentration Approximation Threshold"), _TL(""), PARAMETER_TYPE_Double, 0.001, 0.0, true ); Parameters.Add_Value( NULL , "GRAD_MIN" , _TL("Minimum Gradient"), _TL(""), PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Choice( NULL , "NEIGHBOURS" , _TL("Neighbourhood"), _TL(""), CSG_String::Format("%s|%s|%s|", _TL("Moore (8)"), _TL("Neumann (4)"), _TL("Optimised") ), 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSim_Diffusion_Gradient_And_Concentration::On_Execute(void) { m_pMask = Parameters("MASK")->asGrid(); CSG_Grid *pSurface = Parameters("SURF")->asGrid(); CSG_Grid *pGradient = Parameters("GRAD")->asGrid(); CSG_Grid *pConcentration = Parameters("CONC")->asGrid(); m_Conc_In = Parameters("CONC_IN" )->asDouble(); m_Conc_Out = Parameters("CONC_OUT")->asDouble(); m_MinGradient = Parameters("GRAD_MIN")->asDouble(); m_Tmp.Create(*Get_System()); //----------------------------------------------------- bool bResult = Surface_Initialise(pSurface); if( bResult ) { Surface_Interpolate (pSurface); Surface_Get_Gradient(pSurface, pGradient); Concentration_Interpolate(pConcentration, pGradient); } //----------------------------------------------------- m_Tmp.Destroy(); return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_hydrology/KinWav_D8.h0000744000175000017500000001144212737416207025016 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: KinWav_D8.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // KinWav_D8.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__KinWav_D8_H #define HEADER_INCLUDED__KinWav_D8_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CKinWav_D8 : public CSG_Module_Grid { public: CKinWav_D8(void); protected: virtual bool On_Execute (void); private: double m_dTime, Newton_MaxIter, Newton_Epsilon; CSG_Grid *m_pDEM, *m_pFlow, m_Direction, m_Alpha, m_Flow_Last; CSG_Table *m_pGauges_Flow; CSG_Shapes *m_pGauges; void Get_Runoff (int x, int y); double Get_Runoff (double q_Up, double q_Last, double alpha, double dL, double r, double r_Last); bool Initialize (double Roughness); bool Finalize (void); bool Gauges_Initialise (void); bool Gauges_Set_Flow (double Time); void Get_Precipitation (double Time); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__KinWav_D8_H saga-2.3.1/src/modules/simulation/sim_hydrology/topmodel.h0000744000175000017500000001123312737416207025105 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topmodel.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // topmodel.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__topmodel_H #define HEADER_INCLUDED__topmodel_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "topmodel_values.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTOPMODEL : public CSG_Module_Grid { public: CTOPMODEL(void); virtual ~CTOPMODEL(void); protected: virtual bool On_Execute(void); private: int m_fP, m_fET, m_fTime; double dTime, inf_cumf, inf_bPonding; CSG_Table *m_pWeather; CTOPMODEL_Values Vals; void Run(double Evaporation, double Infiltration, double Infiltration_Excess); bool Get_Weather(int iTimeStep, double &Precipitation, double &Evaporation, CSG_String &Date); double Get_Infiltration(double t, double R); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__topmodel_H saga-2.3.1/src/modules/simulation/sim_hydrology/Makefile.in0000664000175000017500000005724212737447617025202 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/simulation/sim_hydrology ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_hydrology_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_hydrology_la_OBJECTS = DVWK_SoilMoisture.lo \ diffuse_pollution_risk.lo diffusion_gradient_concentration.lo \ idw.lo KinWav_D8.lo MLB_Interface.lo topmodel.lo \ topmodel_values.lo WaterRetentionCapacity.lo libsim_hydrology_la_OBJECTS = $(am_libsim_hydrology_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_hydrology_la_SOURCES) DIST_SOURCES = $(libsim_hydrology_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_hydrology.la libsim_hydrology_la_SOURCES = \ DVWK_SoilMoisture.cpp\ diffuse_pollution_risk.cpp\ diffusion_gradient_concentration.cpp\ idw.cpp\ KinWav_D8.cpp\ MLB_Interface.cpp\ topmodel.cpp\ topmodel_values.cpp\ WaterRetentionCapacity.cpp\ diffuse_pollution_risk.h\ diffusion_gradient_concentration.h\ DVWK_SoilMoisture.h\ idw.h\ KinWav_D8.h\ MLB_Interface.h\ topmodel.h\ topmodel_values.h\ WaterRetentionCapacity.h libsim_hydrology_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/simulation/sim_hydrology/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_hydrology/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_hydrology.la: $(libsim_hydrology_la_OBJECTS) $(libsim_hydrology_la_DEPENDENCIES) $(EXTRA_libsim_hydrology_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_hydrology_la_OBJECTS) $(libsim_hydrology_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DVWK_SoilMoisture.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/KinWav_D8.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WaterRetentionCapacity.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diffuse_pollution_risk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diffusion_gradient_concentration.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idw.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/topmodel.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/topmodel_values.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/simulation/sim_hydrology/diffusion_gradient_concentration.h0000744000175000017500000001365312737416207032063 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // //-------------------------------------------------------// // // // diffusion_gradient_concentration.h // // // // Copyright (C) 2007 by // // O.Conrad, R.Heinrich // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // contact: Ralph Heinrich // // // // e-mail: heinrich-ralph@web.de // // // // phone: +49-35603-152006 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__diffusion_gradient_concentration_H #define HEADER_INCLUDED__diffusion_gradient_concentration_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSim_Diffusion_Gradient : public CSG_Module_Grid { public: CSim_Diffusion_Gradient(void); virtual CSG_String Get_MenuPath (void) { return( "Diffusion, Flow and Concentration Gradient Simulation" ); } protected: virtual bool On_Execute (void); //----------------------------------------------------- CSG_Grid *m_pMask, m_Tmp; //----------------------------------------------------- bool Surface_Initialise (CSG_Grid *pSurface); bool Surface_Interpolate (CSG_Grid *pSurface); double Surface_Set_Means (CSG_Grid *pSurface); bool Surface_Get_Gradient (CSG_Grid *pSurface, CSG_Grid *pGradient); //----------------------------------------------------- bool is_Lake (int x, int y); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSim_Diffusion_Concentration : public CSim_Diffusion_Gradient { public: CSim_Diffusion_Concentration(void); protected: virtual bool On_Execute (void); double m_Conc_In, m_Conc_Out, m_MinGradient; bool Concentration_Interpolate (CSG_Grid *pConcentration, CSG_Grid *pGradient); private: bool _Concentration_Interpolate (CSG_Grid *pConcentration, CSG_Grid *pGradient, bool bNeumann); double _Concentration_Interpolate (CSG_Grid *pConcentration, CSG_Grid *pGradient, bool bNeumann, double f); int _Concentration_Set_Means (CSG_Grid *pConcentration, CSG_Grid *pGradient, bool bNeumann, double f, double &Conc_Out); bool _Concentration_Initialise (CSG_Grid *pConcentration); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSim_Diffusion_Gradient_And_Concentration : public CSim_Diffusion_Concentration { public: CSim_Diffusion_Gradient_And_Concentration(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__diffusion_gradient_concentration_H saga-2.3.1/src/modules/simulation/sim_hydrology/WaterRetentionCapacity.cpp0000744000175000017500000001562012737416207030251 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: WaterRetentionCapacity.cpp 966 2011-03-25 00:40:53Z johanvdw $ *********************************************************/ /******************************************************************************* WaterRetentionCapacity.cpp Copyright (C) Victor Olaya This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, USA *******************************************************************************/ #include "idw.h" #include "WaterRetentionCapacity.h" CWaterRetentionCapacity::CWaterRetentionCapacity(void){ Parameters.Set_Name(_TL("Water Retention Capacity")); Parameters.Set_Description(_TW( "(c) 2004 Victor Olaya. Water Retention Capacity (Gandullo, 1994)")); Parameters.Add_Shapes(NULL, "SHAPES", _TL("Plot Holes"), _TL(""), PARAMETER_INPUT); Parameters.Add_Shapes(NULL, "OUTPUT", _TL("Final Parameters"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "DEM", _TL("DEM"), _TL("DEM"), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "RETENTION", _TL("Water Retention Capacity"), _TL(""), PARAMETER_OUTPUT); }//constructor CWaterRetentionCapacity::~CWaterRetentionCapacity(void) {} bool CWaterRetentionCapacity::On_Execute(void){ int i,j; int x,y; int iField; int iShape; int iRows; float fValue = 0; float **pData; int iX, iY; float fC; double dSlope,dAspect; CSG_Shape* pShape; CSG_Shapes* pShapes = Parameters("SHAPES")->asShapes(); CSG_Grid* pDEM = Parameters("DEM")->asGrid(); m_pRetention = Parameters("RETENTION")->asGrid(); m_pSlope = SG_Create_Grid(pDEM); m_pOutput = Parameters("OUTPUT")->asShapes(); m_pOutput->Assign(pShapes); m_pOutput->Add_Field("CCC", SG_DATATYPE_Double); m_pOutput->Add_Field("CIL", SG_DATATYPE_Double); m_pOutput->Add_Field(_TL("Permeability"), SG_DATATYPE_Double); m_pOutput->Add_Field(_TL("Equivalent Moisture"), SG_DATATYPE_Double); m_pOutput->Add_Field(_TL("Water Retention Capacity"), SG_DATATYPE_Double); for(y=0; yGet_Gradient(x, y, dSlope, dAspect) ){ m_pSlope->Set_Value(x, y, dSlope); } else{ m_pSlope->Set_NoData(x, y); } } } iRows = pShapes->Get_Field_Count() / 5; pData = new float*[iRows]; for (iShape = 0; iShape < pShapes->Get_Count(); iShape++){ pShape = pShapes->Get_Shape(iShape); for (i = 0; i< iRows; i++){ pData[i] = new float[5]; for (j = 0; j < 5; j++){ pData[i][j] = 0; try{ pData[i][j] = pShape->asFloat(j+i*5); }//try catch(...){} }//for }//for iX = (int)((pShape->Get_Point(0).x - pDEM->Get_XMin())/pDEM->Get_Cellsize()); iY = (int)((pShape->Get_Point(0).y - pDEM->Get_YMin())/pDEM->Get_Cellsize()); fC = (float)(1. - tan(m_pSlope->asFloat(iX,iY))); pShape = m_pOutput->Get_Shape(iShape); CalculateWaterRetention(pData, iRows, fC, pShape); }//for iField = m_pOutput->Get_Field_Count()-1; CIDW IDW; IDW.setParameters(m_pRetention, m_pOutput, iField); IDW.Interpolate(); CorrectWithSlope(); return true; }//method void CWaterRetentionCapacity::CalculateWaterRetention(float **pData, int iNumHorizons, float fC, CSG_Table_Record *pRecord){ int i; int iField; float *pCCC = new float[iNumHorizons]; float *pCIL = new float[iNumHorizons]; float *pK = new float[iNumHorizons]; int *pPerm = new int[iNumHorizons]; float *pHe = new float[iNumHorizons]; float *pCRA = new float[iNumHorizons]; float fTotalDepth = 0; float fWaterRetention = 0; float fPerm = 0; float fHe = 0; float fK = 0; float fCCC = 0; float fCIL = 0; pK[0] = 0; for (i = 0; i < iNumHorizons; i++){ pCCC[i] = CalculateCCC(pData[i]); pCIL[i] = CalculateCIL(pData[i]); pPerm[i] = CalculatePermeability(pCCC[i], pCIL[i]); pHe[i] = CalculateHe(pData[i]); if (i){ pK[i] = CalculateK(pPerm[i-1], pPerm[i], fC); }//if pCRA[i] = (float)((12.5 * pHe[i] + 12.5 * (50. - pHe[i]) * pK[i] / 2.) * pData[i][1] / 100.); fTotalDepth += pData[i][0]; }//for for (i = 0; i < iNumHorizons; i++){ fWaterRetention += pData[i][0] / fTotalDepth * pCRA[i]; fCCC += pData[i][0] / fTotalDepth * pCCC[i]; fCIL += pData[i][0] / fTotalDepth * pCIL[i]; fPerm += pData[i][0] / fTotalDepth * pPerm[i]; fHe += pData[i][0] / fTotalDepth * pHe[i]; fK += pData[i][0] / fTotalDepth * pK[i]; }//for iField = pRecord->Get_Table()->Get_Field_Count() - 1; pRecord->Set_Value(iField - 4, fCCC); pRecord->Set_Value(iField - 3, fCIL); pRecord->Set_Value(iField - 2, fPerm); pRecord->Set_Value(iField - 1, fHe); pRecord->Set_Value(iField, fWaterRetention); delete[]pCRA; }//method void CWaterRetentionCapacity::CorrectWithSlope(){ int x,y; float fC; for (x = 0; x < m_pRetention->Get_NX(); x++) { for (y = 0; y < m_pRetention->Get_NY(); y++) { fC = (float)(1. - tan(m_pSlope->asFloat(x,y))); if (fC < 0.){ fC = 0.; }//if m_pRetention->Set_Value(x,y,m_pRetention->asFloat(x,y) * fC); }//for }//for }//method float CWaterRetentionCapacity::CalculateHe(float* pHorizon){ float fL = pHorizon[2]; float fTF = pHorizon[1]; float fAr = pHorizon[3]; float fMO = pHorizon[4]; float fHe = (float)(4.6 + 0.43 * fAr + 0.25 * fL + 1.22 * fMO); return fHe; }//method float CWaterRetentionCapacity::CalculateCIL(float* pHorizon){ float fL = pHorizon[2]; float fTF = pHorizon[1]; float fCIL = (float)((fL * fTF) /10000.); return fCIL; }//method float CWaterRetentionCapacity::CalculateCCC(float* pHorizon){ float fL = pHorizon[2]; float fTF = pHorizon[1]; float fAr = pHorizon[3]; float fMO = pHorizon[4]; float fCCC = (float)((fAr - 4.*fMO) / fTF); return fCCC; }//method float CWaterRetentionCapacity::CalculateK(int iPermI, int iPermS, float fC){ float fAi = (float)((iPermI - 1) * .2); float fAs = (float)((iPermS - 1) * .2); return (float)((1. - fAi - (1 + fAs) * (1. - fC))); }//method int CWaterRetentionCapacity::CalculatePermeability(float fCCC, float fCIL){ int iPerm; if (fCCC < 0.15){ iPerm = 5 - (int)((fCIL-0.1) / 0.15); }//if else if (fCIL < 0.2){ iPerm = 5 - (int)(fCCC / 0.15); }//else if else{ iPerm = (int)(5 - (fCCC + fCIL - 0.1) / 0.15); }//else if (iPerm < 1){ iPerm = 1; }//if return iPerm; }//method saga-2.3.1/src/modules/simulation/sim_hydrology/DVWK_SoilMoisture.cpp0000744000175000017500000004241012737416207027107 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: DVWK_SoilMoisture.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // DVWK_SoilMoisture.cpp // // // // Copyright (C) 2002 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "DVWK_SoilMoisture.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDVWK_SoilMoisture::CDVWK_SoilMoisture(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Soil Moisture Content")); Set_Author (SG_T("(c) 2002 by O.Conrad")); Set_Description (_TW( "The WEELS (Wind Erosion on European Light Soils) soil moisture " "model dynamically calculates the soil moisture based on the rules " "proposed by the DVWK (1996) with input data about:\n" "- soil properties (grids: field capacity and permanent wilting point)\n" "- land use (grid: crop types)\n" "- climate (table: daily values of precipitation, temperature, air humidity)\n\n" "References:\n" "- DVWK - Deutscher Verband fuer Wasserwirtschaft und Kulturbau e.V. (1996): " "'Ermittlung der Verdunstung von Land- und Wasserflaechen', " "DVWK Merkblaetter 238/1996, Bonn, 135p.\n" "- Boehner, J., Schaefer, W., Conrad, O., Gross, J., Ringeler, A. (2001): " "'The WEELS Model: methods, results and limits of wind erosion modelling', " "In: Catena, Special Issue\n") ); //----------------------------------------------------- pNode = Parameters.Add_Grid( NULL , "STA_FC" , _TL("Field Capacity [mm]"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "STA_FC_DEF" , _TL("Default"), _TL(""), PARAMETER_TYPE_Double , 20.0 , 0.0, true ); pNode = Parameters.Add_Grid( NULL , "STA_PWP" , _TL("Permanent Wilting Point [mm]"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "STA_PWP_DEF" , _TL("Default"), _TL(""), PARAMETER_TYPE_Double , 2.0 , 0.0, true ); pNode = Parameters.Add_Grid( NULL , "LANDUSE" , _TL("Land Use"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Value( pNode , "LANDUSE_DEF" , _TL("Default"), _TL(""), PARAMETER_TYPE_Int , -1.0 ); //----------------------------------------------------- pNode = Parameters.Add_Grid( NULL , "DYN_W" , _TL("Soil Moisture"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- pNode = Parameters.Add_FixedTable( NULL , "DYN_CLIMATE" , _TL("Climate Data"), _TL("") ); pClimate = pNode->asTable(); pClimate->Set_Name(_TL("Climate Data")); pClimate->Add_Field(_TL("Precipitation [mm]") , SG_DATATYPE_Double); pClimate->Add_Field(_TL("Temperature (2pm) [DegreeC]"), SG_DATATYPE_Double); pClimate->Add_Field(_TL("Air Humidity (2pm) [%%]"), SG_DATATYPE_Double); //----------------------------------------------------- pNode = Parameters.Add_FixedTable( NULL , "STA_KC" , _TL("Crop Coefficients"), _TL("") ); pCropCoeff = pNode->asTable(); pCropCoeff->Set_Name(_TL("Crop Coefficients")); pCropCoeff->Add_Field(_TL("Land Use ID") , SG_DATATYPE_Int); pCropCoeff->Add_Field(_TL("Name") , SG_DATATYPE_String); pCropCoeff->Add_Field(_TL("January") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("February") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("March") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("April") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("May") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("June") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("July") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("August") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("September") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("October") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("November") , SG_DATATYPE_Double); pCropCoeff->Add_Field(_TL("December") , SG_DATATYPE_Double); CSG_Table_Record *pRec; #define ADD_RECORD(ID, NAME, m01, m02, m03, m04, m05, m06, m07, m08, m09, m10, m11, m12) pRec = pCropCoeff->Add_Record();\ pRec->Set_Value( 0, ID); pRec->Set_Value( 1, NAME);\ pRec->Set_Value( 2, m01); pRec->Set_Value( 3, m02); pRec->Set_Value( 4, m03); pRec->Set_Value( 5, m04);\ pRec->Set_Value( 6, m05); pRec->Set_Value( 7, m06); pRec->Set_Value( 8, m07); pRec->Set_Value( 9, m08);\ pRec->Set_Value(10, m09); pRec->Set_Value(11, m10); pRec->Set_Value(12, m11); pRec->Set_Value(13, m12); // ID NAME Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dec ADD_RECORD(1.0, _TL("Maehweide") , 1 , 1 , 1 , 1 , 1.05, 1.10, 1.10, 1.05, 1.05, 1 , 1 , 1 ); ADD_RECORD(2.0, _TL("Winterweizen") , 0.65, 0.65, 0.80, 0.85, 1.15, 1.45, 1.40, 1 , 0.80, 0.70, 0.65, 0.65); ADD_RECORD(3.0, _TL("Wintergerste") , 1 , 1 , 0.85, 0.95, 1.30, 1.35, 1.25, 1 , 1 , 1 , 1 , 1 ); ADD_RECORD(4.0, _TL("Sommergerste") , 1 , 1 , 0.80, 0.90, 1.20, 1.35, 1.20, 1 , 1 , 1 , 1 , 1 ); ADD_RECORD(5.0, _TL("Winterroggen") , 0.65, 0.65, 0.85, 0.90, 1.20, 1.30, 1.25, 0.95, 0.80, 0.70, 0.65, 0.65); ADD_RECORD(6.0, _TL("Hafer" ) , 1 , 1 , 0.65, 0.70, 1.10, 1.45, 1.35, 0.95, 1 , 1 , 1 , 1 ); ADD_RECORD(7.0, _TL("Zuckerrueben") , 1 , 1 , 1 , 0.50, 0.75, 1.05, 1.40, 1.30, 1.10, 0.85, 1 , 1 ); ADD_RECORD(8.0, _TL("Kartoffeln") , 1 , 1 , 1 , 0.50, 0.90, 1.05, 1.45, 1.20, 0.90, 1 , 1 , 1 ); ADD_RECORD(9.0, _TL("Winterraps") , 0.65, 0.65, 0.85, 1 , 1.35, 1.35, 1.10, 0.85, 1 , 1 , 0.65, 0.65); ADD_RECORD(0.0, _TL("Unknown") , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ); #undef ADD_RECORD } //--------------------------------------------------------- CDVWK_SoilMoisture::~CDVWK_SoilMoisture(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDVWK_SoilMoisture::On_Execute(void) { int Day, x, y, i, LandUseID; CSG_Grid *pGrid; //----------------------------------------------------- if( pClimate->Get_Record_Count() > 0 ) { pFK_mm = Parameters("STA_FC") ->asGrid(); FK_mm_Def = Parameters("STA_FC_DEF") ->asDouble(); pPWP_mm = Parameters("STA_PWP") ->asGrid(); PWP_mm_Def = Parameters("STA_PWP_DEF") ->asDouble(); pWi_mm = Parameters("DYN_W") ->asGrid(); DataObject_Set_Colors(pWi_mm, 100, SG_COLORS_YELLOW_BLUE); //------------------------------------------------- pLandUse = SG_Create_Grid(pWi_mm, pCropCoeff->Get_Record_Count() < 127 ? SG_DATATYPE_Char : SG_DATATYPE_Int); pLandUse->Assign(Parameters("LANDUSE_DEF")->asInt()); if( (pGrid = Parameters("LANDUSE")->asGrid()) != NULL ) { for(y=0; yasInt(x, y); for(i=0; iGet_Record_Count(); i++) { if( LandUseID == pCropCoeff->Get_Record(i)->asInt(0) ) { pLandUse->Set_Value(x, y, i); break; } } } } } //------------------------------------------------- DataObject_Update(pWi_mm, 0, pFK_mm ? pFK_mm->Get_ZMax() : FK_mm_Def, true); for(Day=0; Day<365 && Set_Progress(Day, 365); Day++) { Step_Day(Day); DataObject_Update(pWi_mm, true); } //------------------------------------------------- delete(pLandUse); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CDVWK_SoilMoisture::Get_Month(int Day) { const int Days[] = // Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; int iMonth, nDays; Day %= 365; if( Day < 0 ) { Day += 365; } for(iMonth=0, nDays=0; iMonth<12; iMonth++) { nDays += Days[iMonth]; if( Day < nDays ) { return( iMonth + 1 ); } } return( 12 ); } //--------------------------------------------------------- // VKR 4.10: Bestandeskoeffizient z.Ber.d.pot.Verdunstung d.Pflbest. (kc) // // Bestand : Typ (als ENUM) des Pflanzenbestandes // Month : 1=Jan, 2=Feb... 0=NA; // double CDVWK_SoilMoisture::Get_kc(int Bestand, int Day) { if( Bestand >= 0 && Bestand < pCropCoeff->Get_Record_Count() ) { return( pCropCoeff->Get_Record(Bestand)->asDouble(1 + Get_Month(Day)) ); } return( 1.0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CDVWK_SoilMoisture::Get_ETP_Haude(int Day) { const double f[] = // --- Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez { 0.00, 0.22, 0.22, 0.22, 0.29, 0.29, 0.28, 0.26, 0.25, 0.23, 0.22, 0.22, 0.22 }; double T14, U14, es, e, ETP_Haude; //----------------------------------------------------- CSG_Table_Record *pRecord; if( (pRecord = pClimate->Get_Record(Day)) == NULL ) { return( 0 ); } T14 = pRecord->asDouble(1); U14 = pRecord->asDouble(2); //----------------------------------------------------- // VKR 4.6: Berechnung des Saettigungsdampfdruckes (es [hPa]) // // 17,62 * T14 // es(T14) = 6,11 * exp( -------------- ); bei T14 > 0 // 243,12 + T14 // // 22,46 * T14 // es(T14) = 6,11 * exp( -------------- ); bei T14 < 0 // 272,62 + T14 // // T14 : Temperatur 14 Uhr [DegreeC] // if( T14 < 0 ) { es = 6.11 * exp( (22.46 * T14) / (272.62 + T14) ); } else { es = 6.11 * exp( (17.62 * T14) / (243.12 + T14) ); } //----------------------------------------------------- // VKR 4.7: Berechnung des aktuellen Dampfdruckes (e [hPa]) // // e = es(T14) * U14 / 100 // // es(T14) : Saettigungsdampfdruck 14 Uhr [hPa] // U14 : relative Luftfeuchte 14 Uhr [%] (Dampfdruck in % des Saettigungsdampfdruckes) // e = es * U14 / 100.0; //----------------------------------------------------- // VKR 4.8: Berechnung der potentiellen Verdunstung nach Haude (ETPhaude [mm/d]) // // ETPhaude = f(m) * (es - e) // // f(m) : Monatsfaktor [mm/mbar/d] // e : aktueller Dampfdruck [hPa] // es : Saettigungsdampfdruck // ETP_Haude = f[Get_Month(Day)] * (es - e); return( ETP_Haude ); } //--------------------------------------------------------- double CDVWK_SoilMoisture::Get_Pi(int Day) { const double Messfehler[] = // --- Jan Feb Mar Apr Mai Jun Jul Aug Sep Okt Nov Dez { 0.000, 0.228, 0.236, 0.200, 0.160, 0.120, 0.103, 0.105, 0.103, 0.115, 0.136, 0.162, 0.189 }; double P, Pi; //----------------------------------------------------- CSG_Table_Record *pRecord; if( (pRecord = pClimate->Get_Record(Day)) == NULL ) { return( 0 ); } P = pRecord->asDouble(0); //----------------------------------------------------- // VKR 4.11: Berechnung der korrigierten Niederschlaege (Pi [mm/d]) // // Pi = N * kn // // N : Niederschlag gemessen [mm/d] // kn : Korrekturfaktor ergibt sich aus den prozentualen Meßfehlern... // Month : 1=Jan, 2=Feb... 0=NA; // Pi = P + P * Messfehler[Get_Month(Day)]; return( Pi ); } //--------------------------------------------------------- double CDVWK_SoilMoisture::Get_Wi(double Wi, double Pi, double ETP, double kc, double FK, double PWP) { double Ri, d, ETPi, ETAi; //----------------------------------------------------- // VKR 4.9: Berechnung des Reduktionsfaktors f.Verdunstung (Ri) // // PWP // 1 - ----- // Wi ETP Ri = 1 bei Pi > ETPi // Ri = ------------- + 0,1 * ------; Ri = 1 bei Ri > 1,0 // PWP ETPi Ri = 0 bei Ri < 0,0 // 1 - ----- // FK // // Pi : korrigierter Niederschlag [mm/d] // Wi : Bodenwassergehalt // PWP : Permanenter Welkepunkt // FK : Feldkapazitaet // kc : Koeffizient f.d. Pflz.Bestand // ETPi = ETP * kc; if( Pi > ETPi ) { Ri = 1.0; } else if( ETPi <= 0.0 || Wi <= 0.0 || FK <= 0.0 ) { Ri = 0.0; } else { d = 1.0 - PWP / FK; if( d == 0.0 ) { Ri = 0.0; } else { Ri = (1.0 - PWP / Wi) / d + 0.1 * ETP / ETPi; if( Ri > 1.0 ) { Ri = 1.0; } else if( Ri < 0.0 ) { Ri = 0.0; } } } //----------------------------------------------------- // VKR 4.13: Berechnung der tatsaechlichen Verdunstung (ETa [mm/d]) // // ETai = Pi - (Pi - (ETPhaude * kc)) * Ri // // Pi : korrigierter Niederschlag [mm/d] // ETPhaude : potentielle Verdunstung nach Haude [mm/d] // kc : Bestandeskoeffizient // Ri : Reduktionsfaktor // ETAi = Pi - (Pi - ETPi) * Ri; //----------------------------------------------------- // VKR 4.14: Berechnung des Bodenwasservorrats (Wi [mm/d]) // // Wi+1 = Wi + Pi - ETai - SRi + KR // // Pi : korrigierter Niederschlag [mm/d] // ETai : tatsaechliche Verdunstung [mm/d] // SRi : taegliche Sickerwaserrate [mm/d] // SRi = 0 bei Wi+1 <= FK * ku // SRi = Wi+1 - FK * ku bei Wi+1 > FK * ku; // FK : Feldkapazitaet [mm] // ku : moegliche Uebersaettigung ueber FK := 1 (findet keine Beruecksichtigung) // KR : kapillare Aufstiegsrate := 0 (findet keine Beruecksichtigung) // Wi += Pi - ETAi; if( Wi > FK ) { Wi = FK; // -= SRi... } else if( Wi < PWP ) { Wi = PWP; } return( Wi ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CDVWK_SoilMoisture::Step_Day(int Day) { int x, y; double Wi, Pi, ETP, kc, FK, PWP; ETP = Get_ETP_Haude(Day); Pi = Get_Pi(Day); for(y=0; yasInt(x, y), Day); FK = pFK_mm ? pFK_mm ->asDouble(x, y) : FK_mm_Def; PWP = pPWP_mm ? pPWP_mm ->asDouble(x, y) : PWP_mm_Def; Wi = pWi_mm->asDouble(x, y); Wi = Get_Wi(Wi, Pi, ETP, kc, FK, PWP); pWi_mm->Set_Value(x, y, Wi); } } } saga-2.3.1/src/modules/simulation/sim_hydrology/topmodel.cpp0000744000175000017500000004640612737416207025452 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topmodel.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // topmodel.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "topmodel.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTOPMODEL::CTOPMODEL(void) { CSG_Parameter *pNode; //----------------------------------------------------- // Place information about your module here... Set_Name (_TL("TOPMODEL")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Simple Subcatchment Version of TOPMODEL\n\n" "Based on the 'TOPMODEL demonstration program v95.02' by Keith Beven " "(Centre for Research on Environmental Systems and Statistics, " "Institute of Environmental and Biological Sciences, " "Lancaster University, Lancaster LA1 4YQ, UK) " "and the C translation of the Fortran source codes implemented in GRASS.\n\n" "This program allows single or multiple subcatchment calculations " "but with single average rainfall and potential evapotranspiration " "inputs to the whole catchment. Subcatchment discharges are routed " "to the catchment outlet using a linear routing algorithm with " "constant main channel velocity and internal subcatchment " "routing velocity. The program requires ln(a/tanB) distributions " "for each subcatchment. These may be calculated using the " "GRIDATB program which requires raster elevation data as input. " "It is recommended that those data should be 50 m resolution or " "better.\n\n" "NOTE that TOPMODEL is not intended to be a traditional model " "package but is more a collection of concepts that can be used " "**** where appropriate ****. It is up to the user to verify that " "the assumptions are appropriate (see discussion in " "Beven et al.(1994). This version of the model will be " "best suited to catchments with shallow soils and moderate " "topography which do not suffer from excessively long dry " "periods. Ideally predicted contributing areas should be " "checked against what actually happens in the catchment.\n\n" "It includes infiltration excess calculations and parameters " "based on the exponential conductivity Green-Ampt model of " "Beven (HSJ, 1984) but if infiltration excess does occur it " "does so over whole area of a subcatchment. Spatial variability " "in conductivities can however be handled by specifying " "Ko parameter values for different subcatchments, even if they " "have the same ln(a/tanB) and routing parameters, ie. to " "represent different parts of the area.\n\n" "Note that time step calculations are explicit ie. SBAR " "at start of time step is used to determine contributing area. " "Thus with long (daily) time steps contributing area depends on " "initial value together with any volume filling effect of daily " "inputs. Also baseflow at start of time step is used to update " "SBAR at end of time step." "\n\nReferences\n" "- Beven, K., Kirkby, M.J., Schofield, N., Tagg, A.F. (1984): " " Testing a physically-based flood forecasting model (TOPMODEL) for threee U.K. catchments, " " Journal of Hydrology, H.69, S.119-143.\n" "\n" "- Beven, K. (1997): " " TOPMODEL - a critique, " " Hydrological Processes, Vol.11, pp.1069-1085.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "ATANB" , _TL("Topographic Wetness Index"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "MOIST" , _TL("Soil Moisture Deficit"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); pNode = Parameters.Add_Table( NULL , "WEATHER" , _TL("Weather Records"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "RECORD_P" , _TL("Precipitation [m / dt]"), _TL("") ); Parameters.Add_Table_Field( pNode , "RECORD_ET" , _TL("Evapotranspiration [m / dt]"), _TL("") ); Parameters.Add_Table_Field( pNode , "RECORD_DATE" , _TL("Date/Time"), _TL(""), true ); Parameters.Add_Table( NULL , "TABLE" , _TL("Simulation Output"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "DTIME" , _TL("Time Step [h]"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "NCLASSES" , _TL("Number of Classes"), _TL(""), PARAMETER_TYPE_Int , 30 , 1 , true ); pNode = NULL; // = Parameters("MOIST"); Parameters.Add_Value( pNode, "P_QS0" , _TL("Initial subsurface flow per unit area [m/h]"), _TL(""), PARAMETER_TYPE_Double , 3.28e-05 ); Parameters.Add_Value( pNode, "P_LNTE" , _TL("Areal average of ln(T0) = ln(Te) [ln(m^2/h)]"), _TL(""), PARAMETER_TYPE_Double , 5.0 ); Parameters.Add_Value( pNode, "P_MODEL" , _TL("Model parameter [m]"), _TL(""), PARAMETER_TYPE_Double , 0.032 ); Parameters.Add_Value( pNode, "P_SR0" , _TL("Initial root zone storage deficit [m]"), _TL(""), PARAMETER_TYPE_Double , 0.002 ); Parameters.Add_Value( pNode, "P_SRZMAX" , _TL("Maximum root zone storage deficit [m]"), _TL(""), PARAMETER_TYPE_Double , 0.05 ); Parameters.Add_Value( pNode, "P_SUZ_TD" , _TL("Unsaturated zone time delay per unit storage deficit [h]"), _TL(""), PARAMETER_TYPE_Double , 50.0 ); Parameters.Add_Value( pNode, "P_VCH" , _TL("Main channel routing velocity [m/h]"), _TL(""), PARAMETER_TYPE_Double , 3600.0 ); Parameters.Add_Value( pNode, "P_VR" , _TL("Internal subcatchment routing velocity [m/h]"), _TL(""), PARAMETER_TYPE_Double , 3600.0 ); Parameters.Add_Value( pNode, "P_K0" , _TL("Surface hydraulic conductivity [m/h]"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( pNode, "P_PSI" , _TL("Wetting front suction [m]"), _TL(""), PARAMETER_TYPE_Double , 0.02 ); Parameters.Add_Value( pNode, "P_DTHETA" , _TL("Water content change across the wetting front"), _TL(""), PARAMETER_TYPE_Double , 0.1 ); Parameters.Add_Value( pNode, "BINF" , _TL("Green-Ampt Infiltration"), _TL(""), PARAMETER_TYPE_Bool , true ); } //--------------------------------------------------------- CTOPMODEL::~CTOPMODEL(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTOPMODEL::On_Execute(void) { bool bInfiltration; sLong n; int iClass, nClasses, iTime, nTimeSteps, k; double Precipitation, Evaporation, Infiltration, Infiltration_Excess; CSG_String Time; CSG_Grid *pAtanB, *pMoist, gClass; CSG_Table_Record *pRecord; CSG_Table *pTable; //----------------------------------------------------- // Get user inputs from the 'Parameters' object... pAtanB = Parameters("ATANB") ->asGrid(); m_pWeather = Parameters("WEATHER") ->asTable(); m_fP = Parameters("RECORD_P") ->asInt(); m_fET = Parameters("RECORD_ET") ->asInt(); m_fTime = Parameters("RECORD_DATE") ->asInt(); dTime = Parameters("DTIME") ->asDouble(); nClasses = Parameters("NCLASSES") ->asInt(); bInfiltration = Parameters("BINF") ->asBool(); nTimeSteps = m_pWeather->Get_Record_Count(); if( (pMoist = Parameters("MOIST")->asGrid()) != NULL ) { pMoist->Set_Name(_TL("Soil Moisture Deficit")); DataObject_Set_Colors(pMoist, 100, SG_COLORS_RED_GREY_BLUE, true); } //----------------------------------------------------- pTable = Parameters("TABLE")->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("TOPMODEL - Simulation Output")); pTable->Add_Field(_TL("Time") , SG_DATATYPE_String); pTable->Add_Field(_TL("Total flow (in watershed) [m^3/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Total flow [m/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Saturation overland flow [m/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Subsurface flow [m/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Vertical (drainage) flux [m/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Mean saturation deficit (in watershed) [m]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Infiltration rate [m/dt]") , SG_DATATYPE_Double); pTable->Add_Field(_TL("Infiltration excess runoff [m/dt]") , SG_DATATYPE_Double); //----------------------------------------------------- Vals.Create(dTime, nTimeSteps, &Parameters, pAtanB, nClasses, &gClass); //----------------------------------------------------- inf_bPonding = false; inf_cumf = 0.0; for(iTime=0; iTime 0.0 ) { Infiltration = dTime * Get_Infiltration((iTime + 1) * dTime, Precipitation / dTime); Infiltration_Excess = Precipitation - Infiltration; Precipitation = Infiltration; } else { Infiltration = 0.0; Infiltration_Excess = 0.0; } Run(Evaporation, Precipitation, Infiltration_Excess); for(iClass=0; iClass nTimeSteps - 1 ) break; Vals.Qt_[k] += Vals.qt_Total * Vals.Add[iClass]; } if( pMoist ) { for(n=0; n= 0 && iClass < nClasses ) { pMoist->Set_Value(n, Vals.Get_Class(iClass)->S_); } else { pMoist->Set_NoData(n); } } // DataObject_Update(pMoist); DataObject_Update(pMoist, 0, 0.35, true); } pRecord = pTable->Add_Record(); pRecord->Set_Value(0, Time); // Time pRecord->Set_Value(1, Vals.Qt_[iTime]); // QT pRecord->Set_Value(2, Vals.qt_Total); // qt pRecord->Set_Value(3, Vals.qo_Total); // q0 pRecord->Set_Value(4, Vals.qs_Total); // qs pRecord->Set_Value(5, Vals.qv_Total); // qv pRecord->Set_Value(6, Vals.Sbar_); // SBar pRecord->Set_Value(7, Infiltration); // Infiltration pRecord->Set_Value(8, Infiltration_Excess); // Infiltration Excess DataObject_Update(pTable); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CTOPMODEL::Run(double Evaporation, double Precipitation, double Infiltration_Excess) { int iClass; double d, Excess; CTOPMODEL_Class *pClass; Vals.qo_Total = 0.0; Vals.qv_Total = 0.0; Vals.qs_Total = Vals._qs_ * exp(-Vals.Sbar_ / Vals.p_Model); for(iClass=0; iClassS_ = Vals.Sbar_ + Vals.p_Model * (Vals.Get_Lambda() - pClass->AtanB); if( pClass->S_ < 0.0 ) { pClass->S_ = 0.0; } //------------------------------------------------- // ROOT ZONE CALCULATIONS pClass->Srz_ -= Precipitation; if( pClass->Srz_ < 0.0 ) { pClass->Suz_ -= pClass->Srz_; pClass->Srz_ = 0.0; } //------------------------------------------------- // UNSATURATED ZONE CALCULATIONS if( pClass->Suz_ > pClass->S_ ) { Excess = pClass->Suz_ - pClass->S_; pClass->Suz_ = pClass->S_; } else { Excess = 0.0; } //------------------------------------------------- // CALCULATE DRAINAGE FROM SUZ (Vertical Soil Water Flux (qv))... if( pClass->S_ > 0.0 ) { if( Vals.p_Suz_TimeDelay > 0.0 ) { // Methode 1... d = pClass->Suz_ / (pClass->S_ * Vals.p_Suz_TimeDelay) * dTime; // GRASS } else { // Methode 2... d = -Vals.p_Suz_TimeDelay * Vals.p_K0 * exp(-pClass->S_ / Vals.p_Model); } if( d > pClass->Suz_ ) { d = pClass->Suz_; } pClass->Suz_ -= d; if( pClass->Suz_ < 0.0000001 ) { pClass->Suz_ = 0.0; } pClass->qv_ = d * pClass->Area_Rel; Vals.qv_Total += pClass->qv_; } else { pClass->qv_ = 0.0; } //------------------------------------------------- // CALCULATE EVAPOTRANSPIRATION FROM ROOT ZONE DEFICIT if( Evaporation > 0.0 ) { d = Evaporation * (1.0 - pClass->Srz_ / Vals.p_Srz_Max); if( d > Vals.p_Srz_Max - pClass->Srz_ ) { d = Vals.p_Srz_Max - pClass->Srz_; } pClass->Srz_ += d; } //------------------------------------------------- pClass->qo_ = Excess * pClass->Area_Rel; Vals.qo_Total += pClass->qo_; pClass->qt_ = pClass->qo_ + Vals.qs_Total; } Vals.qo_Total += Infiltration_Excess; Vals.qt_Total = Vals.qo_Total + Vals.qs_Total; Vals.Sbar_ += Vals.qs_Total - Vals.qv_Total; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CTOPMODEL::Get_Weather(int iTimeStep, double &Precipitation, double &Evaporation, CSG_String &Time) { CSG_Table_Record *pRecord; if( m_pWeather && (pRecord = m_pWeather->Get_Record(iTimeStep)) != NULL ) { Precipitation = pRecord->asDouble(m_fP); Evaporation = pRecord->asDouble(m_fET); if( m_fTime >= 0 ) { Time = pRecord->asString(m_fTime); } else { Time.Printf(SG_T("%d"), iTimeStep); } return( true ); } Precipitation = 0.0; Evaporation = 0.0; return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define NEWTON_EPSILON 0.001 #define NEWTON_MAXITER 100 #define NEWTON_NTERMS 10 //--------------------------------------------------------- double CTOPMODEL::Get_Infiltration(double t, double R) { int i, j, factorial; double f, f_, f1, f2, fc, R2, cnst, pt, psi_dtheta, sum; if( R <= 0.0 ) { inf_cumf = 0.0; inf_bPonding = 0; return( 0.0 ); } psi_dtheta = Vals.p_Psi * Vals.p_dTheta; if( !inf_bPonding ) { if( inf_cumf ) { f1 = inf_cumf; R2 = -Vals.p_K0 / Vals.p_Model * (psi_dtheta + f1) / (1 - exp(f1 / Vals.p_Model)); if( R2 < R ) { f_ = inf_cumf; pt = t - dTime; inf_bPonding = 1; goto cont1; } } f2 = inf_cumf + R * dTime; R2 = -Vals.p_K0 / Vals.p_Model * (psi_dtheta + f2) / (1 - exp(f2 / Vals.p_Model)); if( f2 == 0.0 || R2 > R ) { f = R; inf_cumf += f * dTime; inf_bPonding = 0; return( f ); } f_ = inf_cumf + R2 * dTime; for(i=0; i R ) { f1 = f_; f_ = (f_ + f2) / 2.0; f = f_ - f1; } else { f2 = f_; f_ = (f_ + f1) / 2.0; f = f_ - f2; } if( fabs(f) < NEWTON_EPSILON ) break; } if( i == NEWTON_MAXITER ) { // G_set_d_null_value(&f, 1); return( 0.0 ); } pt = t - dTime + (f_ - inf_cumf) / R; if( pt > t ) { f = R; inf_cumf += f * dTime; inf_bPonding = 0; return( f ); } cont1: cnst = 0.0; factorial = 1; fc = (f_ + psi_dtheta); for(j=1; j<=NEWTON_NTERMS; j++) { factorial *= j; cnst += pow(fc / Vals.p_Model, (double) j) / (double) (j * factorial); } cnst = log(fc) - (log(fc) + cnst) / exp(psi_dtheta / Vals.p_Model); f_ += R * (t - pt) / 2.0; inf_bPonding = 1; } for(i=0; iGet_NY(); y++){ for(x=0; xGet_NX(); x++){ Get_Grid_Value(x,y); }// for }// for }//method //--------------------------------------------------------- bool CIDW::Get_Grid_Value(int x, int y) { int iPoint, nPoints; double zSum, dSum, d, dx, xPos, yPos; TSG_Point Point; CSG_Shape *pPoint; nPoints = m_pPoints->Get_Count(); xPos = m_pGrid->Get_XMin() + x * m_pGrid->Get_Cellsize(); yPos = m_pGrid->Get_YMin() + y * m_pGrid->Get_Cellsize(); for(iPoint=0, zSum=0.0, dSum=0.0; iPointGet_Shape(iPoint); Point = pPoint->Get_Point(0); dx = Point.x - xPos; d = Point.y - yPos; d = sqrt(dx*dx + d*d); if( d <= 0.0 ){ m_pGrid->Set_Value(x, y, pPoint->asDouble(m_iField) ); return( true ); }//if d = pow(d, -2); zSum += d * pPoint->asDouble(m_iField); dSum += d; }//for if( dSum > 0.0 ){ m_pGrid->Set_Value(x, y, zSum / dSum ); return( true ); }//if m_pGrid->Set_NoData(x, y); return( false ); }//methodsaga-2.3.1/src/modules/simulation/sim_hydrology/Makefile.am0000744000175000017500000000156412737416207025153 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_hydrology.la libsim_hydrology_la_SOURCES =\ DVWK_SoilMoisture.cpp\ diffuse_pollution_risk.cpp\ diffusion_gradient_concentration.cpp\ idw.cpp\ KinWav_D8.cpp\ MLB_Interface.cpp\ topmodel.cpp\ topmodel_values.cpp\ WaterRetentionCapacity.cpp\ diffuse_pollution_risk.h\ diffusion_gradient_concentration.h\ DVWK_SoilMoisture.h\ idw.h\ KinWav_D8.h\ MLB_Interface.h\ topmodel.h\ topmodel_values.h\ WaterRetentionCapacity.h libsim_hydrology_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/simulation/sim_hydrology/topmodel_values.h0000744000175000017500000001426412737416207026473 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topmodel_values.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // topmodel_values.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__topmodel_values_H #define HEADER_INCLUDED__topmodel_values_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTOPMODEL_Class { public: CTOPMODEL_Class(double Srz_Init); virtual ~CTOPMODEL_Class(void); double qt_, qo_, qv_, Srz_, Suz_, S_, AtanB, Area_Rel; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTOPMODEL_Values { public: CTOPMODEL_Values(void); virtual ~CTOPMODEL_Values(void); int ndelay_, nreach_; double qt_Total, qo_Total, qv_Total, qs_Total, lnTe_, _qs_, *Add, // nreach_'s: *Qt_, // input.ntimestep's: Sbar_, p_Srz_Max, // Maximum root zone storage deficit [m] p_Model, // Model parameter m... p_Suz_TimeDelay, // Unsaturated zone time delay per unit storage deficit ( > 0.0) [h] // OR -alpha: Effective vertical hydraulic gradient ( <= 0.0); -10 means that alpha = 10 p_K0, // Surface hydraulic conductivity [m/h] p_Psi, // Wetting front suction [m] p_dTheta; // Water content change across the wetting front void Create(double dTime, int anTimeSteps, CSG_Parameters *pParameters, CSG_Grid *pAtanB, int anClasses, CSG_Grid *pClass); void Destroy(void); //----------------------------------------------------- int Get_Count(void) { return( nClasses ); } //----------------------------------------------------- double Get_Area_Total(void) { return( Area_Total ); } //----------------------------------------------------- CTOPMODEL_Class * Get_Class(int iClass) { if( iClass >= 0 && iClass < nClasses ) { return( Classes[iClass] ); } return( NULL ); } //----------------------------------------------------- double Get_Lambda(void) { return( Lambda ); } private: int nClasses, Channel_Count; double Lambda, *Channel_Distance, *Channel_AreaRatio, Area_Total; // Total catchment area [m^2] CTOPMODEL_Class **Classes; }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__topmodel_values_H saga-2.3.1/src/modules/simulation/sim_hydrology/MLB_Interface.h0000744000175000017500000000773112737416207025664 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__sim_hydrology_H #define HEADER_INCLUDED__sim_hydrology_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef sim_hydrology_EXPORTS #define sim_hydrology_EXPORT _SAGA_DLL_EXPORT #else #define sim_hydrology_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__sim_hydrology_H saga-2.3.1/src/modules/simulation/sim_hydrology/MLB_Interface.cpp0000744000175000017500000001220012737416207026202 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Hydrology") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2001") ); case MLB_INFO_Description: return( _TL("Modelling hydrological processes.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Hydrology") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "DVWK_SoilMoisture.h" #include "KinWav_D8.h" #include "topmodel.h" #include "WaterRetentionCapacity.h" #include "diffuse_pollution_risk.h" #include "diffusion_gradient_concentration.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CDVWK_SoilMoisture ); case 1: return( new CKinWav_D8 ); case 2: return( new CTOPMODEL ); case 3: return( new CWaterRetentionCapacity ); case 4: return( new CDiffuse_Pollution_Risk ); case 5: return( new CSim_Diffusion_Gradient ); case 6: return( new CSim_Diffusion_Concentration ); case 7: return( new CSim_Diffusion_Gradient_And_Concentration ); case 9: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/simulation/sim_hydrology/topmodel_values.cpp0000744000175000017500000002405212737416207027022 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: topmodel_values.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_hydrology // // // //-------------------------------------------------------// // // // topmodel_values.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "topmodel_values.h" //--------------------------------------------------------- #define RESET_ARRAY(a) if( a ) { free(a); a = NULL; } #define RESET_MATRIX(n, m) if( n > 0 && m ) { for(int i=0; i 0 ) { for(iClass=0; iClass 0 ) { //------------------------------------------------- // 1. Topographic Index Classification etc... nClasses = anClasses; Classes = (CTOPMODEL_Class **)calloc(nClasses, sizeof(CTOPMODEL_Class *)); for(iClass=0; iClassGet_Parameter("P_SR0")->asDouble()); } zMin = pAtanB->Get_ZMin(); zRange = pAtanB->Get_ZMax() - zMin; dz = zRange / (nClasses + 1); nCells = 0; pClass->Create(pAtanB, SG_DATATYPE_Short); pClass->Set_NoData_Value(-9999); for(n=0; nGet_NCells(); n++) { if( !pAtanB->is_NoData(n) ) { nCells++; iClass = (int)((nClasses - 1.0) * (pAtanB->asDouble(n) - zMin) / zRange); Classes[iClass]->Area_Rel++; pClass->Set_Value(n, iClass); } else { pClass->Set_NoData(n); } } Area_Total = (double)nCells * pAtanB->Get_Cellsize() * pAtanB->Get_Cellsize(); for(iClass=0; iClassAtanB = zMin + dz * (iClass + 0.5); // mid of class -> + 0.5... Classes[iClass]->Area_Rel /= (double)nCells; } //------------------------------------------------- // 2. Calculate Lambda, the catchment average topographic index... for(iClass=0, Lambda=0.0; iClassArea_Rel * Classes[iClass]->AtanB; } //------------------------------------------------- // 3. Parameter Initialisation... //------------------------------------------------- p_Srz_Max = pParameters->Get_Parameter("P_SRZMAX")->asDouble(); p_Model = pParameters->Get_Parameter("P_MODEL")->asDouble(); p_Suz_TimeDelay = pParameters->Get_Parameter("P_SUZ_TD")->asDouble(); p_K0 = pParameters->Get_Parameter("P_K0")->asDouble(); p_Psi = pParameters->Get_Parameter("P_PSI")->asDouble(); p_dTheta = pParameters->Get_Parameter("P_DTHETA")->asDouble(); //------------------------------------------------- int i, j, t; double A1, A2, qs0_, // Initial subsurface flow per unit area [m/h], "The first streamflow input is assumed to represent only the subsurface flow contribution in the watershed." vch_, // Main channel routing velocity [m/h] vr_, // Internal subcatchment routing velocity [m/h] *tch_; // params.nch's //------------------------------------------------- lnTe_ = log(dTime) + pParameters->Get_Parameter("P_LNTE")->asDouble(); vch_ = dTime * pParameters->Get_Parameter("P_VCH")->asDouble(); vr_ = dTime * pParameters->Get_Parameter("P_VR")->asDouble(); qs0_ = dTime * pParameters->Get_Parameter("P_QS0")->asDouble(); _qs_ = exp(lnTe_ - Lambda); //------------------------------------------------- tch_ = (double *)malloc(Channel_Count * sizeof(double)); tch_[0] = Channel_Distance[0] / vch_; for(i=1; i tch_[Channel_Count - 1]) { Add[i] = 1.0; } else { for(j=1; j&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/simulation/sim_erosion ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_erosion_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_erosion_la_OBJECTS = MMF_SAGA.lo MLB_Interface.lo libsim_erosion_la_OBJECTS = $(am_libsim_erosion_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_erosion_la_SOURCES) DIST_SOURCES = $(libsim_erosion_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1537 2012-11-19 20:05:19Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_erosion.la libsim_erosion_la_SOURCES = \ MMF_SAGA.cpp\ MLB_Interface.cpp\ MMF_SAGA.h\ MLB_Interface.h libsim_erosion_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/simulation/sim_erosion/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_erosion/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_erosion.la: $(libsim_erosion_la_OBJECTS) $(libsim_erosion_la_DEPENDENCIES) $(EXTRA_libsim_erosion_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_erosion_la_OBJECTS) $(libsim_erosion_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MMF_SAGA.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/simulation/sim_erosion/MMF_SAGA.cpp0000744000175000017500000011301612737416206024466 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_erosion // // // //-------------------------------------------------------// // // // MMF_SAGA.cpp // // // // Copyright (C) 2009-12 by // // Volker Wichmann // // Muhammad Setiawan // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Implementation of the CMMF_SAGA class. // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MMF_SAGA.h" /////////////////////////////////////////////////////////// // // // Construction/Destruction // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMMF_SAGA::CMMF_SAGA(void) { // CSG_Parameter *pNodeTerrain, *pNodeVegetation, *pNodeSoil, *pNodeClimate, *pNodeOptions, *pNodeOutput; Set_Name (_TL("MMF-SAGA Soil Erosion Model")); Set_Author (SG_T("(c) 2009-2012 V. Wichmann, M. Setiawan")); Set_Description(_TW("Soil erosion modelling with a modified MMF (Morgan-Morgan-Finney) model " "(Morgan & Duzant 2008).
    " "This module is called MMF-SAGA because some things have been implemented differently " "compared to the original publication. The most important are:

    " "
      " "
    • the extension of the model to support spatially distributed modelling
    • " "
    • the introduction of a \"Channel Network\" layer
    • " "
    • the introduction of a \"rainfall duration\" (time span) parameter
    • " "
    • the exposure of the flow depth parameter
    • " "
    " "

    " "A more detailed description of the model, its modifications, and " "model application is provided by Setiawan (2012), chapter 6.
    " "Currently, a number of additional grid datasets are outputted to facilitate " "model evaluation. This can be easily changed within the source code.
    " "

    " "References:
    " "Morgan, R.P.C. (2001): A simple approach to soil loss prediction: a revised " "Morgan-Morgan-Finney model. Catena 44: 305-322.

    " "Morgan, R.P.C., Duzant, J.H. (2008): Modified MMF (Morgan-Morgan-Finney) model " "for evaluating effects of crops and vegetation cover on soil erosion. Earth " "Surf. Process. Landforms 32: 90-106.

    " "" "Setiawan, M. A. (2012): Integrated Soil Erosion Management in the upper Serayu " "Watershed, Wonosobo District, Central Java Province, Indonesia. Dissertation at " "the Faculty of Geo- and Atmospheric Sciences of the University of Innsbruck, Austria." "

    " )); // comments on equation numbers refer to Morgan & Duzant (2008) //pNodeTerrain = Parameters.Add_Node(NULL, "TERRAIN", _TL("Terrain"), _TL("Terrain parameters")); Parameters.Add_Grid( NULL, "DTM", _TL("Digital Terrain Model"), _TL("DTM, digital terrain model [m]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "S", _TL("Slope"), _TL("S, slope [rad]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "CHANNEL", _TL("Channel Network"), _TL("Channel network, all other cells NoData"), PARAMETER_INPUT_OPTIONAL ); //pNodeVegetation = Parameters.Add_Node(NULL, "VEGETATION", _TL("Vegetation"), _TL("Vegetation parameters")); Parameters.Add_Grid( NULL, "PI", _TL("Permament Interception"), _TL("PI, permanent interception expressed as the proportion [between 0-1] of rainfall"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "CC", _TL("Canopy Cover"), _TL("CC, canopy cover expressed as a portion [between 0-1] of the soil surface protected by vegetation or crop"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "PH", _TL("Plant Height"), _TL("PH, plant height [m], representing the effective height from which raindrops fall from the crop or vegetation"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "EtEo", _TL("Ratio Evapotranspiration"), _TL("Et/Eo, ratio of actual to potential evapotranspiration"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "GC", _TL("Ground cover"), _TL("GC, Ground cover expressed as a portion [between 0-1] of the soil surface protected by vegetation or crop cover on the ground"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "D", _TL("Diameter plant elements"), _TL("D, Average diameter [m] of the individual plants elements (stem, leaves) at the ground surface"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "NV", _TL("Number plant elements"), _TL("NV, Number of plant elements per unit area [number/unit area] at the ground surface"), PARAMETER_INPUT ); //pNodeSoil = Parameters.Add_Node(NULL, "SOIL", _TL("Soil"), _TL("Soil parameters")); Parameters.Add_Grid( NULL, "MS", _TL("Soil moisture (at FC)"), _TL("MS, Soil moisture at field capacity [% w/w]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "BD", _TL("Bulk density top layer"), _TL("BD, Bulk density of the top layer [Mg/m3]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "EHD", _TL("Effective hydrological depth"), _TL("EHD, Effective hydrological depth of the soil [m]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "LP", _TL("Sat. lateral permeability"), _TL("LP, Saturated lateral permeability of the soil [m/day]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "PER_C", _TL("Percentage clays"), _TL("c, Percentage clays [%]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "PER_Z", _TL("Percentage silt"), _TL("z, Percentage silt [%]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "PER_S", _TL("Percentage sand"), _TL("s, Percentage sand [%]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "ST", _TL("Percentage rock fragments"), _TL("ST, Percentage rock fragments on the soil surface [%]"), PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "RFR", _TL("Surface roughness"), _TW("RFR, Surface roughness [cm/m]. In case the surface roughness is not provided as input, v_flow_t is " "set to 1.0, i.e. natural soil surface roughness is not accounted for."), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Table( NULL, "TAB_METEO", _TL("Meteorological data"), _TL("Meteorological data for multiple timestep modelling [model step (day); temperature (Celsius); rainfall (mm), rainfall intensity (mm/h); rainfall duration (day); timespan (days)]"), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_FilePath( Parameters("TAB_METEO"), "OUT_PATH", _TL("Output file path"), _TL("Full path to the directory for the output grids of each model step"), SG_T("\0*.*\0\0*.*\0"), _TL(""), true, true ); //pNodeClimate = Parameters.Add_Node(NULL, "CLIMATE", _TL("Climate"), _TL("Climate parameters")); Parameters.Add_Value( NULL, "INTERFLOW", _TL("Simulate Interflow"), _TL("Simulate interflow"), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("INTERFLOW"), "T", _TL("Mean temperature"), _TL("T, mean temperature [degree C]"), PARAMETER_TYPE_Double, 18.0 ); Parameters.Add_Value( Parameters("INTERFLOW"), "TIMESPAN", _TL("Timespan (days)"), _TL("The number of days to model."), PARAMETER_TYPE_Int, 30.0, 1.0, true, 365, true ); Parameters.Add_Grid( Parameters("INTERFLOW"), "IF", _TL("Interflow"), _TL("IF"), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL, "R", _TL("Rainfall"), _TL("R, height of precipitation in timespan [mm]"), PARAMETER_TYPE_Double, 200.0 ); Parameters.Add_Value( NULL, "I", _TL("Rainfall intensity"), _TL("I, rainfall intensity [mm/h]"), PARAMETER_TYPE_Double, 20.0 ); Parameters.Add_Value( NULL, "Rn", _TL("Rainfall Duration"), _TL("Rn, number of rain days in timespan [-]"), PARAMETER_TYPE_Double, 20.0 ); CSG_String choices; for (int i=0; iasGrid(); if( !pDTM->Set_Index() ) { Error_Set(_TL("index creation failed")); return( false ); } pS = Parameters("S")->asGrid(); pChannel = Parameters("CHANNEL")->asGrid(); pPI = Parameters("PI")->asGrid(); pCC = Parameters("CC")->asGrid(); pPH = Parameters("PH")->asGrid(); pMS = Parameters("MS")->asGrid(); pBD = Parameters("BD")->asGrid(); pEHD = Parameters("EHD")->asGrid(); pEtEo = Parameters("EtEo")->asGrid(); pLP = Parameters("LP")->asGrid(); pGC = Parameters("GC")->asGrid(); pPer_c = Parameters("PER_C")->asGrid(); pPer_z = Parameters("PER_Z")->asGrid(); pPer_s = Parameters("PER_S")->asGrid(); pST = Parameters("ST")->asGrid(); pD = Parameters("D")->asGrid(); pNV = Parameters("NV")->asGrid(); pRFR = Parameters("RFR")->asGrid(); pMeteoTab = Parameters("TAB_METEO")->asTable(); sOutPath = Parameters("OUT_PATH")->asString(); if (pMeteoTab != NULL) { if (sOutPath.Length() == 0) { SG_UI_Msg_Add_Error(_TL("No path for output files specified!")); SG_UI_Msg_Add(_TL("Please provide a path for the output files."), true); return (false); } iRuns = pMeteoTab->Get_Count(); } else iRuns = 1; // check if all input grids are valid within the bounds of the DTM //---------------------------------------------------------------- for (y=0; yis_NoData(x, y)) { InvalidGrid = SG_T(""); if (pS->is_NoData(x, y)) InvalidGrid = SG_T("S"); if (pPI->is_NoData(x, y)) InvalidGrid = SG_T("PI"); if (pCC->is_NoData(x, y)) InvalidGrid = SG_T("CC"); if (pPH->is_NoData(x, y)) InvalidGrid = SG_T("PH"); if (pMS->is_NoData(x, y)) InvalidGrid = SG_T("MS"); if (pBD->is_NoData(x, y)) InvalidGrid = SG_T("BD"); if (pEHD->is_NoData(x, y)) InvalidGrid = SG_T("EHD"); if (pEtEo->is_NoData(x, y)) InvalidGrid = SG_T("EtEo"); if (pLP->is_NoData(x, y)) InvalidGrid = SG_T("LP"); if (pGC->is_NoData(x, y)) InvalidGrid = SG_T("GC"); if (pPer_c->is_NoData(x, y)) InvalidGrid = SG_T("PER_C"); if (pPer_z->is_NoData(x, y)) InvalidGrid = SG_T("PER_Z"); if (pPer_s->is_NoData(x, y)) InvalidGrid = SG_T("PER_S"); if (pST->is_NoData(x, y)) InvalidGrid = SG_T("ST"); if (pD->is_NoData(x, y)) InvalidGrid = SG_T("D"); if (pNV->is_NoData(x, y)) InvalidGrid = SG_T("NV"); if (pRFR != NULL && pRFR->is_NoData(x, y)) InvalidGrid = SG_T("RFR"); if (InvalidGrid.Length() > 0) { Error_Set(CSG_String::Format(_TL("NoData encountered in input grid %s: x %d (%.2f), y %d (%.2f)"), InvalidGrid.c_str(), x, pDTM->Get_System().Get_xGrid_to_World(x), y, pDTM->Get_System().Get_yGrid_to_World(y))); return (false); } } } } #ifdef _TMP_OUT pRf = Parameters("Rf")->asGrid(); pKE = Parameters("KE")->asGrid(); pRc = Parameters("Rc")->asGrid(); pSLc = Parameters("SLc")->asGrid(); pSLz = Parameters("SLz")->asGrid(); pSLs = Parameters("SLs")->asGrid(); pW_up = Parameters("W_up")->asGrid(); pTCc = Parameters("TCc")->asGrid(); pTCz = Parameters("TCz")->asGrid(); pTCs = Parameters("TCs")->asGrid(); pGc = Parameters("Gc")->asGrid(); pGz = Parameters("Gz")->asGrid(); pGs = Parameters("Gs")->asGrid(); pTCondc = Parameters("TCONDc")->asGrid(); pTCondz = Parameters("TCONDz")->asGrid(); pTConds = Parameters("TCONDs")->asGrid(); pTCc->Assign_NoData(); pTCz->Assign_NoData(); pTCs->Assign_NoData(); pGc->Assign_NoData(); pGz->Assign_NoData(); pGs->Assign_NoData(); pTCondc->Assign_NoData(); pTCondz->Assign_NoData(); pTConds->Assign_NoData(); #endif pIF = Parameters("IF")->asGrid(); pQ = Parameters("Q")->asGrid(); pSL = Parameters("SL")->asGrid(); R = Parameters("R")->asDouble(); I = Parameters("I")->asDouble(); Rn = Parameters("Rn")->asDouble(); KE_I_method = Parameters("KE_I_METHOD")->asInt(); timespan = Parameters("TIMESPAN")->asInt(); flowd_va = Parameters("FLOWD_VA")->asDouble(); bChannelT = Parameters("CHANNELTRANSPORT")->asBool(); bInterflow = Parameters("INTERFLOW")->asBool(); T = Parameters("T")->asDouble(); if (bInterflow && pIF == NULL) { pIF = SG_Create_Grid(pDTM); bFreeIF = true; } // create temporary grids #ifndef _TMP_OUT pRf = SG_Create_Grid(pDTM->Get_System()); pKE = SG_Create_Grid(pDTM->Get_System()); pRc = SG_Create_Grid(pDTM->Get_System()); pSLc = SG_Create_Grid(pDTM->Get_System()); pSLz = SG_Create_Grid(pDTM->Get_System()); pSLs = SG_Create_Grid(pDTM->Get_System()); pW_up = SG_Create_Grid(pDTM->Get_System()); #endif for (int iRun=0; iRunGet_Record(iRun)->asInt(0); T = pMeteoTab->Get_Record(iRun)->asDouble(1); R = pMeteoTab->Get_Record(iRun)->asDouble(2); I = pMeteoTab->Get_Record(iRun)->asDouble(3); Rn = pMeteoTab->Get_Record(iRun)->asDouble(4); timespan = pMeteoTab->Get_Record(iRun)->asInt(5); } if (bInterflow && Rn > timespan) { Error_Set(CSG_String::Format(_TL("Number of raindays is greater than model timespan!"))); return (false); } // Initialize Grids pSLc->Assign(0.0); pSLz->Assign(0.0); pSLs->Assign(0.0); pQ->Assign(0.0); pW_up->Assign(0.0); if (bInterflow) pIF->Assign(0.0); // Estimation of rainfall energy (effective rainfall, leaf drainage, direct throughfall, kinetic energy) //------------------------------------------------------------------------------------------------------ for (y=0; yis_NoData(x, y) && !pPI->is_NoData(x, y) && !pCC->is_NoData(x, y) && !pPH->is_NoData(x, y)) { pRf->Set_Value(x, y, (R * (1-pPI->asDouble(x, y))) / cos(pS->asDouble(x, y))); // Equ. (1) LD = pRf->asDouble(x, y) * pCC->asDouble(x, y); // Equ. (2) DT = pRf->asDouble(x, y) - LD; // Equ. (3) switch (KE_I_method) // Equ. (4), see Table 2 in Morgan (2001) { case MMF_KE_I_WISCHMEIER_SMITH_1978: default: KE_DT = DT * (11.87 + 8.73 * log10(I)); break; case MMF_KE_I_MARSHALL_PALMER: KE_DT = DT * (8.95 + 8.44 * log10(I)); break; case MMF_KE_I_ZANCHI_TORRI_1980: KE_DT = DT * (9.81 + 11.25 * log10(I)); break; case MMF_KE_I_COUTINHO_TOMAS_1995: KE_DT = DT * (35.9 * (1 - 0.56 * exp(-0.034 * I))); break; case MMF_KE_I_HUDSON_1965: KE_DT = DT * (29.8 - (127.5 / I)); break; case MMF_KE_I_ONEGA_ET_AL_1998: KE_DT = DT * (9.81 + 10.6 * log10(I)); break; case MMF_KE_I_ROSEWELL_1986: KE_DT = DT * (29.0 * (1 - 0.6 * exp(-0.04 * I))); break; case MMF_KE_I_MCISAAC_1990: KE_DT = DT * (26.8 * (1 - 0.29 * exp(-0.049 * I))); break; } if (pPH->asDouble(x, y) < 0.15) KE_LD = 0.0; // Equ. (5) else KE_LD = LD * (15.8 * pow(pPH->asDouble(x, y), 0.5) - 5.87); // Equ. (6) pKE->Set_Value(x, y, KE_DT + KE_LD); // Equ. (7) } else { pRf->Set_NoData(x, y); pKE->Set_NoData(x, y); } } } // estimation of runoff //----------------------- if (bInterflow) { Z = 300 + (25 * T) + (0.05 * T * T * T); // Equ. (12), wrong in Morgan and Duzant (2008) -> original annual Turc equation uses T^3, not T^2 Rmod = R * (365/timespan); // scale up from timespan to annual values E = Rmod / sqrt(0.9 + (Rmod*Rmod)/(Z*Z)); // Equ. (11) E = E / (365/timespan); // calculate E for timespan } Ro = R / Rn; // Equ. (9) mean rain per rain day for (sLong n=0; nGet_Sorted(n, x, y, true, false); if (pDTM->is_NoData(x, y)) // pMS, pBD, pEHD, pEtEo, pRf, pLP, pS { pQ->Set_NoData(x, y); pSL->Set_NoData(x, y); pRc->Set_NoData(x, y); if (bInterflow) pIF->Set_NoData(x, y); } else { if (bInterflow) { Rc = (1000 * pMS->asDouble(x, y) * pBD->asDouble(x, y) * pEHD->asDouble(x, y) * pow(pEtEo->asDouble(x, y), 0.5)) - pIF->asDouble(x, y); // Equ. (8) if (Rc < 0.0) Rc = 0.0; pRc->Set_Value(x, y, Rc); } else pRc->Set_Value(x, y, 1000 * pMS->asDouble(x, y) * pBD->asDouble(x, y) * pEHD->asDouble(x, y) * pow(pEtEo->asDouble(x, y), 0.5)); // Equ. (8), modified L = Get_Cellsize() / cos(pS->asDouble(x, y)); // slope length, approx. from cellsize and slope if (pChannel != NULL && !pChannel->is_NoData(x, y)) Q = pRf->asDouble(x, y) + pQ->asDouble(x, y); else Q = (pRf->asDouble(x, y) + pQ->asDouble(x, y)) * exp((-1.0 * pRc->asDouble(x, y)) / Ro) * pow(L/10,0.1); // Equ. (9) //double Qe = pRf->asDouble(x, y) * exp((-1.0 * pRc->asDouble(x, y)) / Ro); if (bInterflow) { IF = ((R - E - Q) * pLP->asDouble(x, y) * sin(pS->asDouble(x, y))) / timespan; // Equ. (13) if (IF < 0) IF = 0.0; } z = pDTM->asDouble(x, y); dzSum = 0.0; W_down = 0.0; // uncomment this to just route number of cells to verify flow routing /*if (pChannel != NULL && !pChannel->is_NoData(x, y)) Q = 1.0 + pQ->asDouble(x, y); else Q = 0.0; if (bInterflow) IF = 0.0; */ if (pChannel != NULL && !pChannel->is_NoData(x, y)) { steepestN = pDTM->Get_Gradient_NeighborDir(x, y); dzSum = 1.0; } else // MFD Freeman 1991 { for (int i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( pDTM->is_InGrid(ix, iy) ) { d = z - pDTM->asDouble(ix, iy); } else { ix = Get_xTo(i + 4, x); iy = Get_yTo(i + 4, y); if( pDTM->is_InGrid(ix, iy) ) { d = pDTM->asDouble(ix, iy) - z; } else { d = 0.0; } } if( d > 0.0 ) { dzSum += (dz[i] = pow(d / Get_Length(i), Convergence)); } else { dz[i] = 0.0; } } } // flow routing //----------------------------------------------------- if (dzSum > 0.0) { if (pChannel != NULL && !pChannel->is_NoData(x, y)) { if (steepestN != -1) { ix = Get_xTo(steepestN, x); iy = Get_yTo(steepestN, y); pQ->Add_Value(ix, iy, Q); // distribute pW_up->Add_Value(ix, iy, Get_Length(steepestN)); // upslope CL of ix,iy W_down = Get_Length(steepestN); // downslope CL of x,y if (bInterflow) pIF->Add_Value(ix, iy, IF); } } else { d_Q = Q / dzSum; if (bInterflow) d_IF = IF / dzSum; for (int i=0; i<8; i++) { if (dz[i] > 0.0) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( pDTM->is_InGrid(ix, iy) ) { pQ->Add_Value(ix, iy, d_Q * dz[i]); // distribute f_w = 0.5 * Get_Cellsize() / Get_System()->Get_UnitLength(i); pW_up->Add_Value(ix, iy, f_w); // upslope CL of ix,iy W_down += f_w; // downslope CL of x,y if (bInterflow) pIF->Add_Value(ix, iy, d_IF * dz[i]); } } } } } pQ->Set_Value(x, y, Q); // write local values if (bInterflow) pIF->Set_Value(x, y, IF); if (bCalcSoil) { // detachment of soil particles ... per_c = pPer_c->asDouble(x, y); per_z = pPer_z->asDouble(x, y); per_s = pPer_s->asDouble(x, y); ST = pST->asDouble(x, y); KE = pKE->asDouble(x, y); GC = pGC->asDouble(x, y); sin_S = sin(pS->asDouble(x, y)); // ... by raindrop impact Fc = Kc * (per_c / 100.0) * (1.0 - ST) * KE * 0.001; // Equ. (14) Fz = Kz * (per_z / 100.0) * (1.0 - ST) * KE * 0.001; // Equ. (15) Fs = Ks * (per_s / 100.0) * (1.0 - ST) * KE * 0.001; // Equ. (16) F = Fc + Fz + Fs; // Equ. (17) // ... by runoff Hc = DRc * (per_c / 100.0) * pow(Q, 1.5) * (1.0 - (GC + ST)) * pow(sin_S, 0.3) * 0.001; // Equ. (18) Hz = DRz * (per_z / 100.0) * pow(Q, 1.5) * (1.0 - (GC + ST)) * pow(sin_S, 0.3) * 0.001; // Equ. (19) Hs = DRs * (per_s / 100.0) * pow(Q, 1.5) * (1.0 - (GC + ST)) * pow(sin_S, 0.3) * 0.001; // Equ. (20) H = Hc + Hz +Hs; // Equ. (21) // flow velocity ... /// input map with 3 classes // ... for standard bare soil n_manning = 0.015; d_flow = 0.005; slopeFract = tan(pS->asDouble(x, y)); if (slopeFract == 0.0) slopeFract = 0.001; // workaround for velocity calculations, otherwise v_flow and thus TC may become NaN! v_flow_b = 1.0 / n_manning * pow(d_flow, 0.67) * pow(slopeFract, 0.5); // Equ. (22) // ... actual flow velocity n_manning = 0.015; // if .... // global method //d_flow = 0.005; // unchannelled flow //d_flow = 0.01; // shallow rills //d_flow = 0.25; // deeper rills d_flow = flowd_va; // user supplied value v_flow_a = 1.0 / n_manning * pow(d_flow, 0.67) * pow(slopeFract, 0.5) * pow(M_EULER, (-0.018*ST)); // Equ. (23) // ... for vegetated conditions if (pGC->asDouble(x, y) > 0.01) // assuming bare soil as no ground cover v_flow_v = pow(((2 * 9.81) / (pD->asDouble(x, y) * pNV->asDouble(x, y))), 0.5) * pow(slopeFract, 0.5); // Equ. (24) else v_flow_v = 1.0; // bare soil // ... for the effect of tillage d_flow = 0.005; if (pRFR != NULL) { n_manning = pow(M_EULER, -2.1132 + 0.0349 * pRFR->asDouble(x, y)); // Equ. (27) v_flow_t = 1.0 / n_manning * pow(d_flow, 0.67) * pow(slopeFract, 0.5); } else { v_flow_t = 1.0; // if not under arable cultivation and natural soil surface roughness is not accounted for } // particle fall number //d_flow = 0.005; d_flow = flowd_va; // user supplied value if (pGC->asDouble(x, y) > 0.01) // assuming bare soil as no ground cover { Nf_c = (L * vs_c) / (v_flow_v * d_flow); // Equ. (28) Nf_z = (L * vs_z) / (v_flow_v * d_flow); // Equ. (29) Nf_s = (L * vs_s) / (v_flow_v * d_flow); // Equ. (30) } else // bare soil { Nf_c = (L * vs_c) / (v_flow_b * d_flow); // Equ. (28) Nf_z = (L * vs_z) / (v_flow_b * d_flow); // Equ. (29) Nf_s = (L * vs_s) / (v_flow_b * d_flow); // Equ. (30) } // percentage of detached sediment deposited DEPc = 44.1 * pow(Nf_c, 0.29); // Equ. (31) if (DEPc > 100.0) DEPc = 100.0; DEPz = 44.1 * pow(Nf_z, 0.29); // Equ. (32) if (DEPz > 100.0) DEPz = 100.0; DEPs = 44.1 * pow(Nf_s, 0.29); // Equ. (33) if (DEPs > 100.0) DEPs = 100.0; // delivery of detached particles to runoff if (W_down <= 0.0) W_down = 0.5 * Get_Cellsize(); if (pW_up->asDouble(x, y) == 0) W_up = W_down; Gc = (Fc + Hc) * (1.0 - DEPc / 100.0) + (pSLc->asDouble(x, y) * W_up/W_down); // Equ. (35) Gz = (Fz + Hz) * (1.0 - DEPz / 100.0) + (pSLz->asDouble(x, y) * W_up/W_down); // Equ. (36) Gs = (Fs + Hs) * (1.0 - DEPs / 100.0) + (pSLs->asDouble(x, y) * W_up/W_down); // Equ. (37) //G = Gc + Gz + Gs; // Equ. (38) // transport capacity of runoff v_flow = (v_flow_a * v_flow_v * v_flow_t) / v_flow_b; TCc = v_flow * (per_c / 100.0) * pow(Q, 2) * sin_S * 0.001; // Equ. (39) TCz = v_flow * (per_z / 100.0) * pow(Q, 2) * sin_S * 0.001; // Equ. (40) TCs = v_flow * (per_s / 100.0) * pow(Q, 2) * sin_S * 0.001; // Equ. (41) // sediment balance if (TCc >= Gc) { SLc = Gc; #ifdef _TMP_OUT pTCondc->Set_Value(x, y, TCOND_SED_LIMITED); #endif } else // recalculation { if (pGC->asDouble(x, y) > 0.01) // assuming bare soil as no ground cover Nf_c = (L * vs_c1) / (v_flow_v * d_flow); // Equ. (28) else // bare soil Nf_c = (L * vs_c1) / (v_flow_b * d_flow); // Equ. (28) DEPc = 44.1 * pow(Nf_c, 0.29); // Equ. (31) if (DEPc > 100.0) DEPc = 100.0; Gc = Gc * (1.0 - DEPc / 100.0); // Equ. (45) if (TCc >= Gc) { SLc = TCc; #ifdef _TMP_OUT pTCondc->Set_Value(x, y, TCOND_TRANS_LIMITED_TC); #endif } else { SLc = Gc; #ifdef _TMP_OUT pTCondc->Set_Value(x, y, TCONF_TRANS_LIMITED_G); #endif } } if (TCz >= Gz) { SLz = Gz; #ifdef _TMP_OUT pTCondz->Set_Value(x, y, 0); #endif } else // recalculation { if (pGC->asDouble(x, y) > 0.01) // assuming bare soil as no ground cover Nf_z = (L * vs_z1) / (v_flow_v * d_flow); // Equ. (28) else // bare soil Nf_z = (L * vs_z1) / (v_flow_b * d_flow); // Equ. (28) DEPz = 44.1 * pow(Nf_z, 0.29); // Equ. (31) if (DEPz > 100.0) DEPz = 100.0; Gz = Gz * (1.0 - DEPz / 100.0); // Equ. (46) if (TCz >= Gz) { SLz = TCz; #ifdef _TMP_OUT pTCondz->Set_Value(x, y, 1); #endif } else { SLz = Gz; #ifdef _TMP_OUT pTCondz->Set_Value(x, y, 2); #endif } } if (TCs >= Gs) { SLs = Gs; #ifdef _TMP_OUT pTConds->Set_Value(x, y, 0); #endif } else // recalculation { if (pGC->asDouble(x, y) > 0.01) // assuming bare soil as no ground cover Nf_s = (L * vs_s1) / (v_flow_v * d_flow); // Equ. (28) else // bare soil Nf_s = (L * vs_s1) / (v_flow_b * d_flow); // Equ. (28) DEPs = 44.1 * pow(Nf_s, 0.29); // Equ. (31) if (DEPs > 100.0) DEPs = 100.0; Gs = Gs * (1.0 - DEPs / 100.0); // Equ. (47) if (TCs >= Gs) { SLs = TCs; #ifdef _TMP_OUT pTConds->Set_Value(x, y, 1); #endif } else { SLs = Gs; #ifdef _TMP_OUT pTConds->Set_Value(x, y, 2); #endif } } SLc *= pDTM->Get_Cellarea(); SLz *= pDTM->Get_Cellarea(); SLs *= pDTM->Get_Cellarea(); // sediment routing //----------------------------------------------------- if (dzSum > 0.0) { if (pChannel != NULL && !pChannel->is_NoData(x, y) && bChannelT) // Transport along channel, ignore (new) sediment balance within channel { if (steepestN != -1) { ix = Get_xTo(steepestN, x); iy = Get_yTo(steepestN, y); pSLc->Add_Value(ix, iy, pSLc->asDouble(x, y)); pSLz->Add_Value(ix, iy, pSLz->asDouble(x, y)); pSLs->Add_Value(ix, iy, pSLs->asDouble(x, y)); } } else if (pChannel == NULL || (pChannel != NULL && pChannel->is_NoData(x, y))) // no channel grid used or no channel cell { d_SLc = SLc / dzSum; d_SLz = SLz / dzSum; d_SLs = SLs / dzSum; for (int i=0; i<8; i++) { if (dz[i] > 0.0) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( pDTM->is_InGrid(ix, iy) ) { pSLc->Add_Value(ix, iy, d_SLc * dz[i]); // distribute pSLz->Add_Value(ix, iy, d_SLz * dz[i]); pSLs->Add_Value(ix, iy, d_SLs * dz[i]); } } } } } if (pChannel != NULL && !pChannel->is_NoData(x, y)) // channel grid and channel cell: only write incoming material, ignore (new) sediment balance { pSL->Set_Value(x, y, pSLc->asDouble(x, y) + pSLz->asDouble(x, y) + pSLs->asDouble(x, y)); pSLc->Set_Value(x, y, pSLc->asDouble(x, y)); pSLz->Set_Value(x, y, pSLz->asDouble(x, y)); pSLs->Set_Value(x, y, pSLs->asDouble(x, y)); } else // calc mean annual soil loss { pSL->Set_Value(x, y, SLc + SLz + SLs); pSLc->Set_Value(x, y, SLc); pSLz->Set_Value(x, y, SLz); pSLs->Set_Value(x, y, SLs); } #ifdef _TMP_OUT pTCc->Set_Value(x, y, TCc * pDTM->Get_Cellarea()); pTCz->Set_Value(x, y, TCz * pDTM->Get_Cellarea()); pTCs->Set_Value(x, y, TCs * pDTM->Get_Cellarea()); pGc->Set_Value(x, y, Gc * pDTM->Get_Cellarea()); pGz->Set_Value(x, y, Gz * pDTM->Get_Cellarea()); pGs->Set_Value(x, y, Gs * pDTM->Get_Cellarea()); #endif }// bCalcSoil }// not NoData }// for if (pMeteoTab != NULL) { pQ->Save(CSG_String::Format(SG_T("%s\\%03d_Runoff"), sOutPath.c_str(), iRun + 1)); pSL->Save(CSG_String::Format(SG_T("%s\\%03d_SoilLoss"), sOutPath.c_str(), iRun + 1)); } }// for model step //----------------------------------------------------- // delete temporary grids #ifndef _TMP_OUT delete(pRf); delete(pKE); delete(pRc); delete(pSLc); delete(pSLz); delete(pSLs); delete(pW_up); #endif if (bFreeIF) delete(pIF); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_erosion/Makefile.am0000744000175000017500000000107012737416206024600 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1537 2012-11-19 20:05:19Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_erosion.la libsim_erosion_la_SOURCES =\ MMF_SAGA.cpp\ MLB_Interface.cpp\ MMF_SAGA.h\ MLB_Interface.h libsim_erosion_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/simulation/sim_erosion/MLB_Interface.h0000744000175000017500000000763012737416206025317 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_erosion // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__sim_erosion_H #define HEADER_INCLUDED__sim_erosion_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef sim_erosion_EXPORTS #define sim_erosion_EXPORT _SAGA_DLL_EXPORT #else #define sim_erosion_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__sim_erosion_H saga-2.3.1/src/modules/simulation/sim_erosion/MMF_SAGA.h0000744000175000017500000001265012737416206024135 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_erosion // // // //-------------------------------------------------------// // // // MMF_SAGA.h // // // // Copyright (C) 2009-12 by // // Volker Wichmann // // Muhammad Setiawan // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__MMF_SAGA_H #define HEADER_INCLUDED__MMF_SAGA_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // For debugging purposes the source code is currently configured // to output additional grid datasets; comment the line below and // recompile to disable this functionality. #define _TMP_OUT //--------------------------------------------------------- // coding of transport conditions #define TCOND_SED_LIMITED 0 // sediment limited #define TCOND_TRANS_LIMITED_TC 1 // transport limited (SL = TC) #define TCONF_TRANS_LIMITED_G 2 // transport limited (SL = G) //--------------------------------------------------------- typedef enum EMMF_KE_I_Key { MMF_KE_I_WISCHMEIER_SMITH_1978 = 0, MMF_KE_I_MARSHALL_PALMER, MMF_KE_I_ZANCHI_TORRI_1980, MMF_KE_I_COUTINHO_TOMAS_1995, MMF_KE_I_HUDSON_1965, MMF_KE_I_ONEGA_ET_AL_1998, MMF_KE_I_ROSEWELL_1986, MMF_KE_I_MCISAAC_1990, MMF_KE_I_Count } TMMF_KE_I_Key; //--------------------------------------------------------- const SG_Char gMMF_KE_I_Key_Name[MMF_KE_I_Count][64] = { SG_T("North America east of Rocky Mountains (Wischmeier & Smith 1978)"), SG_T("North-western Europe (Marshall & Palmer)"), SG_T("Mediterranean-type climates (Zanchi & Torri 1980)"), SG_T("Western Mediterranean (Coutinho & Tomas 1995)"), SG_T("Tropical climates (Hudson 1965)"), SG_T("Eastern Asia (Onaga et al. 1998)"), SG_T("Southern hemisphere climates (Rosewell 1986)"), SG_T("Bogor, West-Java, Indonesia (McISaac 1990)") }; //--------------------------------------------------------- class CMMF_SAGA : public CSG_Module_Grid { public: CMMF_SAGA(void); virtual ~CMMF_SAGA(void); protected: virtual bool On_Execute(void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__MMF_SAGA_H saga-2.3.1/src/modules/simulation/sim_erosion/MLB_Interface.cpp0000744000175000017500000001112312737416206025642 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id$ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_erosion // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return(_TL("Erosion")); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return(_TL("V. Wichmann, M. Setiawan (c) 2009-2012")); case MLB_INFO_Description: return(_TL("Modelling erosion processes.")); case MLB_INFO_Version: return(_TL("1.0")); case MLB_INFO_Menu_Path: return(_TL("Simulation|Erosion")); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "MMF_SAGA.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { CSG_Module *pModule; switch( i ) { case 0: pModule = new CMMF_SAGA; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/simulation/Makefile.in0000664000175000017500000004720112737447617022304 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @LIBFIRE_TRUE@am__append_1 = sim_fire_spreading subdir = src/modules/simulation ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = sim_cellular_automata sim_ecosystems_hugget sim_erosion \ sim_hydrology sim_ihacres sim_qm_of_esp sim_rivflow \ sim_fire_spreading am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = sim_cellular_automata sim_ecosystems_hugget sim_erosion \ sim_hydrology sim_ihacres sim_qm_of_esp sim_rivflow \ $(am__append_1) all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/simulation/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/simulation/sim_qm_of_esp/0000775000175000017500000000000012737740007023040 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/simulation/sim_qm_of_esp/successive_flow_routing.h0000744000175000017500000001210712737416210030157 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: successive_flow_routing.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // successive_flow_routing.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__successive_flow_routing_H #define HEADER_INCLUDED__successive_flow_routing_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "flow_routing.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSuccessive_Flow_Routing : public CSG_Module_Grid { public: CSuccessive_Flow_Routing(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Simulation|Hydrology" )); } protected: virtual bool On_Execute (void); private: double m_Manning; CSG_Grid *m_pDEM, *m_pFlow, *m_pSlope; void Fill_Sinks (void); void Set_Flow (int x, int y); void Set_Channel_Slope (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__successive_flow_routing_H saga-2.3.1/src/modules/simulation/sim_qm_of_esp/hillslope_evolution_adi.h0000744000175000017500000001232012737416210030116 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: hillslope_evolution_adi.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // hillslope_evolution_adi.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__hillslope_evolution_adi_H #define HEADER_INCLUDED__hillslope_evolution_adi_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CHillslope_Evolution_ADI : public CSG_Module_Grid { public: CHillslope_Evolution_ADI(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Simulation|Hillslope Evolution" )); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pDEM_Old, *m_pChannels; void Set_Difference (void); void Set_Diffusion (double dFactor); bool is_Channel (int x, int y); double Get_Elevation (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__hillslope_evolution_adi_H saga-2.3.1/src/modules/simulation/sim_qm_of_esp/flow_routing.cpp0000744000175000017500000001727112737416210026265 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: flow_routing.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // flow_routing.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "flow_routing.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFlow_Routing::CFlow_Routing(void) { //----------------------------------------------------- Set_Name (_TL("Flow Accumulation (QM of ESP)")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Calculation of flow accumulation, aka upslope contributing area, with the " "multiple flow direction method after Freeman (1991).\n" "\nReferences:\n" "Freeman, G.T. (1991): Calculating catchment area with divergent flow based on a rectangular grid. Computers & Geosciences, 17, pp.413-422.\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "FLOW" , _TL("Contributing Area"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Choice( NULL , "PREPROC" , _TL("Preprocessing"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("none"), _TL("fill sinks temporarily"), _TL("fill sinks permanently") ), 1 ); Parameters.Add_Value( NULL , "DZFILL" , _TL("Fill Increment"), _TL(""), PARAMETER_TYPE_Double, 0.01, 0.0000001, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CFlow_Routing::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "PREPROC") ) { pParameters->Get_Parameter("DZFILL")->Set_Enabled(pParameter->asInt() != 0); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_Routing::On_Execute(void) { m_pDEM = Parameters("DEM" )->asGrid(); m_pFlow = Parameters("FLOW")->asGrid(); return( Set_Flow(Parameters("PREPROC")->asInt(), Parameters("DZFILL")->asDouble()) ); } //--------------------------------------------------------- bool CFlow_Routing::Set_Flow(CSG_Grid *pDEM, CSG_Grid *pFlow, int Preprocess, double dzFill) { if( is_Executing() || !pDEM || !pFlow || !pDEM->is_Compatible(pFlow) || !Get_System()->Assign(pDEM->Get_System()) ) { return( false ); } m_pDEM = pDEM; m_pFlow = pFlow; return( Set_Flow(Preprocess, dzFill) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFlow_Routing::Set_Flow(int Preprocess, double dzFill) { CSG_Grid DEM; switch( Preprocess ) { case 1: DEM.Create(*m_pDEM); m_pDEM = &DEM; case 2: { CFill_Sinks Preprocessor; Preprocessor.Fill_Sinks(m_pDEM, NULL, dzFill); } break; } //----------------------------------------------------- int i, x, y; m_pFlow->Assign(0.0); m_pDEM->Get_Sorted(0, x, y); Process_Set_Text(_TL("Calculating Contributing Area")); for(i=0; iGet_Sorted(i, x, y) ) { Set_Flow(x, y); } } //----------------------------------------------------- if( Preprocess == 2 ) { DataObject_Update(m_pDEM); } return( true ); } //--------------------------------------------------------- void CFlow_Routing::Set_Flow(int x, int y) { if( !m_pDEM->is_NoData(x, y) ) { m_pFlow->Add_Value(x, y, Get_Cellarea()); int i; double z, dz[8], dzSum; for(i=0, dzSum=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && (dz[i] = z - m_pDEM->asDouble(ix, iy)) > 0.0 ) { dzSum += (dz[i] = pow(dz[i] / Get_Length(i), 1.1)); } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { for(i=0, z=m_pFlow->asDouble(x, y)/dzSum; i<8; i++) { if( dz[i] > 0.0 ) { m_pFlow->Add_Value(Get_xTo(i, x), Get_yTo(i, y), z * dz[i]); } } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_qm_of_esp/hillslope_evolution_ftcs.cpp0000744000175000017500000002342712737416210030665 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: hillslope_evolution_ftcs.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // hillslope_evolution_ftcs.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "hillslope_evolution_ftcs.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CHillslope_Evolution_FTCS::CHillslope_Evolution_FTCS(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Diffusive Hillslope Evolution (FTCS)")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Simulation of diffusive hillslope evolution using a Forward-Time-Centered-Space (FTCS) method.\n" "\nReferences:\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "MODEL" , _TL("Modelled Elevation"), _TL(""), PARAMETER_OUTPUT ); pNode = Parameters.Add_Grid( NULL , "DIFF" , _TL("Elevation Difference"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( pNode , "UPDATE" , _TL("Update"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "KAPPA" , _TL("Diffusivity [m2 / kyr]"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Value( NULL , "DURATION" , _TL("Simulation Time [kyr]"), _TL(""), PARAMETER_TYPE_Double, 100.0, 0.0, true ); pNode = Parameters.Add_Choice( NULL , "TIMESTEP" , _TL("Time Step"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("user defined"), _TL("automatically") ), 1 ); Parameters.Add_Value( pNode , "DTIME" , _TL("Time Step [kyr]"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Choice( NULL , "NEIGHBOURS" , _TL("Neighbourhood"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Neumann"), _TL("Moore") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CHillslope_Evolution_FTCS::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TIMESTEP") ) { pParameters->Get_Parameter("DTIME")->Set_Enabled(pParameter->asInt() == 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DIFF") ) { pParameters->Get_Parameter("UPDATE")->Set_Enabled(pParameter->asGrid() != NULL); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CHillslope_Evolution_FTCS::On_Execute(void) { //----------------------------------------------------- CSG_Grid DEM(*Get_System()); m_pDEM_Old = &DEM; m_pDEM = Parameters("MODEL")->asGrid(); m_pDEM->Assign(Parameters("DEM")->asGrid()); DataObject_Set_Colors(Parameters("DIFF")->asGrid(), 10, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- double k, dTime, nTime; k = Parameters("KAPPA" )->asDouble(); nTime = Parameters("DURATION")->asDouble(); if( Parameters("TIMESTEP")->asInt() == 0 ) { dTime = Parameters("DTIME")->asDouble(); } else { dTime = 0.5 * Get_Cellarea() / (2.0 * k); if( Parameters("NEIGHBOURS")->asInt() == 1 ) { dTime /= sqrt(2.0); } } if( dTime > nTime ) { Message_Add(CSG_String::Format(SG_T("\n%s: %s [%f]"), _TL("Warning"), _TL("Time step exceeds duration"), dTime), false); dTime = nTime; } Message_Add(CSG_String::Format(SG_T("\n%s: %f"), _TL("Time Step"), dTime), false); Message_Add(CSG_String::Format(SG_T("\n%s: %d"), _TL("Steps"), (int)(nTime / dTime)), false); //----------------------------------------------------- for(double iTime=dTime; iTime<=nTime && Set_Progress(iTime, nTime); iTime+=dTime) { Process_Set_Text(CSG_String::Format(SG_T("%s: %.2f [%.2f]"), _TL("Simulation Time"), iTime, nTime)); SG_UI_Progress_Lock(true); Set_Diffusion(dTime * k / Get_Cellarea()); Set_Difference(); SG_UI_Progress_Lock(false); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CHillslope_Evolution_FTCS::Set_Difference(void) { CSG_Grid *pDiff = Parameters("DIFF")->asGrid(); if( pDiff ) { CSG_Grid *pDEM = Parameters("DEM")->asGrid(); #pragma omp parallel for for(int i=0; iis_NoData(i) ) { pDiff->Set_NoData(i); } else { pDiff->Set_Value(i, m_pDEM->asDouble(i) - pDEM->asDouble(i)); } } if( Parameters("UPDATE")->asBool() ) { DataObject_Update(pDiff, SG_UI_DATAOBJECT_SHOW); } } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CHillslope_Evolution_FTCS::Set_Diffusion(double dFactor) { int iStep = Parameters("NEIGHBOURS")->asInt() == 1 ? 1 : 2; m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for for(int y=0; yis_NoData(x, y) ) { double z = m_pDEM_Old->asDouble(x, y); double dz = 0.0; for(int i=0; i<8; i+=iStep) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM_Old->is_InGrid(ix, iy) ) { dz += (m_pDEM_Old->asDouble(ix, iy) - z) / Get_UnitLength(i); } } m_pDEM->Add_Value(x, y, dFactor * dz); } } } } /*/--------------------------------------------------------- void CHillslope_Evolution_FTCS::Set_Diffusion(double dFactor) { m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for for(int y=0; yis_NoData(x, y) ) { double z, dz; z = m_pDEM_Old->asDouble(x, y); dz = -4.0 * z; for(int i=0; i<8; i+=2) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); dz += m_pDEM_Old->is_InGrid(ix, iy) ? m_pDEM_Old->asDouble(ix, iy) : z; } m_pDEM->Add_Value(x, y, dFactor * dz); } } } }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_qm_of_esp/Makefile.in0000664000175000017500000005644212737447617025133 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/simulation/sim_qm_of_esp ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_qm_of_esp_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_qm_of_esp_la_OBJECTS = fill_sinks.lo flow_routing.lo \ hillslope_evolution_adi.lo hillslope_evolution_ftcs.lo \ MLB_Interface.lo successive_flow_routing.lo libsim_qm_of_esp_la_OBJECTS = $(am_libsim_qm_of_esp_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_qm_of_esp_la_SOURCES) DIST_SOURCES = $(libsim_qm_of_esp_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1537 2012-11-19 20:05:19Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_qm_of_esp.la libsim_qm_of_esp_la_SOURCES = \ fill_sinks.cpp\ flow_routing.cpp\ hillslope_evolution_adi.cpp\ hillslope_evolution_ftcs.cpp\ MLB_Interface.cpp\ successive_flow_routing.cpp\ fill_sinks.h\ flow_routing.h\ hillslope_evolution_adi.h\ hillslope_evolution_ftcs.h\ MLB_Interface.h\ successive_flow_routing.h libsim_qm_of_esp_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/simulation/sim_qm_of_esp/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_qm_of_esp/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_qm_of_esp.la: $(libsim_qm_of_esp_la_OBJECTS) $(libsim_qm_of_esp_la_DEPENDENCIES) $(EXTRA_libsim_qm_of_esp_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_qm_of_esp_la_OBJECTS) $(libsim_qm_of_esp_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fill_sinks.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flow_routing.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hillslope_evolution_adi.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hillslope_evolution_ftcs.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/successive_flow_routing.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/simulation/sim_qm_of_esp/fill_sinks.h0000744000175000017500000001207612737416210025347 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: fill_sinks.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // fill_sinks.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__fill_sinks_H #define HEADER_INCLUDED__fill_sinks_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFill_Sinks : public CSG_Module_Grid { public: CFill_Sinks(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Preprocessing" )); } bool Fill_Sinks (CSG_Grid *pDEM, CSG_Grid *pFilled=NULL, double dzFill=0.01); protected: virtual bool On_Execute (void); private: double m_dzFill; CSG_Grid *m_pDEM; bool Fill_Sinks (void); bool Fill_Sink (int x, int y); bool Fill_Cell (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__fill_sinks_H saga-2.3.1/src/modules/simulation/sim_qm_of_esp/hillslope_evolution_adi.cpp0000744000175000017500000003472012737416210030461 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: hillslope_evolution_adi.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // hillslope_evolution_adi.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "hillslope_evolution_adi.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool tridag(const CSG_Vector &a, const CSG_Vector &b, const CSG_Vector &c, const CSG_Vector &r, CSG_Vector &u) { int i, n = a.Get_N(); double beta; CSG_Vector gamma(n); if( n < 2 || n != b.Get_N() || n != c.Get_N() || n != r.Get_N() || b[0] == 0.0 ) { return( false ); } u.Create(n); u[0] = r[0] / (beta = b[0]); for(i=1; i=0; i--) { u[i] -= gamma[i + 1] * u[i + 1]; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CHillslope_Evolution_ADI::CHillslope_Evolution_ADI(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Diffusive Hillslope Evolution (ADI)")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Simulation of diffusive hillslope evolution using an Alternating-Direction-Implicit (ADI) method.\n" "\nReferences:\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "CHANNELS" , _TL("Channel Mask"), _TL("use a zero value for hillslopes, any other value for channel cells."), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "MODEL" , _TL("Modelled Elevation"), _TL(""), PARAMETER_OUTPUT ); pNode = Parameters.Add_Grid( NULL , "DIFF" , _TL("Elevation Difference"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( pNode , "UPDATE" , _TL("Update"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "KAPPA" , _TL("Diffusivity [m2 / kyr]"), _TL(""), PARAMETER_TYPE_Double, 10.0, 0.0, true ); Parameters.Add_Value( NULL , "DURATION" , _TL("Simulation Time [kyr]"), _TL(""), PARAMETER_TYPE_Double, 10000.0, 0.0, true ); pNode = Parameters.Add_Choice( NULL , "TIMESTEP" , _TL("Time Step"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("user defined"), _TL("automatically") ), 0 ); Parameters.Add_Value( pNode , "DTIME" , _TL("Time Step [kyr]"), _TL(""), PARAMETER_TYPE_Double, 1000.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CHillslope_Evolution_ADI::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TIMESTEP") ) { pParameters->Get_Parameter("DTIME")->Set_Enabled(pParameter->asInt() == 0); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "DIFF") ) { pParameters->Get_Parameter("UPDATE")->Set_Enabled(pParameter->asGrid() != NULL); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CHillslope_Evolution_ADI::On_Execute(void) { //----------------------------------------------------- CSG_Grid DEM(*Get_System()), Channels(*Get_System(), SG_DATATYPE_Byte); m_pDEM_Old = &DEM; m_pDEM = Parameters("MODEL" )->asGrid(); m_pChannels = Parameters("CHANNELS")->asGrid(); m_pDEM->Assign(Parameters("DEM")->asGrid()); DataObject_Set_Colors(Parameters("DIFF")->asGrid(), 10, SG_COLORS_RED_GREY_BLUE, true); //----------------------------------------------------- double k, dTime, nTime; k = Parameters("KAPPA" )->asDouble(); nTime = Parameters("DURATION")->asDouble(); if( Parameters("TIMESTEP")->asInt() == 0 ) { dTime = Parameters("DTIME")->asDouble(); } else { dTime = 0.5 * Get_Cellarea() / (2.0 * k); } if( dTime > nTime ) { Message_Add(CSG_String::Format(SG_T("\n%s: %s [%f]"), _TL("Warning"), _TL("Time step exceeds duration"), dTime), false); dTime = nTime; } Message_Add(CSG_String::Format(SG_T("\n%s: %f"), _TL("Time Step"), dTime), false); Message_Add(CSG_String::Format(SG_T("\n%s: %d"), _TL("Steps"), (int)(nTime / dTime)), false); //----------------------------------------------------- for(double iTime=dTime; iTime<=nTime && Set_Progress(iTime, nTime); iTime+=dTime) { Process_Set_Text(CSG_String::Format(SG_T("%s: %.2f [%.2f]"), _TL("Simulation Time"), iTime, nTime)); SG_UI_Progress_Lock(true); Set_Diffusion(dTime * k / Get_Cellarea()); Set_Difference(); SG_UI_Progress_Lock(false); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CHillslope_Evolution_ADI::Set_Difference(void) { CSG_Grid *pDiff = Parameters("DIFF")->asGrid(); if( pDiff ) { CSG_Grid *pDEM = Parameters("DEM")->asGrid(); #pragma omp parallel for for(int i=0; iis_NoData(i) ) { pDiff->Set_NoData(i); } else { pDiff->Set_Value(i, m_pDEM->asDouble(i) - pDEM->asDouble(i)); } } if( Parameters("UPDATE")->asBool() ) { DataObject_Update(pDiff, SG_UI_DATAOBJECT_SHOW); } } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CHillslope_Evolution_ADI::is_Channel(int x, int y) { return( m_pChannels ? m_pChannels->asDouble(x, y) != 0.0 : false ); } //--------------------------------------------------------- inline double CHillslope_Evolution_ADI::Get_Elevation(int x, int y) { if( x < 0 ) x = 0; else if( x >= Get_NX() ) x = Get_NX() - 1; if( y < 0 ) y = 0; else if( y >= Get_NY() ) y = Get_NY() - 1; return( m_pDEM->asDouble(x, y) ); } //--------------------------------------------------------- void CHillslope_Evolution_ADI::Set_Diffusion(double dFactor) { int x, y; for(int i=0; i<5 && Process_Get_Okay(); i++) { m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for private(x, y) for(x=0; xasDouble(x, y); } else if( y == Get_NY() - 1 ) { a[y] = 0; b[y] = 1; c[y] = is_Channel(x, y) ? 0 : -dFactor; r[y] = m_pDEM_Old->asDouble(x, y); } else if( is_Channel(x, y) ) { b[y] = 1; a[y] = 0; c[y] = 0; r[y] = m_pDEM_Old->asDouble(x, y); } else // if( !is_Channel(x, y) ) { a[y] = -dFactor; c[y] = -dFactor; b[y] = 4 * dFactor + 1; r[y] = m_pDEM_Old->asDouble(x, y) + dFactor * (Get_Elevation(x - 1, y) + Get_Elevation(x + 1, y)); } } tridag(a, b, c, r, u); for(y=0; ySet_Value(x, y, u[y]); } } //------------------------------------------------- m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for private(x, y) for(y=0; yasDouble(x, y); } else if( x == Get_NX() - 1 ) { a[x] = 0; b[x] = 1; c[x] = is_Channel(x, y) ? 0 : -dFactor; r[x] = m_pDEM_Old->asDouble(x, y); } else if( is_Channel(x, y) ) { a[x] = 0; b[x] = 1; c[x] = 0; r[x] = m_pDEM_Old->asDouble(x, y); } else // if( !is_Channel(x, y) ) { a[x] = -dFactor; c[x] = -dFactor; b[x] = 4 * dFactor + 1; r[x] = m_pDEM_Old->asDouble(x, y) + dFactor * (Get_Elevation(x, y - 1) + Get_Elevation(x, y + 1)); } } tridag(a, b, c, r, u); for(x=0; xSet_Value(x, y, u[x]); } } } } /*/--------------------------------------------------------- void CHillslope_Evolution_ADI::Set_Diffusion(double dFactor) { int x, y; for(int i=0; i<5 && Process_Get_Okay(); i++) { m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for private(x, y) for(x=0; xasDouble(x, y) + dFactor * (Get_Elevation(x - 1, y) + Get_Elevation(x + 1, y)); } else { b[y] = 1; a[y] = 0; c[y] = 0; r[y] = m_pDEM_Old->asDouble(x, y); } if( y == 0 ) { b[y] = 1; c[y] = 0; r[y] = m_pDEM_Old->asDouble(x, y); } else if( y == Get_NY() - 1 ) { b[y] = 1; a[y] = 0; r[y] = m_pDEM_Old->asDouble(x, y); } } tridag(a, b, c, r, u); for(y=0; ySet_Value(x, y, u[y]); } } //------------------------------------------------- m_pDEM_Old->Assign(m_pDEM); #pragma omp parallel for private(x, y) for(y=0; yasDouble(x, y) + dFactor * (Get_Elevation(x, y - 1) + Get_Elevation(x, y + 1)); } else { b[x] = 1; a[x] = 0; c[x] = 0; r[x] = m_pDEM_Old->asDouble(x, y); } if( x == 0 ) { b[x] = 1; c[x] = 0; r[x] = m_pDEM_Old->asDouble(x, y); } else if( x == Get_NX() - 1 ) { b[x] = 1; a[x] = 0; r[x] = m_pDEM_Old->asDouble(x, y); } } tridag(a, b, c, r, u); for(x=0; xSet_Value(x, y, u[x]); } } } }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_qm_of_esp/Makefile.am0000744000175000017500000000141612737416210025071 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1537 2012-11-19 20:05:19Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_qm_of_esp.la libsim_qm_of_esp_la_SOURCES =\ fill_sinks.cpp\ flow_routing.cpp\ hillslope_evolution_adi.cpp\ hillslope_evolution_ftcs.cpp\ MLB_Interface.cpp\ successive_flow_routing.cpp\ fill_sinks.h\ flow_routing.h\ hillslope_evolution_adi.h\ hillslope_evolution_ftcs.h\ MLB_Interface.h\ successive_flow_routing.h libsim_qm_of_esp_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/simulation/sim_qm_of_esp/successive_flow_routing.cpp0000744000175000017500000002206212737416210030513 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: successive_flow_routing.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // successive_flow_routing.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "successive_flow_routing.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSuccessive_Flow_Routing::CSuccessive_Flow_Routing(void) { //----------------------------------------------------- Set_Name (_TL("Successive Flow Routing")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Calculation of flow accumulation, aka upslope contributing area, with the " "multiple flow direction method after Freeman (1991).\n" "\nReferences:\n" "Freeman, G.T. (1991): Calculating catchment area with divergent flow based on a rectangular grid. " "Computers & Geosciences, 17, pp.413-422.\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "FLOW" , _TL("Flow"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "ITERATIONS" , _TL("Iterations"), _TL(""), PARAMETER_TYPE_Int, 100, 1, true ); Parameters.Add_Value( NULL , "RUNOFF" , _TL("Runoff"), _TL(""), PARAMETER_TYPE_Double, 1.0 ); Parameters.Add_Value( NULL , "MANNING" , _TL("Manning's Roughness"), _TL(""), PARAMETER_TYPE_Double, 0.2 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSuccessive_Flow_Routing::On_Execute(void) { int x, y, nIterations; double Runoff; CSG_Grid *pDEM, DEM, Slope; nIterations = Parameters("ITERATIONS")->asInt(); Runoff = Parameters("RUNOFF" )->asDouble(); m_Manning = Parameters("MANNING" )->asDouble(); pDEM = Parameters("DEM" )->asGrid(); m_pFlow = Parameters("FLOW" )->asGrid(); m_pDEM = &DEM; m_pSlope = &Slope; DEM .Create(*pDEM); Slope .Create(*Get_System()); CSG_Colors Colors(11, SG_COLORS_WHITE_BLUE); Colors[0] = SG_GET_RGB(255, 255, 200); DataObject_Set_Colors(m_pFlow, Colors); DataObject_Update(m_pFlow, SG_UI_DATAOBJECT_SHOW); Fill_Sinks(); #pragma omp parallel for private(x, y) for(y=0; ySet_Value(x, y, pow(Runoff, 1.66667) * m_pSlope->asDouble(x, y)); } } for(int i=0; iGet_Sorted(i, x, y) ) { Set_Flow(x, y); } } #pragma omp parallel for private(x, y) for(y=0; yis_NoData(x, y) ) { m_pFlow->Set_NoData(x, y); } else { double Depth = pow(m_pFlow->asDouble(x, y) / m_pSlope->asDouble(x, y), 0.6); if( m_pDEM->asDouble(x, y) < pDEM->asDouble(x, y) + Depth ) { m_pDEM->Set_Value(x, y, pDEM->asDouble(x, y) + Depth / nIterations); } m_pFlow->Set_Value(x, y, m_pDEM->asDouble(x, y) - pDEM->asDouble(x, y)); } } } DataObject_Update(m_pFlow); SG_UI_Progress_Lock(false); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define RUN_MODULE(LIBRARY, MODULE, CONDITION) {\ bool bResult;\ SG_RUN_MODULE(bResult, LIBRARY, MODULE, CONDITION)\ } #define SET_PARAMETER(IDENTIFIER, VALUE) pModule->Get_Parameters()->Set_Parameter(SG_T(IDENTIFIER), VALUE) void CSuccessive_Flow_Routing::Fill_Sinks(void) { RUN_MODULE("ta_preprocessor", 2, // CPit_Eliminator SET_PARAMETER("DEM" , m_pDEM) ) } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSuccessive_Flow_Routing::Set_Flow(int x, int y) { if( !m_pDEM->is_NoData(x, y) ) { int i; double z, dz[8], dzSum; for(i=0, dzSum=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && (dz[i] = z - m_pDEM->asDouble(ix, iy)) > 0.0 ) { dzSum += (dz[i] = pow(dz[i] / Get_Length(i), 1.1)); } else { dz[i] = 0.0; } } if( dzSum > 0.0 ) { for(i=0, z=m_pFlow->asDouble(x, y)/dzSum; i<8; i++) { if( dz[i] > 0.0 ) { m_pFlow->Add_Value(Get_xTo(i, x), Get_yTo(i, y), z * dz[i]); } } } } } //--------------------------------------------------------- void CSuccessive_Flow_Routing::Set_Channel_Slope(int x, int y) { if( m_pDEM->is_NoData(x, y) ) { m_pSlope->Set_NoData(x, y); } else { int i; double z, dz, Slope; for(i=0, Slope=0.0, z=m_pDEM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && (dz = (z - m_pDEM->asDouble(ix, iy)) / Get_Length(i)) > Slope ) { Slope = dz; } } m_pSlope->Set_Value(x, y, sqrt(Slope > 0.01 ? Slope : 0.01) * Get_Cellsize() / m_Manning); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_qm_of_esp/hillslope_evolution_ftcs.h0000744000175000017500000001216512737416210030327 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: hillslope_evolution_ftcs.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // hillslope_evolution_ftcs.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__hillslope_evolution_ftcs_H #define HEADER_INCLUDED__hillslope_evolution_ftcs_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CHillslope_Evolution_FTCS : public CSG_Module_Grid { public: CHillslope_Evolution_FTCS(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Simulation|Hillslope Evolution" )); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pDEM_Old; void Set_Difference (void); void Set_Diffusion (double dFactor); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__hillslope_evolution_ftcs_H saga-2.3.1/src/modules/simulation/sim_qm_of_esp/MLB_Interface.h0000744000175000017500000000766412737416210025613 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__qm_of_esp_MLB_Interface_H #define HEADER_INCLUDED__qm_of_esp_MLB_Interface_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef qm_of_esp_EXPORTS #define qm_of_esp_EXPORT _SAGA_DLL_EXPORT #else #define qm_of_esp_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__qm_of_esp_MLB_Interface_H saga-2.3.1/src/modules/simulation/sim_qm_of_esp/flow_routing.h0000744000175000017500000001224512737416210025726 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: flow_routing.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // flow_routing.h // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__flow_routing_H #define HEADER_INCLUDED__flow_routing_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "fill_sinks.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CFlow_Routing : public CSG_Module_Grid { public: CFlow_Routing(void); virtual CSG_String Get_MenuPath (void) { return( _TL("A:Terrain Analysis|Hydrology|Flow Accumulation" )); } bool Set_Flow (CSG_Grid *pDEM, CSG_Grid *pFlow, int Preprocess = 0, double dzFill = 0.01); protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Grid *m_pDEM, *m_pFlow; bool Set_Flow (int Preprocess, double dzFill); void Set_Flow (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__flow_routing_H saga-2.3.1/src/modules/simulation/sim_qm_of_esp/fill_sinks.cpp0000744000175000017500000002226312737416210025701 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: fill_sinks.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // fill_sinks.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "fill_sinks.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CStack : public CSG_Stack { public: CStack(void) : CSG_Stack(3 * sizeof(int)) {} //----------------------------------------------------- virtual bool Push (int x, int y, int i) { int *Data = (int *)Get_Record_Push(); if( Data ) { Data[0] = x; Data[1] = y; Data[2] = i; return( true ); } return( false ); } //----------------------------------------------------- virtual bool Pop (int &x, int &y, int &i) { int *Data = (int *)Get_Record_Pop(); if( Data ) { x = Data[0]; y = Data[1]; i = Data[2]; return( true ); } return( false ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CFill_Sinks::CFill_Sinks(void) { //----------------------------------------------------- Set_Name (_TL("Fill Sinks (QM of ESP)")); Set_Author ("O.Conrad (c) 2013"); Set_Description (_TW( "Filling in pits and flats in a DEM.\n" "\nReferences:\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("DEM"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "FILLED" , _TL("DEM without Sinks"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL , "SINKS" , _TL("Sinks"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Value( NULL , "DZFILL" , _TL("Fill Increment"), _TL(""), PARAMETER_TYPE_Double, 0.01, 0.0000001, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFill_Sinks::On_Execute(void) { CSG_Grid *pDEM, *pSinks; pDEM = Parameters("DEM" )->asGrid(); m_pDEM = Parameters("FILLED")->asGrid(); pSinks = Parameters("SINKS" )->asGrid(); m_dzFill = Parameters("DZFILL")->asDouble(); m_pDEM->Assign(pDEM); m_pDEM->Set_Name(CSG_String::Format(SG_T("%s [%s]"), pDEM->Get_Name(), _TL("No Sinks"))); if( !Fill_Sinks() ) { return( false ); } if( pSinks ) { pSinks->Assign(m_pDEM); pSinks->Subtract(*pDEM); pSinks->Set_NoData_Value(0.0); } return( true ); } //--------------------------------------------------------- bool CFill_Sinks::Fill_Sinks(CSG_Grid *pDEM, CSG_Grid *pFilled, double dzFill) { if( is_Executing() || !pDEM || (pFilled && !pDEM->is_Compatible(pFilled)) || !Get_System()->Assign(pDEM->Get_System()) ) { return( false ); } //----------------------------------------------------- if( pFilled ) { m_pDEM = pFilled; m_pDEM->Assign(pDEM); } else { m_pDEM = pDEM; } m_dzFill = dzFill; return( Fill_Sinks() ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CFill_Sinks::Fill_Sinks(void) { if( m_dzFill <= 0.0 ) { return( false ); } Process_Set_Text(_TL("Processing Sinks and Flats")); for(int y=0; y 0 ); return( true ); } //--------------------------------------------------------- bool CFill_Sinks::Fill_Cell(int x, int y) { if( x > 0 && x < Get_NX() - 1 && y > 0 && y < Get_NY() - 1 && !m_pDEM->is_NoData(x, y) ) { for(bool bFilled=false, bSingle=true; ; ) { bool bPit = true; double zMin = m_pDEM->asDouble(x, y); for(int i=0; i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) ) { bSingle = false; if( m_pDEM->asDouble(ix, iy) < zMin ) { zMin = m_pDEM->asDouble(ix, iy); bPit = false; } } } if( !bSingle && bPit ) { m_pDEM->Set_Value(x, y, zMin + m_dzFill); bFilled = true; } else { return( bFilled ); } } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// /*/--------------------------------------------------------- void CFill_Sinks::Fill_Sinks(int x, int y) { if( Fill_Cell(x, y) ) { for(int i=0; i<8; i++) { Fill_Sinks(Get_xTo(i, x), Get_yTo(i, y)); } } }/**/ /*/--------------------------------------------------------- void CFill_Sinks::Fill_Sinks(int x, int y) { if( x > 0 && x < Get_NX() - 1 && y > 0 && y < Get_NY() - 1 && !m_pDEM->is_NoData(x, y) ) { int i; double zMin; for(i=0, zMin=m_pDEM->asDouble(x, y); i<8; i++) { int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if( m_pDEM->is_InGrid(ix, iy) && m_pDEM->asDouble(ix, iy) < zMin ) { zMin = m_pDEM->asDouble(ix, iy); } } if( m_pDEM->asDouble(x, y) <= zMin ) { m_pDEM->Set_Value(x, y, zMin + m_dzFill); Fill_Sinks(x, y); for(i=0; i<8; i++) { Fill_Sinks(Get_xTo(i, x), Get_yTo(i, y)); } } } }/**/ /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_qm_of_esp/MLB_Interface.cpp0000744000175000017500000001206412737416210026134 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // qm_of_esp // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2013 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("QM of ESP") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2013") ); case MLB_INFO_Description: return( _TW( "Quantitative Modeling of Earth Surface Processes.\n" "SAGA implementations following the examples from the text book:\n" "Pelletier, J.D. (2008): Quantitative Modeling of Earth Surface Processes. Cambridge, 295p.\n" )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Quantitative Modeling of Earth Surface Processes") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "hillslope_evolution_ftcs.h" #include "fill_sinks.h" #include "flow_routing.h" #include "successive_flow_routing.h" #include "hillslope_evolution_adi.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CHillslope_Evolution_FTCS ); case 1: return( new CFill_Sinks ); case 2: return( new CFlow_Routing ); case 3: return( new CSuccessive_Flow_Routing ); case 4: return( new CHillslope_Evolution_ADI ); case 11: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/simulation/Makefile.am0000744000175000017500000000025212737416206022253 0ustar00oconradoconrad00000000000000SUBDIRS = sim_cellular_automata sim_ecosystems_hugget sim_erosion sim_hydrology sim_ihacres sim_qm_of_esp sim_rivflow if LIBFIRE SUBDIRS +=sim_fire_spreading endif saga-2.3.1/src/modules/simulation/sim_rivflow/0000775000175000017500000000000012737740007022560 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/simulation/sim_rivflow/DataTrans.h0000744000175000017500000001010412737416210024601 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // DataTrans.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__DataTrans_H #define HEADER_INCLUDED__DataTrans_H //--------------------------------------------------------- #include #include using namespace std; //--------------------------------------------------------- //######################################################### class CDataTrans : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CDataTrans(void); // constructor protected: /// protected members and functions: /////////// virtual bool On_Execute (void); // always overwrite this function private: ///// private members and functions: ///////////// CSG_Grid *pSource1, *pSource2; int NX, NY, m_pID, i; bool Set_TFile(CSG_Grid *pSource1, CSG_Grid *pSource2); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__DataTrans_Hsaga-2.3.1/src/modules/simulation/sim_rivflow/RivBasin.cpp0000744000175000017500000005377512737416210025015 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivBasin.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "RivBasin.h" #include #include #include //ACHTUNG ////////////////////////////////////////////////////////////////////// //Das Schreiben von Koordinaten als Gridboxwert ist zur // //Zeit auf VIER Stellen beschraenkt -> DoubleFormat == [XXXXYYYY] // //Bei der Programmierung beruecksichtigen!!! // // // ////////////////////////////////////////////////////////////////////// //--------------------------------------------------------- //######################################################### CRivBasin::CRivBasin(void) { //----------------------------------------------------- // Modul information Set_Name ("RiverBasin"); Set_Author ("Christian Alwardt"); Set_Description ("Parameters of RiverBasin"); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT" , "DTM", "Digitales Gelaendemodell des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT2" , "HGGrid", "Eingaberaster der Hauptgerinnerasterzellen des Flussnetzwerkes", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT3" , "statisches Entnahmeraster", "Eingaberaster mit Angaben zur statischen Flaechenwasserentnahme.", PARAMETER_INPUT_OPTIONAL //Jahreswerte //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Value( NULL, "WCons", "Anteilige Flaechenwasserentnahme", "Wenn gesetzt, werden die Werte des statischen Entahmerasters anteilig entnommen und als Raster statWUse ausgegeben", PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( Parameters("WTHD_NODE") , "WCons2" , _TL("Dynamische Flaechenwassernutzung..."), _TL("Auswahl der Art der anteiligen Flaechenwasserwasserentnahme."), CSG_String::Format(SG_T("%s|%s"), _TL("...anteilig aus den Flussrasterzellen"), _TL("...anteilig aus Rasterzellen der Teileinzugegebiete") ), 0 ); Parameters.Add_Grid( NULL, "OUTPUT2" , "Grad", "Ausgabe der Abflussgradienten jeder Rasterzelle", PARAMETER_OUTPUT ); // Gradient in Abflussrichtung Parameters.Add_Grid( NULL, "OUTPUT3" , "Direc", "Ausgabe der Abflussrichtung fuer jede Rasterzelle", PARAMETER_OUTPUT ); // Flussrichtung 0-7 // 7|0 |1 // 6|-1|2 // 5|4 |3 Parameters.Add_Grid( NULL, "OUTPUT4" , "HGGrad", "Ausgabe der Abflussgradienten jeder Hauptgerinnerasterzelle", PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "OUTPUT5" , "RivSpeed", "Ausgabe Flussgeschwindigkeiten der Hauptgerinnerasterzellen (siehe Parametereinstellungen)", PARAMETER_OUTPUT ); Parameters.Add_Grid( NULL, "OUTPUT6" , "Coordinates", "Ausgabe der Koordinatenwerte der Rasterzellen im Format xxxx.yyyy", PARAMETER_OUTPUT ); // Konvention des Rasterzahlenwertes: xxxx.yyyy [x,y-Koordinate] Parameters.Add_Grid( NULL, "OUTPUT7" , "BasinShare", "Ausagbe der Rasterzellen des Flusseinzugsgebiets", PARAMETER_OUTPUT ); // Grids die in Fluss mueden [>0 = Flussgridkoordinate] , Flussgrids [=0] , keine Flussgrid [-1] Parameters.Add_Grid( NULL, "OUTPUT8" , "statWUse", "Ausagbe der anteiligen Flaechenwasserentnahme je Rasterzelle", PARAMETER_OUTPUT_OPTIONAL ); // Flussgrids [>=0] , keine Flussgrid [-1] Parameters.Add_Grid( NULL, "OUTPUT9" , "NumInFlowCells", "Ausgaberaster mit Angabe ueber die Anzahl der Rasterzellen, die in eine spezifische Rasterzelle (x,y) abflieszen", PARAMETER_OUTPUT ); Parameters.Add_Value( NULL, "pCr" , "Hauptgerinne-Parameter pHG", "Parameter pHG zur Berechnung der Lagtime kHG des Hauptgerinneabflusses", PARAMETER_TYPE_Double, 0.0035, 0, true ); Parameters.Add_Value( NULL, "nCr" , "Hauptgerinne-Speicherkaskade nHG", "Festlegen, wieviele Speicher die ChannelFlow River-Speicherkaskade enthaelt", PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "EnfVmax", "Maximal Geschwindigkeit des Hauptgerinnes beruecksichtigen", "Angegebene Maximalgeschwindigkeit im Hauptgerinne bei der Berechnung der durchschnittlichen Flieszgeschwindigkeit des Hauptgerinnes beruecksichtigen.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "VTresh" , "Maximalgeschwindigkeit im Hauptgerinne in km/h", "Festlegung der maximalen Wasserflussgeschwindigkeit im Hauptgerinne in km/h (oberer Grenzwert)", PARAMETER_TYPE_Double, 4, 0, true, 10, true //Achtung!! Obergrenze statisch eingestellt ); } //--------------------------------------------------------- //######################################################### bool CRivBasin::On_Execute(void) { int x, y; BasinGrids = 0; statV = 0; statN = 0; //----------------------------------------------------- // Get the parameter settings... m_pDTM = Parameters("INPUT")->asGrid(); m_pRivGrids = Parameters("INPUT2")->asGrid(); m_pWCons = Parameters("INPUT3")->asGrid(); //statisches WaterConsumption Grid (Jahreswerte) in [kg m-2 s-1] m_pGrad = Parameters("OUTPUT2")->asGrid(); m_pDirec = Parameters("OUTPUT3")->asGrid(); m_pRivGrad = Parameters("OUTPUT4")->asGrid(); //Gibt Grid aus, welches nur die Werte des Flussgefaelles enhaelt -> damit spaeter auschlieszliche Berechnug des max Flussgefaelles moeglich m_pRSpeed = Parameters("OUTPUT5")->asGrid(); m_pRaster = Parameters("OUTPUT6")->asGrid(); m_pBasinShare = Parameters("OUTPUT7")->asGrid(); m_pSharedRivCons = Parameters("OUTPUT8")->asGrid(); m_pNumInFlowCells = Parameters("OUTPUT9")->asGrid(); pCr = Parameters("pCr")->asDouble(); nCr = Parameters("nCr")->asInt(); m_pVTresh = Parameters("VTresh")->asDouble(); // [km/h] //----------------------------------------------------- // Do something... m_pGrad->Assign(0.0); m_pDirec->Assign(-1.0); m_pRivGrad->Assign(0.0); m_pRSpeed->Assign(0.0); m_pNumInFlowCells->Assign(0.0); m_pBasinShare->Assign(-1.0); // Vorab Werte -1 (kein Flussbasin); Wenn Grid in Fluss muendet > 0 (entspricht Koordinate) oder =0 wenn Flussgrid (>=0 entspricht Flussbasin) if(m_pSharedRivCons) m_pSharedRivCons->Assign(0.0); for(x=0; x < m_pDTM->Get_NX(); x++) { for(y=0; y < m_pDTM->Get_NY(); y++) { double r = x + 0.0001*y; // Konvention des Rasterzahlenwertes: xxxx.yyyy [x,y-Koordinate] m_pRaster->Set_Value(x, y, r); if(m_pDTM->is_NoData(x,y)) { m_pGrad->Set_NoData(x,y); m_pDirec->Set_NoData(x,y); m_pRivGrad->Set_NoData(x,y); } else Set_RivParam(x,y); } } //Durchnittsgeschwindigkeit in Log-Datei schreiben double res = statV / statN; std::stringstream lStr0; std::string lStr; lStr0.str(""); lStr0 << "Durschnittsgeschwindigkeit fuer pHG = " << pCr << ": " << res; lStr = lStr0.str(); WriteLog(lStr); //------------------------------------------------ if(!CRivBasin::Set_BasinShare()) //SetBasin Aufruf Message_Dlg("Achtung, Fehler beim Erzeugen der Flussabhaengigen-Anteile wegen nicht gesezter FlussGrids"); if( !m_pRivGrids ) { m_pRivGrad->Destroy(); m_pRSpeed->Destroy(); m_pNumInFlowCells->Destroy(); m_pBasinShare->Destroy(); } if( (!m_pWCons || !m_pRivGrids) && m_pSharedRivCons) m_pSharedRivCons->Destroy(); //----------------------------------------------------- // Return 'true' if everything is okay... return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CRivBasin::Set_RivParam(int x, int y) { int i, ix, iy; double z, dzMax, l; z = m_pDTM->asDouble(x,y); dzMax = 0.0; i = m_pDTM->Get_Gradient_NeighborDir(x, y); if( i >=0) { ix = Get_xTo(i, x); //x-Wert niedrigste Nachbarzelle iy = Get_yTo(i, y); //y-Wert niedrigste Nachbarzelle l = Get_Length(i); //Weg Mittelpunkt Gitterbox (x,y) nach Gitterboxmitte (ix,iy) dzMax = (z - m_pDTM->asDouble(ix, iy)) / l; //Steigung dz/l entspricht tan(Steigungswinkel) ->Gefaelle in Abflussrichtung } else // Senke!! dzMax = 0; if( m_pRivGrids && m_pRivGrids->asDouble(x,y) != 0) // Wenn bei (x,y) Flussgrid vorliegt... { double vMax2 = pow(dzMax, 0.1 ) / pCr / nCr / 24; //--- Werte zur Berechnung der Durchschnittsgeschwindigkeit im HG erfasse if(Parameters("EnfVmax")->asInt() && vMax2 > m_pVTresh) statV = statV + m_pVTresh; //Falls vMax2 groeszer als Geschwindigkeitsgrenze m_pVTresh, auf m_pVTresh setzten else statV = statV + vMax2; statN = statN + 1; //------------------------- m_pRivGrad->Set_Value( x, y, dzMax ); //Flussbezogene Grids: Flussgefaelle; (x,y) nach (ix,iy) -> Extra RivGrad-Grid das nur die Gradienten der Fluss-Rasterzellen enthaelt, damit in LandFlow einfach der MaximalGradient bzw. kmin der Fluss-Rasterzellen bestimmt werden kann ??? m_pRSpeed->Set_Value(x, y, vMax2); //Flussbezogene Grids: Flieszgeschwindigkeit der Flussgrids (lt. vorgegebenen pCr und nCr); (x,y) nach (ix,iy) m_pGrad->Set_Value( x, y, dzMax); //Allgemeine Grids: Flussgefaellewert wird auch in der allgemeinen Gefaelledatei gesetzt; (x,y) nach (ix,iy) m_pDirec->Set_Value( x, y, i); //Allgemeine Grids: Flieszrichtung Gitterbox; (x,y) nach (ix,iy) } else { m_pGrad->Set_Value( x, y, dzMax); //Allgemeine Grids: Flussgefaellewert wird gesetzt; (x,y) nach (ix,iy) m_pDirec->Set_Value( x, y, i); //Allgemeine Grids: Flieszrichtung Gitterbox; (x,y) nach (ix,iy) } } //--------------------------------------------------------- //######################################################### bool CRivBasin::Set_BasinShare(void) //Fuer alle Werte innerhalb des RiverBasin gilt: Riverbox: Wert==0, Zuflussbox: Wert==>>Riverbox-Koordinate [xxxxyyyy] || alle Boxen Ausserhalb RiverBasin: Wert==-1 { if(m_pRivGrids) { m_pNumInFlowCells->Assign(0.0); int NX = m_pDTM->Get_NX(); //Anzahl der Reihen x int NY = m_pDTM->Get_NY(); //Anzahl der Zeilen y double CellNum0 = 0; double CellNum = 0; int x, y; int i = -1; //Gesamt-Flusseinzugsgebiet und einzelne Flussrasterzelleneinzuggebiete bestimmen und jeweilige Koordinate der Ziel-Flussrasterzelle setzten //--------------------------------------------------------- for(int l=0; l < m_pDTM->Get_NCells() && Set_Progress_NCells(l); l++) //ueber alle Zellen des m_pDEM-Grids { m_pDTM->Get_Sorted(l, x, y); //sortieren der Zellen von hoechster (l=0) nach niedrigster... CellNum = 1; //Initialisierung der Zaehlung "vorherigerNachbarzellen" fuer erste Nachbarzelle (falls folgende if-Bedingung nicht erfuellt -> "gegenstandlos") CellNum0 = 0; //Erster Durchlauf: Zu "Gipfelzelle l" wird anhand des Abflusses die Muendungszelle im Flussgrid bestimmt (entspricht dem (x,y) fuer das gilt: m_pRivGrids->asDouble(x,y) != 0 )... if(m_pNumInFlowCells->asDouble(x,y) == 0 && !m_pDTM->is_NoData(x,y)) //starten nur wenn Gipfelzelle (enstspricht: m_pNumInputCells->asDouble(x,y) == 0); falls != gab es schon eine Zelle die hoeher war u damit wurde der Zweig schon abgegangen { while( !m_pDTM->is_NoData(x,y) && m_pRivGrids->asDouble(x,y) == 0 ) { i = m_pDTM->Get_Gradient_NeighborDir(x, y); if(i >= 0) //es gibt eine niedrigere Nachbarzelle... { x = Get_xTo(i, x); y = Get_yTo(i, y); if(m_pNumInFlowCells->asDouble(x,y) <= 0) //Wenn Null -> erstes Durchlaufen dieses Astes -> immer plus 1 fuer Naechstebarchbarzelle { CellNum0 = CellNum; CellNum = CellNum + 1; } else //Ast wurde vorher schon durchlaufen -> vorherige DurchlaufWerte plus die statische Anzahl der Zellen (CellNum) des noch nicht durchlaufenden Astabschnittes CellNum0 = m_pNumInFlowCells->asDouble(x,y) + CellNum; m_pNumInFlowCells->Set_Value(x, y, CellNum0); //Anzahl voheriger Zellen im Abflusverlauf werden gesetzt... vorher bereits Durchlaufene "aeste" sind beruecksichtigt } else //Senke liegt vor { CellNum0 = m_pNumInFlowCells->asDouble(x,y) * -1; m_pNumInFlowCells->Set_Value(x, y, CellNum0); break; } } // Bei Zelle (x,y) handelt es sich nun um eine Flussrasterzelle oder eine Senke... if(m_pRivGrids->asDouble(x,y) != 0) //Wenn es eine Flussrasterzelle (also Muendungszelle) ist, Wert fuer alle alle Flaechenrasterzellen setzen, die in die Flussrasterzelle (x,y) muenden { m_pBasinShare->Set_Value(x, y, 0); //Muendungsrasterzelle wird auf Null gesetzt //KoordinatenDouble erzeugen FORMAT: xxxxyyyy double r = 0; int u = 10000*x + y; // r = u; //Wert der gesetzt wird : FORMAT: xxxxyyyy (Koordinate der "Ziel"Flussgridbox in die voherige Gitterboxen muenden) m_pDTM->Get_Sorted(l, x, y); //selber Durchlauf nochmal; von der l-ten Gridbox bis Ziel-Flussfgridbox //Zweiter Durchlauf: Wiederum bei "Gipfelzelle l" beginnend wird nun fuer alle Gitterzellen auf dem Weg zur Muendungszelle der KoordinatenWert r gesetzt while( !m_pDTM->is_NoData(x,y) && m_pRivGrids->asDouble(x,y) == 0 ) { i = m_pDTM->Get_Gradient_NeighborDir(x, y); if(i >= 0) { m_pBasinShare->Set_Value(x, y, r); //Koordinaten der Ziel-Flussgridbox werden gesetzt x = Get_xTo(i, x); y = Get_yTo(i, y); } else {break;} //Nur fuer den Fall; i = -1 sollte eigentlich nicht mehr moeglich sein, da letzte Gridbox ja Flussgridbox... } } else {} } if(m_pDTM->is_NoData(x,y)) { m_pNumInFlowCells->Set_NoData(x,y); m_pBasinShare->Set_NoData(x,y); } } //--------------------------------------------------------- //######################################################### //----------------------------------------------------- // Anzahl der Gridboxes des Einzugsgebietes zaehlen: for(x=0; x < NX; x++) { for(y=0; y < NY; y++) { if(!m_pDTM->is_NoData(x,y) && m_pBasinShare->asDouble(x,y) != -1) BasinGrids++; } } //----------------------------------------------------- //Absolute Entnahmen in den Flussrasterzellen-Einzugsgebieten (Teileinzugsgebiet) berechnen und dort anteilig entnehmen if(Parameters("WCons")->asBool() && m_pWCons && m_pSharedRivCons) { for(x=0; x < NX; x++) { for(y=0; y < NY; y++) { if(!m_pDTM->is_NoData(x,y) && m_pRivGrids->asDouble(x,y) > 0 ) { // Wenn Flussrasterzelle... int sx = 0; int sy = 0; double sum = 0; //Summe der Rasterzellen des Teileinzuggebiets (ohne Flussrasterzelle) int u; double r = 0; double conSum = 0; //Summe der Verbrauchswerte des Teileinzugsgebiets double conShare = 0; //Berechnen der anteiligen Entnahme der Flussrasterzelle / Rasterzellen double cellShare = 0; //Summe aller InFlowCell-Werte des Teileinzuggebiets double testSum = 0; conSum = m_pWCons->asDouble(x, y); //Summe der Verbrauchswerte des Teileinzugsgebiets (hier Flussrasterzelle) cellShare = m_pNumInFlowCells->asDouble(x, y); //Summe aller InFlowCell-Werte des Teileinzuggebiets (hier Flussrasterzelle) //KoordinatenDouble der derzeitigen Flussrasterzelle erzeugen - FORMAT: xxxxyyyy u = 10000*x + y; r = u; //alle Rasterzellen finden die in die Flussrasterzelle muenden for(int sx=0; sx < NX; sx++) { //#pragma omp parallel for //TEST hier nicht anwendbar for(int sy=0; sy < NY; sy++) { //Wasserverbrauchswerte alle Rasterzellen die in Flussrasterzelle (x,y) muenden addieren... if(!m_pDTM->is_NoData(sx,sy) && m_pRivGrids->asDouble(sx,sy) == 0 && m_pBasinShare->asDouble(sx,sy) == r ) { if( m_pWCons) conSum = conSum + m_pWCons->asDouble(sx,sy); //Summe der Verbrauchswerte des Teileinzugsgebiets (hier uebrige Rasterzellen) sum = sum + 1; //Summe der Rasterzellen des Teileinzuggebiets (ohne Flussrasterzelle) cellShare = cellShare + m_pNumInFlowCells->asDouble(sx, sy); //Summe aller InFlowCell-Werte des Teileinzuggebiets (hier uebrige Rasterzellen) } } } if(cellShare > 0) { if(!Parameters("WCons2")->asBool()) //1) Gesammte Verbrauchssumme aus der jeweiligen Flussrasterzelle entnehmen m_pSharedRivCons->Set_Value(x, y, conSum); else { //2) Prozemtuale, anteilige Entnahme ueber das gesamte Teileinzugsgebiet conShare = ( m_pNumInFlowCells->asDouble(x, y) / cellShare ) * conSum; //Berechnen der anteiligen Entnahme der Flussrasterzelle: //Summe aller InFlowCell-Werte des Teileinzugsgebiets geteilt durch NumInFlowCells der Flussrasterzelle (x,y) -> Anteilieg Entnahme in Prozent; //dann mit Gesamtennehame des Teileinzuggebiets conSum multiplizieren -> anteilige Entnahme m_pSharedRivCons->Set_Value(x, y, conShare); //Setzen der anteiligen Entnahme der Flussrasterzelle testSum = testSum + conShare; //PruefSumme //Anteilige Entname aller anderen Rasterzellen des Teileinzuggebiets setzen, das in Flussrasterzelle (x,y) muenden for(int sx=0; sx < NX; sx++) { //#pragma omp parallel for //TEST hier nicht anwendbar for(int sy=0; sy < NY; sy++) { if(!m_pDTM->is_NoData(sx,sy) && m_pRivGrids->asDouble(sx,sy) == 0 && m_pBasinShare->asDouble(sx,sy) == r ) { conShare = ( m_pNumInFlowCells->asDouble(sx, sy) / cellShare) * conSum; //Berechnen der anteiligen Entnahme der Rasterzellen (Methode s. Flussrasterzelle oben) m_pSharedRivCons->Set_Value(sx, sy, conShare); //Setzen der anteiligen Entnahme der Flussrasterzelle testSum = testSum + conShare; //PruefSumme } } } //if( testSum != conSum ) //durch Rundungsdifferenzen kommt es bei dieser TestAbfrage zu unberechtigten Fehlermeldungen // Message_Dlg("Fehler! Gesamtentnahme aus Teileinzugsgebiet entspricht nicht der Summe der berechneten anteiligen Entnahmen"); //m_pNumInputCells->Set_Value(x, y, sum); //NUR zu Testzwecken //m_pBasinShare->Set_Value(x, y, sum/BasinGrids ); //Anzahl der Einzugsgebietszellen (anteilig) die in diese Flussgrid (x,y) fliessen } } else m_pSharedRivCons->Set_Value(x, y, conSum); } } } } return (true); } else return (false); } bool CRivBasin::WriteLog(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << "e:" << "\\Log.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } saga-2.3.1/src/modules/simulation/sim_rivflow/RivCourseImpr.h0000744000175000017500000001020312737416210025471 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivCourseImpr.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__RivCourseImpr_H #define HEADER_INCLUDED__RivCourseImpr_H //--------------------------------------------------------- #include //--------------------------------------------------------- //######################################################### class CRivCourseImpr : public CSG_Module_Grid_Interactive { public: CRivCourseImpr(void); protected: virtual bool On_Execute(void); virtual bool On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode); private: CSG_Grid *m_pDTM; double m_pDiffH, minVal; int nX, nY; void getNeighFlowGridValue(int x, int y, double minVal); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__RivCourseImpr_H saga-2.3.1/src/modules/simulation/sim_rivflow/DataTrans.cpp0000744000175000017500000001326712737416210025151 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // DataTrans.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "DataTrans.h" #include #include #include "stdio.h" #include #include #include "stdlib.h" #include using namespace std; #define ESC 27 //--------------------------------------------------------- //######################################################### CDataTrans::CDataTrans(void) { //----------------------------------------------------- // Modul information Set_Name ("DataTrans"); Set_Author ("Christian Alwardt"); Set_Description ("DataOperations"); //Parameters list... Parameters.Add_Grid_List( Parameters("SOURCE_NODE"), "SOURCE1" , SG_T("RunOff"), SG_T(""), PARAMETER_INPUT, false ); Parameters.Add_Grid_List( Parameters("SOURCE_NODE"), "SOURCE2" , SG_T("Drainage"), SG_T(""), PARAMETER_INPUT, false ); } //######################################################### //--------------------------------------------------------- //######################################################### bool CDataTrans::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Grid_List *pSources1 = Parameters("SOURCE1")->asGridList(); //RunOff Liste CSG_Parameter_Grid_List *pSources2 = Parameters("SOURCE2")->asGridList(); //Drainage Liste if( pSources1->Get_Count() > 0 && pSources2->Get_Count() > 0) { if( pSources1->Get_Count() == pSources2->Get_Count()) { m_pID = pSources1->Get_Count(); for(i=0; i < pSources1->Get_Count(); i++) { pSource1 = pSources1->asGrid(i); pSource2 = pSources2->asGrid(i); Set_TFile(pSource1, pSource2); } } else Message_Dlg("Achtung, Anzahl der Einträge stimmt nicht überein"); } delete(pSources1); delete(pSources1); return(true); } bool CDataTrans::Set_TFile(CSG_Grid *pSource1, CSG_Grid *pSource2) { if( pSource1->Get_NX() == pSource2->Get_NX() && pSource1->Get_NY() == pSource2->Get_NY()) { NX = pSource1->Get_NX(); NY = pSource1->Get_NY(); fstream myfile; std::stringstream file0; std::string file; //LandSurfaceModell-Daten //----------------------------------------------------- file0.str(""); file0 << "dataTemp/lsMData-Day" << i+1 << ".txt"; file = file0.str(); myfile.open(file.c_str(), ios::out|ios::trunc); for(int x = 0; x < NX; ++x) { for(int y = 0; y < NY; ++y) { myfile << x << " " << y; myfile << " " << pSource1->asDouble(x,y) << " " << pSource2->asDouble(x,y); myfile << "\n"; } } myfile.close(); Process_Set_Text(CSG_String::Format(SG_T("GridSave || Datensatz %d geschrieben"),i+1)); } return(true); } saga-2.3.1/src/modules/simulation/sim_rivflow/LandFlow.cpp0000744000175000017500000035227612737416210025004 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // LandFlow.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "LandFlow.h" #include #include #include #include #include #include #include #include #include #include using namespace std; #define ESC 27 //--------------------------------------------------------- //######################################################### CLandFlow::CLandFlow(void) { //----------------------------------------------------- // Modul information Set_Name ("LandFlow Version 1.0 (build 3.5.1b)"); //Manuelle erhoehung der WaterUseDATEN (NUR fuer Entnahme aus HG-Rasterzelle) Set_Author ("Christian Alwardt"); Set_Description ("Landflow of RiverBasine"); cVers = 3.51; //################################################################### //----------------------------------------------------- //Parameters list... //----------------------------------------------------- //Parameter Gruppierung... CSG_Parameter *pNode0; CSG_Parameter *pNode1; CSG_Parameter *pNode2; CSG_Parameter *pNode3; CSG_Parameter *pNode4; CSG_Parameter *pNode5; CSG_Parameter *pNode11; CSG_Parameter *pNode21; CSG_Parameter *pNode41; CSG_Parameter *pNode42; CSG_Parameter *pNode51; CSG_Parameter *pNode52; CSG_Parameter *pNode53; CSG_Parameter *pNode54; CSG_Parameter *pNode55; pNode0 = Parameters.Add_Node( NULL , "SOURCE_NODE" , _TL("Eingangsdaten"), _TL("") ); pNode0 = Parameters.Add_Node( NULL , "TARGET_NODE" , _TL("Ausgabedaten"), _TL("") ); pNode1 = Parameters.Add_Node( NULL , "GENERAL_NODE", _TL("Allgemeine Parameter"), _TL("") ); pNode11 = Parameters.Add_Node( pNode1 , "LS_NODE", _TL("Vertikale Zufluesse"), _TL("") ); pNode2 = Parameters.Add_Node( NULL , "FLOW_NODE", _TL("Parameterwerte HD Modell"), _TL("") ); pNode21 = Parameters.Add_Node( pNode2 , "RIV_NODE", _TL("Hauptgerinne-Parameter (erweitertes HD-Modell)"), _TL("") ); pNode3 = Parameters.Add_Node( NULL , "WTHD_NODE", _TL("Dynamische Flaechenwassernutzung und Abflussreduktion"), _TL("") ); pNode4 = Parameters.Add_Node( NULL , "RM_NODE", _TL("Punktuelle Rasterzellenmanipulation"), _TL("") ); pNode41 = Parameters.Add_Node( pNode4 , "RM1_NODE", _TL("Rasterzelle 1"), _TL("Manipulation des Gerinne- bzw. Hauptgerinneabflusses: Rasterzelle 1") ); pNode42 = Parameters.Add_Node( pNode4 , "RM2_NODE", _TL("Rasterzelle 2"), _TL("Manipulation des Gerinne- bzw. Hauptgerinneabflusses: Rasterzelle 2") ); pNode5 = Parameters.Add_Node( NULL , "MONI_NODE", _TL("Test- und Monitoring-Routinen"), _TL("") ); pNode51 = Parameters.Add_Node( pNode5 , "EvP1_NODE", _TL("Evaluierungspunkt 1 [Default: Elbe5000]"), _TL("") ); pNode52 = Parameters.Add_Node( pNode5 , "EvP2_NODE", _TL("Evaluierungspunkt 2 [Default: Elbe5000]"), _TL("") ); pNode53 = Parameters.Add_Node( pNode5 , "EvP3_NODE", _TL("Evaluierungspunkt 3 [Default: Elbe5000]"), _TL("") ); pNode54 = Parameters.Add_Node( pNode5 , "RBM_NODE", _TL("Ausgangsrasterzelle Flusseinzugsgebiet [Default: Elbe5000]"), _TL("") ); pNode55 = Parameters.Add_Node( pNode5 , "TEST1_NODE", _TL("TestRoutine 1"), _TL("") ); //----------------------------------------------------- //Grids... Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT", "Gelaendemodell (DTM)", "Digitales Gelaendemodell des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT2" , "Hoehengradienten (Grad)", "Abflussgradienten jeder Rasterzelle des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT10" , "Flusseinzugsgebiet (BasinShare)", "Abgrenzung des Flusseinzugsgebiets mit den Teileinzugsgebieten des Flussnetzwerkes", PARAMETER_INPUT ); Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT8" , "HG-Raster (HGGrid)", "Hauptgerinnerasterzellen", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT9" , "HG-Hoehengradienten (HGGrad)", "Abflussgradienten der Hauptgerinnerasterzellen", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "INPUT11" , "Referenzverlauf Flussbilanz", "Raster des Referenzverlauf des (linearen) Hauptflussarmes, der zur Erstellung der Flusswasserbilanz herangezogen werden soll", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( NULL, "INPUT12" , "Zuflussrasterzellen (NumInFlowCells)", "Raster mit Angabe ueber die Anzahl der Rasterzellen, die in eine spezifische Rasterzelle (x,y) abflieszen", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( Parameters("WTHD_NODE"), "INPUT3" , "statische Wassserentnahme (statWUse)", "Flaechenbasierte statische Wassserentnahme pro RiverGridbox in. ACHTUNG: Funktioniert ggf. nur bei bereits initiierten Systemen bzw. Vorlauf", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT5" , "Fluss-Speicher einlesen", "Simulation mit spezifischen Gerinne- bzw. Hauptgerinne-Speicherwerten (ChannelFlow) initiieren", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT6" , "Oberflaechenabfluss-Speicher einlesen", "Simulation mit spezifischen Oberflaechenabfluss-Speicherwerten (OverlandFlow) initiieren", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( Parameters("SOURCE_NODE"), "INPUT7" , "Grundwasserabfluss-Speicher einlesen", "Simulation mit spezifischen Grundwasserabfluss-Speicherwerten (BaseFlow) initiieren", PARAMETER_INPUT_OPTIONAL //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); Parameters.Add_Grid( Parameters("TARGET_NODE"), "OUTPUT" , "Fluss-Speicher ausgeben", "Fluss-Speicher 'CFCache' (ChannelFlowCache) am Ende der Simulation ausgeben - Initialisierungsdaten)", PARAMETER_OUTPUT ); Parameters.Add_Grid( Parameters("TARGET_NODE"), "OUTPUT2" , "Oberflaechenabfluss-Speicher ausgeben", "Oberflaechenabfluss-Speicher 'OFCache' (OverlandFlowCache) am Ende der Simulation ausgeben - Initialisierungsdaten", PARAMETER_OUTPUT ); Parameters.Add_Grid( Parameters("TARGET_NODE"), "OUTPUT3" , "Grundwasserabfluss-Speicher ausgeben", "Grundwasserabfluss-Speicher 'BFCache' (BaseFlowCache) am Ende der Simulation ausgeben - Initialisierungsdaten", PARAMETER_OUTPUT ); Parameters.Add_Grid( Parameters("TARGET_NODE"), "OUTPUT4" , "Wasserflussvolumen", "Wasserflussvolumen in m3/s", PARAMETER_OUTPUT ); Parameters.Add_Grid( Parameters("TARGET_NODE"), "OUTPUT5" , "SumRunoffDrainage", "Aufsummieren der vertikalen Runoff und Drainage Zufluesse fuer jede Rasterzelle ueber den gesamten Simulationsverlauf", PARAMETER_OUTPUT ); Parameters.Add_Grid( Parameters("WTHD_NODE"), "OUTPUT6" , "DynWUse", "Dynamisch eingelesene Flaechenwasssernutzung pro Rasterzelle. ACHTUNG: Funktioniert nur bei bereits initiierten Systemen bzw. Vorlauf", PARAMETER_OUTPUT //siehe Funktion WConsRiv() //ACHTUNG auf optionale Eingabe gesetzt -> 'Sicherheits-'Abfrage einbauen ); //----------------------------------------------------- //Allgemeine Parameter... Parameters.Add_Value( Parameters("GENERAL_NODE"), "onlyRB" , "Berechnung nur im Flusseinzugsgebiet", "Der Abfluss wird nur ueber die Rasterzellen des Flusseinzugsgebietes berechnet", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "TimeStep" , "Zeitschrittdauer [s]", "Dauer eines Simulations-Zeitschritts in Sekunden", PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "CalcT", "automatisierter max. Zeitschritt", "Automatisierte Berechnung der maximal moeglichen Dauer eines Zeitschrittes in [s] - Zeitschrittdauern wird ignoriert.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "sYear" , "Startjahr", "Jahr in dem die Simulation zum 1. Januar gestartet wird", PARAMETER_TYPE_Int, 1999, 1979, true, 2009, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "DayNum" , "Anzahl der Simulationstage", "Anzahl der gesamten Simulationtage ueber die berechnete wird", PARAMETER_TYPE_Int, 365, 1, true, 7670, true ); Parameters.Add_FilePath( Parameters("GENERAL_NODE") , "Folder2", _TL("Speicherordner"), _TL("Ordern in den alle Ausgabedaten gespeichert werden sollen"), _TL("Textdatei|*.txt|All Files|*.*"), 0, false ,true ,false ); Parameters.Add_FilePath( Parameters("LS_NODE") , "Folder1", _TL("Pfad LS-Daten"), _TL("Ordnerpfad der Surface Runoff- und Drainagerasterdaten des Landoberflaechenschemas"), _TL("SAGA Grid Files (*.sgrd)|*.sgrd|All Files|*.*"),0 ,false ,true ,false ); Parameters.Add_Value( Parameters("LS_NODE"), "stRedFacR", "Reduzierungsfaktor Surface Runoff [% / 100]", "Statische Reduzierung des vertikalen Zuflusses 'Surface Runoff' in [% / 100] pro Zeitschritt.", PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); Parameters.Add_Value( Parameters("LS_NODE"), "autoFacD" , "Ausgleich der Surface Runoff Reduktion", "Erhoeht automatisch die Drainage um denjenigen Volumenbetrag, um den der Surface Runoff reduziert wurde. Wenn gesetzt, wird etwaige Reduzierung der Drainage NICHT beruecksichtigt!", PARAMETER_TYPE_Bool, 0 ); Parameters.Add_Value( Parameters("LS_NODE"), "stRedFacD", "Reduzierungsfaktor Drainage [% / 100]", "Statische Reduzierung des vertikalen Zuflusses der 'Drainage' in [% / 100] pro Zeitschritt.", PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); Parameters.Add_Value( Parameters("LS_NODE"), "OffsetR", "Offsetwert Surface Runoff [m3/s]", "Statischer Offsetwert auf den vertikalen Zufluss 'Surface Runoff' in [m3/s] je Rasterzelle. ACHTUNG wird auf jede Rasterzelle angewendet, daher limitiert auf +/-1 m3/s. Bei Wahl des Wertes Aufloesung beachten! ", PARAMETER_TYPE_Double, 0.0, -1.0, true, 1.0, true ); Parameters.Add_Value( Parameters("LS_NODE"), "OffsetD", "Offsetwert Drainage [m3/s]", "Statischer Offsetwert auf den vertikalen Zufluss 'Drainage' in [m3/s] je Rasterzelle. ACHTUNG wird auf jede Rasterzelle angewendet, daher limitiert auf +/-1 m3/s. Bei Wahl des Wertes Aufloesung beachten!", PARAMETER_TYPE_Double, 0.0, -1.0, true, 1.0, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "CacheUse", "Initiierung mit vorhandenen Speichern", "Initialisierung der Simulation mit spezifischen Speicherwerten (Raster und NCache)", PARAMETER_TYPE_Bool, false ); Parameters.Add_FilePath( Parameters("GENERAL_NODE") , "Folder4", _TL("NCache einlesen"), _TL("Einlesen der NCache Textdatei"), _TL("Textdatei (*.txt)|*.txt|All Files|*.*"),0 ,false ,false ,false ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "wNC" , "Ausgabe NCache", "Schreibt die Werte der Speicherkaskaden zum Ende Simulation in eine Textdatei (Initialisierungsdaten)", PARAMETER_TYPE_Bool, 0 ); //----------------------------------------------------- //Parameterwerte HD Modell Parameters.Add_Value( Parameters("FLOW_NODE"), "ParamC" , "Gerinne-Parameter cG", "Parameter cG zur Berechnung der Lagtime kG des Gerinneabflusses", PARAMETER_TYPE_Double, 6e-2, 0, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "ParamG" , "Oberflaechen-Parameter cO", "Parameter cO zur Berechnung der Lagtime kO des Oberflaechenabflusses", PARAMETER_TYPE_Double, 357e-3, 0, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "ParamB" , "Grundwasser-Parameter pB", "Parameter pB zur Berechnung der Lagtime kB des Grundwasserabflusses", PARAMETER_TYPE_Double, 300, 0, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "nG" , "Gerinne-Speicherkaskade nG", "Festlegen, wieviele Speicher die Gerinne-Speicherkaskade nG enthaelt", PARAMETER_TYPE_Int, 3, 1, true ); Parameters.Add_Choice( Parameters("RIV_NODE") , "RivG" , _TL("Beruecksichtigung der Hauptgerinnerasterzellen?"), _TL("Seperate Beruecksichtigung und Berechnung ueber Hauptgerinnerasterzellen - neben den normalen Gerinnerasterzellen."), CSG_String::Format(SG_T("%s|%s|")/*(SG_T("%s|%s|%s|%s|")*/, _TL("nein"), _TL("ja; bestimmen anhand eines Hauptgerinnerasters (HG Raster)")/*, _TL("ja; bestimmen ueber das Wasserflussvolumen (P:RFlow)"), _TL("ja; bestimmen ueber die jeweilige Anzahl der ZuflussRasterzellen (IR:NumInFlowCells, P:NumCells")*/ ), 1 ); Parameters.Add_Value( Parameters("RIV_NODE"), "ParamCr" , "Hauptgerinne-Parameter cHG", "Parameter cHG zur Berechnung der Lagtime kHG des ChannelFlow-River [optional siehe oben]", PARAMETER_TYPE_Double, 0.007, 0, true, 1.0, true ); Parameters.Add_Value( Parameters("RIV_NODE"), "nHG" , "Hauptgerinne-Speicherkaskade nHG", "Festlegen, wieviele Speicher die Hauptgerinne-Speicherkaskade enthaelt [optional siehe oben]", PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "EnfVmax", "Abflussgeschwindigkeit begrenzen", "Die mittlere Wasserabflussgeschwindigkeit wird auf einen Hoechstwert begrenzt - Zeitschrittvorgaben und automatisierter Zeitschritt wird ueberschrieben.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("FLOW_NODE"), "VTresh" , "Oberer Abflussgeschwindigkeitsgrenzwert [km/h]", "Maximale mittlere Wasserabflussgeschwindigkeit in km/h", PARAMETER_TYPE_Double, 4, 0, true, 10, true //Achtung!! Obergrenze statisch eingestellt ); //----------------------------------------------------- //Dynamische Wasserentnahme und Abflussreduktion Parameters.Add_Choice( Parameters("WTHD_NODE") , "WCons" , _TL("Dynamische Flaechenwassernutzung..."), _TL("Auswahl der Art der dynamischen Flaechenwasserwassernutzung (WUse). ACHTUNG: Funktioniert ggf. nur bei bereits initiierten Systemen bzw. nach Vorlauf"), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("keine"), _TL("...anteilig aus den Hauptgerinnerasterzellen"), _TL("...anteilig aus Rasterzellen der Teileinzugegebiete"), _TL("...genau den entsprechenden Wert aus der jeweiligen Rasterzelle entnehmen") ), 0 ); Parameters.Add_FilePath( Parameters("WTHD_NODE") , "Folder3", _TL("Ordnerpfad der WUse Daten"), _TL("Speicherpfad der dynamischen Wassernutzungsdaten"), _TL("SAGA Grid Files (*.sgrd)|*.sgrd|All Files|*.*"),0 ,false ,true ,false ); Parameters.Add_Choice( Parameters("WTHD_NODE") , "WConUnit" , _TL("WUse Einheit"), _TL("Einheit in der die WUse Daten vorliegen"), CSG_String::Format(SG_T("%s|%s|"), _TL("m3/s"), _TL("m3/Monat") ), 0 ); Parameters.Add_Value( Parameters("WTHD_NODE"), "WConsD" , "Vorlauftage ohne Entnahmen", "Anzahl der Simulationestage bevor eine Wasserentnahme beruecksichtigt wird", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( Parameters("WTHD_NODE"), "WConThres", "Abflussschwellenwert [m3/s]", "Fester Abflussschwellenwert in m3/s fuer das Hauptgerinne, der durch Entnahmen nicht unterschritten werden soll.", PARAMETER_TYPE_Double, 0.0, 0.0, true ); Parameters.Add_Value( Parameters("WTHD_NODE"), "stConsAll", "Abflussreduzierungsfaktor Gerinnerasterzellen [% / 100]", "Statische Reduzierung des Gesamtabflusses in den Gerinnerasterzellen um [% / 100] pro Zeitschritt.", PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); Parameters.Add_Value( Parameters("WTHD_NODE"), "stConsRiv", "Abflussreduzierungsfaktor HG-Rasterzellen [% / 100]", "Statische Reduzierung des Gesamtabflusses in den Hauptgerinnegitterboxen um [% / 100] pro Zeitschritt.", PARAMETER_TYPE_Double, 0.0, 0.0, true, 1.0, true ); //----------------------------------------------------- //punktuelle Rasterzellenmanipulation //RM1 Parameters.Add_Choice( Parameters("RM1_NODE") , "vRM1" , _TL("Abflussmanipulation Rasterzelle 1... "), _TL("Der Gerinne- bzw. Hauptgerinneabfluss kann mit dieser Methode fuer Rasterzelle 1 manipuliert werden. "), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("nein"), _TL("Ja, berechneten Abfluss veraendern: res. Abfluss = berechn. Abfluss * q + a"), _TL("Ja, Abfluss manuell vorgeben: res. Abfluss = Speicherinhalt * q + a") ), 0 ); Parameters.Add_Value( Parameters("RM1_NODE"), "RM1x" , "Rasterzelle 1 [x-Koord.]", "x-Koordinate der Rasterzelle 1, fuer die der Abfluss manipulatiert werden soll", PARAMETER_TYPE_Int, -1, -1, true ); Parameters.Add_Value( Parameters("RM1_NODE"), "RM1y" , "Rasterzelle 1 [y-Koord.]", "y-Koordinate der Rasterzelle 1, fuer die der Abfluss manipulatiert werden soll", PARAMETER_TYPE_Int, -1, -1, true ); Parameters.Add_Value( Parameters("RM1_NODE"), "RM1q" , "q [%/100]", "Prozentualer Faktor q [%/100] fuer Rasterzelle 1", PARAMETER_TYPE_Double, 1, 0, true ); Parameters.Add_Value( Parameters("RM1_NODE"), "RM1a" , "a [+-m3/s]", "Addidativer Offsetwert a [+-m3/s] fuer Rasterzelle 1", PARAMETER_TYPE_Double, 0 ); //RM22 Parameters.Add_Choice( Parameters("RM2_NODE") , "vRM2" , _TL("Abflussmanipulation Rasterzelle 2... "), _TL("Der Gerinne- bzw. Hauptgerinneabfluss kann mit dieser Methode fuer Rasterzelle 2 manipuliert werden. "), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("nein"), _TL("Ja, berechneten Abfluss veraendern: res. Abfluss = berechn. Abfluss * q + a"), _TL("Ja, Abfluss manuell vorgeben: res. Abfluss = Speicherinhalt * q + a") ), 0 ); Parameters.Add_Value( Parameters("RM2_NODE"), "RM2x" , "Rasterzelle 2 [x-Koord.]", "x-Koordinate der Rasterzelle 2, fuer die der Abfluss manipulatiert werden soll", PARAMETER_TYPE_Int, -1, -1, true ); Parameters.Add_Value( Parameters("RM2_NODE"), "RM2y" , "Rasterzelle 2 [y-Koord.]", "y-Koordinate der Rasterzelle 2, fuer die der Abfluss manipulatiert werden soll", PARAMETER_TYPE_Int, -1, -1, true ); Parameters.Add_Value( Parameters("RM2_NODE"), "RM2q" , "q [%/100]", "Prozentualer Faktor q [%/100] fuer Rasterzelle 2", PARAMETER_TYPE_Double, 1, 0, true ); Parameters.Add_Value( Parameters("RM2_NODE"), "RM2a" , "a [+-m3/s]", "Addidativer Offsetwert a [+-m3/s] fuer Rasterzelle 2", PARAMETER_TYPE_Double, 0 ); //Test- und Monitoring-Routinen //EvP1 Parameters.Add_String( Parameters("EvP1_NODE") , "EvP1s" , _TL("EvP1 Name"), _TL("Name des Evaluierungspunktes 1"), SG_T("NeuDarchau.txt") ); Parameters.Add_Value( Parameters("EvP1_NODE"), "EvP1x" , "EvP1 Rasterzelle [x-Koord.]", "x-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 1", PARAMETER_TYPE_Int, 30, 0, true ); Parameters.Add_Value( Parameters("EvP1_NODE"), "EvP1y" , "EvP1 Rasterzelle [y-Koord.]", "y-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 1", PARAMETER_TYPE_Int, 115, 0, true ); //EvP2 Parameters.Add_String( Parameters("EvP2_NODE") , "EvP2s" , _TL("EvP2 Name"), _TL("Name des Evaluierungspunktes 2"), SG_T("Lutherstadt-Wittenberg.txt") ); Parameters.Add_Value( Parameters("EvP2_NODE"), "EvP2x" , "EvP2 Rasterzelle [x-Koord.]", "x-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 2", PARAMETER_TYPE_Int, 54, 0, true ); Parameters.Add_Value( Parameters("EvP2_NODE"), "EvP2y" , "EvP2 Rasterzelle [y-Koord.]", "y-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 2", PARAMETER_TYPE_Int, 85, 0, true ); //EvP3 Parameters.Add_String( Parameters("EvP3_NODE") , "EvP3s" , _TL("EvP3 Name"), _TL("Name des Evaluierungspunktes 3"), SG_T("Schoena.txt") ); Parameters.Add_Value( Parameters("EvP3_NODE"), "EvP3x" , "EvP3 Rasterzelle [x-Koord.]", "x-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 3", PARAMETER_TYPE_Int, 78, 0, true ); Parameters.Add_Value( Parameters("EvP3_NODE"), "EvP3y" , "EvP3 Rasterzelle [y-Koord.]", "y-Koordinate der spezifischen Hauptgerinnerasterzelle des Evaluerungspunktes 3", PARAMETER_TYPE_Int, 65, 0, true ); //RBM Parameters.Add_Value( Parameters("RBM_NODE"), "RBMx" , "Ausgangsrasterzelle [x-Koord.]", "x-Koordinate der Ausgangsrasterzelle des Flusseinzugsgebietes", PARAMETER_TYPE_Int, 16, 0, true ); Parameters.Add_Value( Parameters("RBM_NODE"), "RBMy" , "Ausgangsrasterzelle [y-Koord.]", "y-Koordinate der Ausgangsrasterzelle des Flusseinzugsgebietes", PARAMETER_TYPE_Int, 121, 0, true ); Parameters.Add_Value( Parameters("MONI_NODE"), "wP" , "SimParameters", "Schreibt wichtige, der Simulation zugrundeliegenden Parameter in eine Textdatei", PARAMETER_TYPE_Bool, 1 ); Parameters.Add_Value( Parameters("MONI_NODE"), "eP" , "Fehlerprotokoll", "Schreibt Fehler in Textfile", PARAMETER_TYPE_Bool, 1 ); Parameters.Add_Value( Parameters("MONI_NODE"), "MoniLog1" , "RiverBasinDay-Monitoring", "Monitoring taegicher Werte des Flusseinzugsgebiets", PARAMETER_TYPE_Bool, 1 ); Parameters.Add_Value( Parameters("MONI_NODE"), "MoniLog3" , "RiverBasinMonth-Monitoring", "Monitoring monatlicher Werte des Flusseinzugsgebiets", PARAMETER_TYPE_Bool, 1 ); Parameters.Add_Value( Parameters("MONI_NODE"), "MoniLog2" , "WSystem-Monitoring", "Monitoring von Zu- und Abflusswerten des WasserGesamtsystems", PARAMETER_TYPE_Bool, 1 ); //Test1 Parameters.Add_Choice( Parameters("TEST1_NODE") , "Test1" , _TL("Testroutine1 durchfuehren... "), _TL("Waehlen ob TestRoutine 1 durchgefuehrt werden soll... 1) nur fuer Teileinzugsgebiet der HG-Rasterzelle oder 2) fuer das Flusseinzugsgebiet bis zum Erreichen der HG-Rasterzelle."), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("nein"), _TL("Ja, TestRoutine1 nur fuer Teileinzugsgbiet der HG-Rasterzelle"), _TL("Ja, TestRoutine1 fuer Flusseinzugsgebiet bis zu der HG-Rasterzelle") ), 0 ); Parameters.Add_Value( Parameters("TEST1_NODE"), "xt1" , "Hauptgerinnerasterzelle [x-Koord.]", "x-Koordinate der spezifischen Hauptgerinnerasterzelle fuer TestRoutine 1", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( Parameters("TEST1_NODE"), "yt1" , "Hauptgerinnerasterzelle [y-Koord.]", "y-Koordinate der spezifischen Hauptgerinnerasterzelle fuer TestRoutine 1", PARAMETER_TYPE_Int, 0, 0, true ); //----------------------------------------------------- /* Parameters.Add_Value( Parameters("RIV_NODE"), "RFlow" , "Wasserflussvolumen [untere Grenze]", "Unterer Grenzwert des Wasserflussvolumens, ab dem eine Flussrasterzelle vorliegen soll [siehe Auswahl 'Flussrasterzellen beruecksichtigen'].", PARAMETER_TYPE_Double, 0, 0, true ); Parameters.Add_Value( Parameters("RIV_NODE"), "NumCells" , "ZuflussRasterzellen [untere Grenze]", "Unterer Grenzwert der Anzahl an ZuflussRasterzellen, ab der eine Flussrasterzelle vorliegen soll [siehe Auswahl 'Flussrasterzellen beruecksichtigen'].", PARAMETER_TYPE_Int, 0, 0, true );*/ //################################################################### } /////////////////////////////////////////////////////////// // // // Hauptfunktion // // // /////////////////////////////////////////////////////////// bool CLandFlow::On_Execute(void) { //----------------------------------------------------- //SAGA-Input m_pDTM = Parameters("INPUT")->asGrid(); m_pGrad = Parameters("INPUT2")->asGrid(); m_pWConsIn = Parameters("INPUT3")->asGrid(); //statisches WaterConsumption Grid in m3/s -> [kg m-2 s-1] m_pCCacheIn = Parameters("INPUT5")->asGrid(); m_pRCacheIn = Parameters("INPUT6")->asGrid(); m_pDCacheIn = Parameters("INPUT7")->asGrid(); m_pRivGrids = Parameters("INPUT8")->asGrid(); m_pRivGrad = Parameters("INPUT9")->asGrid(); m_pBasinShare = Parameters("INPUT10")->asGrid(); m_pRivBalanceGrid = Parameters("INPUT11")->asGrid(); m_pNumInFlow = Parameters("INPUT12")->asGrid(); m_pCCacheOut = Parameters("OUTPUT")->asGrid(); m_pRCacheOut = Parameters("OUTPUT2")->asGrid(); m_pDCacheOut = Parameters("OUTPUT3")->asGrid(); m_pChannelFlow = Parameters("OUTPUT4")->asGrid(); m_pSumRunoffDrainage = Parameters("OUTPUT5")->asGrid(); m_pWConsOut = Parameters("OUTPUT6")->asGrid(); //dynamisch imm Programmablauf generiertes WaterConsumption Grid in [kg m-2 s-1] m_pTStep = Parameters("TimeStep")->asInt(); // [s] m_sYear0 = Parameters("sYear")->asInt(); // [y] m_pDays = Parameters("DayNum")->asInt(); m_pLSDataFolder = Parameters("Folder1")->asString(); m_pDataSaveFolder = Parameters("Folder2")->asString(); m_pWConDataFolder = Parameters("Folder3")->asString(); m_pNCacheFolder = Parameters("Folder4")->asString(); m_pVTresh = Parameters("VTresh")->asDouble(); // [km/h] m_pWConsDIn = Parameters("WConsD")->asInt(); m_pWConThres = Parameters("WConThres")->asDouble(); //Schwellenwert fuer HG-Abfluss der auch bei Entnahmen nicht unterschritten werden soll m_pOffsetR = Parameters("OffsetR")->asDouble(); //Offsetwert auf den vertikalen Zufluss 'RunOff' pro Rasterzelle in m3/s m_pOffsetD = Parameters("OffsetD")->asDouble(); //Offsetwert auf den vertikalen Zufluss 'Drainage' pro Rasterzelle in m3/s m_pConsFacAll = (Parameters("stConsAll")->asDouble()); // Entnahmefaktor aus Gitterboxen [%]/[dt] m_pConsFacRiv = (Parameters("stConsRiv")->asDouble()); // Entnahmefaktor aus Fluss-Gitterboxen [%]/[dt] m_pRedFacR = (Parameters("stRedFacR")->asDouble()); // Reduzierungsfaktor des RunOff [%]/[dt] m_pRedFacD = (Parameters("stRedFacD")->asDouble()); // Reduzierungsfaktor der Drainage [%]/[dt] nC = Parameters("nG")->asInt(); //Anzahl der Speicherkaskaden des ChannelFlow Speichers nCr = Parameters("nHG")->asInt(); //Anzahl der Speicherkaskaden des ChannelFlow River-Speichers C0 = Parameters("ParamC")->asDouble(); C0r = Parameters("ParamCr")->asDouble(); // Parameter fuer ChannelFlow im River [optional] G0 = Parameters("ParamG")->asDouble(); pB = Parameters("ParamB")->asDouble(); var2 = Parameters("MoniLog1")->asBool(); var3 = Parameters("MoniLog2")->asBool(); var4 = Parameters("MoniLog3")->asBool(); m_pEvP1s = Parameters("EvP1s")->asString(); m_pEvP2s = Parameters("EvP2s")->asString(); m_pEvP3s = Parameters("EvP3s")->asString(); //----------------------------------------------------- //Setzen von statischen Programmvariablen [0]=off [1]=on var1 = 1; //Prozentuale Wasserentnahme zulassen //----------------------------------------------------- //----------------------------------------------------- //Simulationsstart: Startzeit und -datum erfassen time_t rawtime; struct tm * timeinfo; time (&rawtime); timeinfo = localtime (&rawtime); //----------------------------------------------------- //----------------------------------------------------- //SpeicherDateipfad (sfile) fuer diese Simulation wird generiert und entsprechender Ordner erstellt - Ordnerformat : ddmmyy_HHMM std::stringstream sPath0; sPath0.str(""); char buffer [20]; strftime(buffer,20,"%d%m%y_%H%M",timeinfo); sPath0 << m_pDataSaveFolder.b_str() << "\\" << buffer; //^Speicherdateipfad m_pSPath = sPath0.str(); //^ sPath0.str(""); sPath0 << m_pSPath << "\\Grids"; //^Unter-Speicherdateipfad1 m_pSPath2 = sPath0.str(); //^ sPath0.str(""); sPath0 << m_pSPath << "\\RivBalance"; //^Unter-Speicherdateipfad2 m_pSPath3 = sPath0.str(); //^ SG_Dir_Create(CSG_String(m_pSPath .c_str())); //SaveOrdner zum speichern der Simulationsdaten wird erstellt SG_Dir_Create(CSG_String(m_pSPath2.c_str())); //Unter-SaveOrdner1 zum speichern der Grid-Dateien wird erstellt SG_Dir_Create(CSG_String(m_pSPath3.c_str())); //Unter-SaveOrdner2 zum speichern der Grid-Dateien wird erstellt //----------------------------------------------------- //LoadPfad //----------------------------------------------------- //FileName-String std::stringstream file0; std::string file; //----------------------------------------------------- //Parameter m_sYear = m_sYear0; //Jahresvariable initiieren nG = 1; //Anzahl der Speicherkaskaden des GroundFlow Speichers - STATISCH NX = m_pDTM->Get_NX(); //Anzahl der Reihen x NY = m_pDTM->Get_NY(); //Anzahl der Zeilen y NumRBGrids = 0; //Anzahl der Rasterzellen im Flusseinzugsgebiet NumGrids = 0; //Anzahl der Rasterzellen im DTM (ohne NoDataZellen) errC = 0; //Fehlercode Variable errC2 = 0; //Fehlercode Variable2 errC3 = 0; //Fehlercode Variable3 errC4 = 0; //Fehlercode Variable4 m_pWConsD = m_pWConsDIn; // Operator fuer "verbleibende Tage bis Entnahme" wird auf Input-Wert gesetzt //###################################################### //Pruefroutinen //----------------------------------------------------- //STATISCHE SICHERHEITSANGABEN!! ueBERARBEITEN!!! if(m_sYear == 1989 && m_pDays > 7670) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1990 && m_pDays > 7305) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1991 && m_pDays > 6940) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1992 && m_pDays > 6575) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1993 && m_pDays > 6209) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1994 && m_pDays > 5844) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1995 && m_pDays > 5479) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1996 && m_pDays > 5114) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1997 && m_pDays > 4748) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1998 && m_pDays > 4383) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 1999 && m_pDays > 4018) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2000 && m_pDays > 3653) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2001 && m_pDays > 3287) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2002 && m_pDays > 2922) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2003 && m_pDays > 2557) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2004 && m_pDays > 2192) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2005 && m_pDays > 1826) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2006 && m_pDays > 1461) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2007 && m_pDays > 1096) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2008 && m_pDays > 731) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); if(m_sYear == 2009 && m_pDays > 365) WriteLog("Fehler! Anzahl der Tageschritte zu grosz - uebersteigt Anzahl der Datensaetze!"); //###################################################### //Analyse------------------------------------------- for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if(!m_pDTM->is_NoData(x,y)) { NumGrids++; //Anzahl der Rasterzellen im DTM (ohne NoDatazellen) if(m_pBasinShare->asDouble(x,y) >= 0) NumRBGrids++; //Anzahl der Rasterzellen im Flusseinzugsgebiet } } } //-------------------------------------------------- //################################################################### //###################################################### //Ermittlung kMin, vMax // double zMax, zMax2; double k_Min0; //temporaerer Operator zur bestimmung von KMin und vMax int n0; //temporaerer Operator zur bestimmung von KMin und vMax //----------------------------------------------------- //nMax Wird benoetigt um Eintraege in NCArray-Array und -File zu setzten / zu lesen | Eigentlich sollte gelten nC >= nCr if(nC >= nCr) nMax = nC; else nMax = nCr; //----------------------------------------------------- zMax = m_pGrad->Get_ZMax(); //liefert maximale Steigung des DEM Grids ueber GradGrid //minimalsten Retetionskoeffizienten der jeweiligen Abflussarten bestimmen kMinG = G0/(nG*2) * (m_pDTM->Get_Cellsize() / 1000 ) / pow(zMax, 0.1 ); //anhand zMax Berechnung der kleinsten GroundFlow-Lagtime kMinC = C0/(nC*2) * (m_pDTM->Get_Cellsize() / 1000 ) / pow(zMax, 0.1 ); //anhand zMax Berechnung der kleinsten ChannelFlow-Lagtime kMinB = pB * (m_pDTM->Get_Cellsize() / 1000 ) / 50; //anhand zMax Berechnung der kleinsten BaseFlow-Lagtime //mittlere vMax der jeweiligen Abflussarten bestimmen (in einer Speicher Kaskade entspricht die Mittlere MAximalgeschwindigkeit der Summe der einzelnen Speicher-Maximalgeschwindigkeiten) vMaxC = m_pDTM->Get_Cellsize() / 1000 / kMinC / nC / 24; vMaxG = m_pDTM->Get_Cellsize() / 1000 / kMinG / nG / 24; // falls Flusssgrids beruecksichtigt werden... if( Parameters("RivG")->asInt() > 0 ) { if( m_pRivGrids && m_pRivGrad) { zMax2 = m_pRivGrad->Get_ZMax(); //liefert maximale Steigung der RiverGrids ueber RiverGradIn kMinCr = C0r/(nCr*2) * (m_pDTM->Get_Cellsize() / 1000 ) / pow(zMax2, 0.1 ); //anhand zMax2 Berechnung der kleinsten ChannelFlow River-Lagtime vMaxCr = m_pDTM->Get_Cellsize() / 1000 / kMinCr / nCr / 24; //----------------------------------------------------- //nMax Wird benoetigt um Eintraege in NCArray-Array und -File zu setzten / zu lesen | Eigentlich sollte gelten nC >= nCr if(nC >= nCr) nMax = nC; else nMax = nCr; //----------------------------------------------------- } else { Message_Dlg("Flussgrids koennen nicht beruecksichtigt werden, da kein RiverGrids und/oder RiverGrad-Input gesetzt wurde"); return (false); } } else //Wenn Flussgrids nicht extra veruecksichtigt werden { kMinCr = -1; vMaxCr = -1; } //vMax aller Abflussarten bestimmen if(vMaxCr >= vMaxC) vMax = vMaxCr; else vMax = vMaxC; if(vMaxG > vMax) vMax = vMaxG; //Wenn mittlere Geschwindigkeitsobergrenze gesetzt und diese kleiner als errechnete mittlere Maximalgeschwindigkeit vMax... if( Parameters("EnfVmax")->asBool()) //Retentionskoeffizienten nach "oben" anpassen um mittlere Geschwindigkeitsobergrenze einzuhalten { if( m_pVTresh < vMax) { //mittlere Geschwindigkeitsobergrenze wird (bisher) allgemein fuer alle Abflussarten gesetzt!! vMax = m_pVTresh; if( (m_pDTM->Get_Cellsize() / 1000 / vMax / nC / 24) > kMinC) kMinC = m_pDTM->Get_Cellsize() / 1000 / vMax / nC / 24; if( Parameters("RivG")->asInt() > 0 && (m_pDTM->Get_Cellsize() / 1000 / vMax / nCr / 24) > kMinCr ) kMinCr = m_pDTM->Get_Cellsize() / 1000 / vMax / nCr / 24; if( (m_pDTM->Get_Cellsize() / 1000 / vMax / nG / 24) > kMinG) kMinG = m_pDTM->Get_Cellsize() / 1000 / vMax / nG / 24; } else Message_Dlg("Eingabe der Geschwindigkeitsobergrenze ist groeszer als maximal berechnete Geschwindigkeit - Eingabe wird ignoriert"); } //Bestimmen des minimalsten Retentionskoeffizienten... if(kMinC < kMinG) k_Min0 = kMinC; else k_Min0 = kMinG; if(kMinCr >= 0 && kMinCr < k_Min0) k_Min0 = kMinCr; if(kMinB < k_Min0) //Sicherheitsabfrage { Message_Dlg("BaseFlow-Lagtime ist am geringsten - SEHR wahrscheinlicher Fehler!"); } //### entspricht kleinst moeglicher Zeitschrittlaenge! k_Min = k_Min0; //### if((k_Min*86400) <= 1) { Message_Dlg("FEHLER!! k_Min ist kleiner als eine Sekunde!!"); WriteLog("FEHLER!! k_Min war kleiner als eine Sekunde!!"); errC = 1; return (false); } //Setzen des Zeitschrittoperators m_pTStep : entspricht der Zeitschrittlaenge dt //WENN GESETZT - Automatisierte max. Zeitschrittlaengen-Festlegung: if( Parameters("CalcT")->asBool() ) m_pTStep = (int)(k_Min * 86400); //Problem: k_Min nicht zwanglaeufig ein vielfaches von 60, daher m_pTStep ggf. nicht glatt durch 86400 teilbar // WENN NICHT GESETZT : 1) Verwendung der m_pTStep Eingabe - falls nicht zu grosz: -> sonst m_pVTresh = k_Min else { if( m_pTStep >= k_Min * 86400) m_pTStep = (int)(k_Min * 86400); } // //###################################################### //###################################################### //Speicher, Arrays und Membervariablen initiieren // CreateKArray( NX, NY, 3); CreateNcArray( NX, NY, nMax+1); // Array mit nMax+1 Speicherwerten (n Speichereintraege + Eintrag ueber Summe der Speicher) //CreatePArray( NX, NY, 1); //zur Zeit: nicht gesetzt //----------------------------------------------------- //SpeicherArrays initieren // InitKArray(); InitNcArray(NX, NY, nMax+1); //Array mit nMax+1 Speicherwerten (n Speichereintraege + Eintrag ueber Summe der Speicher) //InitPArray(NX, NY, 1); //zur Zeit: nicht gesetzt /**///%%%% Monitoring %%%%%%%%%% /**///Initiierung /**/WSystem = 0; // Im System befindliches Wasser /**/WSystemInit = 0; // Anfaenglicher Speicherinhalt WSystem nach Speicherinitilisierung /**/WSystemIn = 0; // Summe des Wassers was ins System gelangt (Drainage, RunOff) /**/WSystemOut = 0; // Summe des Wassers welches das System verlaeszt (Systemabfluss) /**/WSystemDayIn = 0; // Summe des Wassers was am jeweiligen Tag ins System gelangt (Drainage, RunOff) /**/WSystemDayOut = 0; // Summe des Wassers welches am jeweiligenTag das System verlaeszt (Systemabfluss) /**/WSystemDayWithd = 0; // Summe allen Wassers, dass dem WSystem pro Tag entnommen wird oder ueber Entnahmefaktor verloren geht /**/RivBas = 0; // Im RivBasin befindliches Wasser /**/RivBasInit = 0; // Anfaenglicher Speicherinhalt RivBasin nach Speicherinitilisierung /**/RivBasIn = 0; // Summe des Wassers was ins RiverBasin gelangt (Drainage, RunOff) /**/RivOut = 0; // Summe des Wassers welches das RiverBasin ueber den Fluss verlaeszt (Flussabfluss) /**/RivBasDayIn = 0; // Summe des Wassers was am jeweiligen Tag ins RiverBasin gelangt (Drainage, RunOff) /**/RivDayOut = 0; // Summe des Wassers welches am je weiligenTag das RiverBasin ueber den Fluss verlaeszt (Flussabfluss) /**/RivMonthOut = 0; // Summe des Wassers welches im jeweiligen Monat das RiverBasin ueber den Fluss verlaeszt (Flussabfluss) /**/RivBasSink = 0; // Summe allen Wasser das ueber dem Rechenzeitraum im RivBas in Senken verschwindet (geloescht wird) /**/manWithd = 0; // Wasser das durch Rasterzellen Manipulation aus dem RivBasinSystem entfernt oder hinzugefuegt wurde /**/WCCache = 0; // Speicherabbild des Wassers in den Kaskaden Speichern /**/RivBasConMonth = 0; // Summe der auftretenden Flaechenentnahmen innerhalb des gesamten Flusseinzugsgebietes pro Monat /**/resRivBasConMonth = 0; // Summe der tatsaechlichen durchgefuehrten Flaechenentnahmen innerhalb des gesamten Flusseinzugsgebietes pro Monat /**/remRivBasConMonth = 0; // Summe der Entnahmen die dem RivBas nicht entnommen werden konnten (weil resFlow kleiner als m_pCon) pro Monat /**/RivBasDayWithd = 0; // Summe allen Wassers, dass dem RivBasin pro Tag entnommen wird oder ueber Entnahmefaktor verloren geht /**/SumRDMonth = 0; //Summe der Runoff und Drainage Werte des Einzugsgebietes eines Monats /**/SumRMonth = 0; //NUR Summe der Runoff-Werte des Einzugsgebietes eines Monats /**/SumDMonth = 0; //NUR Summe der Drainage-Werte des Einzugsgebietes eines Monats /**/m_pTestR1m = 0; //TestRoutine1 /**/m_pTestR1RDm = 0; //TestRoutine1 /**/m_pTestR1Cm = 0; //TestRoutine1 /**/m_pTestR1resCm = 0; //TestRoutine1 /**/m_pTestR1remCm = 0; //TestRoutine1 /**/SumRD_SubBasin = 0; //Summe der Runoff und Drainage Werte eines SubBasin [TestRoutine 1] /**/SumCon_SubBasin = 0; //Summe der beabsichtigten Entnahmen eines SubBasin [TestRoutine 1] /**/SumResCon_SubBasin = 0; //Summe der tatsaechlichen Entnahmen eines SubBasin [TestRoutine 1] /**/SumRemCon_SubBasin = 0; //Summe der nicht beruecksichtigten Entnahmen eines SubBasin [TestRoutine 1] /**///%%%%%%%%%%%%%% /**///MonitoringLogs initiieren (Legende) /**///Monitoringlog 1 - RivBasine /**/if(var2) /**/{ /**/ file0.str(""); /**/ file0 << "Tag RivBasDayIn RivDayOut RivBasIn RivOut RivBas DiffInOut RivBasSink RivBasDayWithd "; /**/ file = file0.str(); /**/ TestLog1( file ); /**/} /**///Monitoringlog 2 - WSystem /**/if(var3) /**/{ /**/ file0.str(""); /**/ file0 << "Tag WSystemDayIn WSystemDayOut WSystemIn WSystemOut WSystem DiffInOut WCCache WSystemDayWithd"; /**/ file = file0.str(); /**/ TestLog2( file ); /**/} /**///Monitoringlog 3 - RivBasWUse /**/if(var4) /**/{ /**/ file0.str(""); /**/ file0 << "Jahr Monat RivBasRDMonth RivMonthOut RivBasWUseMonth RivBasResWUseMonth RivBasRemWUseMonth RivBasRMonth RivBasDMonth"; /**/ file = file0.str(); /**/ TestLog3( file ); /**/} /**/ /**/if(Parameters("Test1")->asInt() > 0 && m_pRivGrids->asDouble(Parameters("xt1")->asInt(),Parameters("yt1")->asInt()) != 0 ) /**/{ /**/ file0.str(""); /**/ file0 << "Jahr Monat SubRivBasRDMonth SubRivBasOutMonth SubRivBasWUseMonth SubRivBasResWUseMonth SubRivBasRemWUseMonth"; /**/ file = file0.str(); /**/ TestLog4( file ); /**/} /**///%%%%%%%%%%%%%%%%%%%%%%%%%% //----------------------------------------------------- //Temporaere Speicher anlegen m_pTempR = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); m_pTempC = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); m_pTempD = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); m_pTempK = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); // Temporaerer Speicher um je Zeitschritt dt_n den Channelzufluss je Gitterbox zu speichern und zu Anfang von dt_n+1 in den Kaskadenpeicher nCArray[x][y][0] zu schreiben m_pTemp = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); // Temporaerer Zwischenspeicher m_pSumCon = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); m_pSumRemCon = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); m_pSumResCon = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); //TestRoutine1 if(Parameters("Test1")->asInt() == 2) m_pTestR1Share = SG_Create_Grid(m_pDTM, SG_DATATYPE_Double); //gesammtes Einzugsgebiet zu HG-Rasterzelle (x,y) der TestR1 Routine //----------------------------------------------------- m_pChannelFlow->Assign(0.0); //erste Initiierung des ChannelFlow Grids m_pSumRunoffDrainage->Assign(0.0); //erste Initiierung des m_pSumRunoffDrainage Grids m_pWConsOut->Assign(0.0); //erste Initiierung des dynamischen m_pWConsOut Grids m_pTempK->Assign(0.0); //erste Initiierung m_pSumCon->Assign(0.0); //erste Initiierung m_pSumRemCon->Assign(0.0); //erste Initiierung m_pSumResCon->Assign(0.0); //erste Initiierung //TestRoutine1 if(Parameters("Test1")->asInt() == 2) { m_pTestR1Share->Assign(-1.0); //erste Initiierung TestR1Share( Parameters("xt1")->asInt(), Parameters("yt1")->asInt() ); //EinzugsgebietsRasterzellen BIS Errreichen der HG-Rasterzelle aus TestRoutine1 bestimmen } //------------ m_pHFlowFac = 1.0; //Initiierung: Weiterleitungsfaktor des Wasserflusses aus einer Gitzterbox m_pRFlowFac = 1.0; //Initiierung: Weiterleitungsfaktor des Wasserflusses aus einer Fluss-Gitterbox m_pVRFlowFac = 1.0; //Initiierung: Zuflussfaktor des vertikalen Zuflusses RunOff m_pVDFlowFac = 1.0; //Initiierung: Zuflussfaktor der vertikalen Zuflsses Drainage m_pTestR1 = 0; //Initiierung: SpeicherVariable TestRoutine 1 //----------------------------------------------------- //Ggf. Input-Grid-Speicherwerte einlesen // if( Parameters("CacheUse")->asBool() && m_pRCacheIn && m_pDCacheIn && m_pCCacheIn && !m_pNCacheFolder.is_Empty()) { //----------------------------------------------------- //Initialisierung der temporaeren Speicher mit voherigen Soeicherwerten m_pTempR->Assign(m_pRCacheIn); //Initiierung des temporaeren RunOff-Speichers mit vorhandenen Werten m_pTempD->Assign(m_pDCacheIn); //Initiierung des temporaeren Drainage-Speichers mit vorhandenen Werten m_pCCacheOut->Assign(m_pCCacheIn); //Initiierung des ChannelFlow-Grids mit vorhandenen Werten //RivBas / WSystem Monitoring: Inhalt des RivBas und Wsystem aus Speichern einlesen /**///%%%% Monitoring %%%%%%%%%% /**/ /**/for(int x=0; x < NX; x++) /**/{ /**/ for(int y=0; y < NY; y++) /**/ { /**/ WSystem = WSystem + m_pTempR->asDouble(x,x) + m_pTempD->asDouble(x,y) + m_pCCacheOut->asDouble(x,y); /**/ /**/ if(m_pBasinShare->asDouble(x,y) >= 0 ) //wenn im RivBasin... /**/ RivBas = RivBas + m_pTempR->asDouble(x,x) + m_pTempD->asDouble(x,y) + m_pCCacheOut->asDouble(x,y); /**/ } /**/} /**/RivBasInit = RivBas; /**/WSystemInit = WSystem; //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ReadNCacheFile(false, "NcCacheIn.txt", NX, NY, 0, 0, nMax, ' ', 0, false); //nC-Speicherdatei in Array einlesen //----------------------------------------------------- } else { m_pTempR->Assign(0.0); m_pTempD->Assign(0.0); m_pCCacheOut->Assign(0.0); //erste Initiierung des ChannelCache Grids } //----------------------------------------------------- //Zeit Membervariablen initiieren [Funktioniert bisher nur fuer 1968-2009] // //Simulationsuhr auf 1. Januar Startjahr 00:00:00 gesetzt // CTime timeS(m_sYear0, 1, 1, 0, 0, 0); CSG_DateTime timeS(1, CSG_DateTime::Jan, m_sYear0, 0, 0, 0); dT = 0; //daytimeCounter - Tageszeitzaehler [s] (0-86400) dDC = 1; //dayDataCounter - Datentag-Zaehler [d] (1-365/366) dC = 1; //dayCounter - Tageszaehler [d] mYC = 1; //MonthOfYear Monatszaehler [m] (1-12) dMC = 1; //DayOfMonth Tageszaehler [d] (1-28/29/30/31) //UhrzeitTest-Platzhalter double Td = 0; double Tm = 0; double Ty = 0; double Th = 0; double Tmi = 0; //----------------------- //Schaltjahr-Bestimmung - statisch fuer Zeitraum 1980 - 2009 m_pDDays = CSG_DateTime::Get_NumberOfDays(m_sYear); // if(m_sYear == 1968 || m_sYear == 1972 || m_sYear == 1976 || m_sYear == 1980 || m_sYear == 1984 || m_sYear == 1988 || m_sYear == 1992 || m_sYear == 1996 || m_sYear == 2000 || m_sYear == 2004 || m_sYear == 2008 ) // m_pDDays = 366; // else // m_pDDays = 365; numTS = int(86400/m_pTStep); //Anzahl der Zeitschtritte pro Tag //----------------------------------------------------- //Auslesepunkte - Tagesspeicher //STATISCH double dV1 = 0; double dV2 = 0; double dV3 = 0; // //###################################################### //###################################################### //Ggf. Prozentuale Wasserentnahme initiieren //----------------------------------------------------- //Falls der Inputparameter Wasserentnahmefaktor != Null, berechnen des effektiven Wasserdurchflussfaktors m_pFlowFac // if(var1 && m_pConsFacAll != 0) { /*double pow1 = 1.0 - m_pConsFacAll; double pow2 = 1.0 / numTS; if(m_pConsFac!=0 && m_pConsFac <= 1) m_pFlowFac = pow( pow1, pow2); //ZinsesZins-Rechnung */ m_pHFlowFac = 1.0 - m_pConsFacAll; } if(var1 && m_pConsFacRiv != 0) m_pRFlowFac = 1.0 - m_pConsFacRiv; if(var1 && m_pRedFacR != 0) m_pVRFlowFac = 1.0 - m_pRedFacR; if(var1 && m_pRedFacD != 0) m_pVDFlowFac = 1.0 - m_pRedFacD; // //###################################################### //###################################################### // Hauptfunktionsschleife //###################################################### // //LS-Data Grids initiieren und einlesen fuer Tag 1 //----------------------------------------------------- CSG_String m_pLSData26File; CSG_String m_pLSData27File; m_pLSData26File.Printf(SG_T("%s/%d/srunoff_%d_%d.sgrd"), m_pLSDataFolder.w_str(), m_sYear, m_sYear, dDC); m_pLSData27File.Printf(SG_T("%s/%d/drainage_%d_%d.sgrd"), m_pLSDataFolder.w_str(), m_sYear, m_sYear, dDC); CSG_Grid pRunOff(m_pLSData26File); CSG_Grid pDrainage(m_pLSData27File); //----------------------------------------------------- //Dynamische WCons-Data Grids initiieren und einlesen fuer Tag 1 //----------------------------------------------------- if(Parameters("WCons")->asInt() > 0) { m_pWConsFile.Printf(SG_T("%s/TotalWUse_%d_%d.sgrd"), m_pWConDataFolder.w_str(), m_sYear, mYC); pWConsData.Create(m_pWConsFile); //Entnahmen berechnen fuer Monat 1 if( !WConsRiv( Parameters("WCons")->asInt() )) Message_Dlg("Fehler beim Berechnen der dynamischen Entnahmen!"); } //----------------------------------------------------- //###################################################### // while(dC <= m_pDays ) // ...so lange Tageszahl kleiner gleich der festgelegten Simulationstage. { m_pTempC->Assign(0.0); //temporaerer Speicher zum Berechnen von m_pCCacheOut (Gueltigkeit fuer einen Zeitschritt) m_pTemp->Assign(0.0); //temporaerer Speicher zum Speichern des Zuflusses pro Gitterbox (Gueltigkeit fuer einen Zeitschritt) //###################################################### for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if(Parameters("onlyRB")->asBool() && m_pBasinShare->asDouble(x,y) < 0) //Falls nur im RiverBasin gerechnet werden soll und Koordinaten (x,y) nicht in diesem liegt -> Koordinaten ueberspringen... {} else { if(m_pDTM->is_NoData(x,y)) { m_pCCacheOut->Set_NoData(x,y); } else { /**///TEST---- /**/double test1 = pRunOff.asDouble(x,y); /**///-------- //Tageswerte fuer RunOff und Drainage aus Array einlesen und auf Flaeche und Zeitschritt umrechnen //Entsprechende Reduktionen und Offsets beruecksichtigen bzw. ausgleichen. //----------------------------------------------------- m_pRun = ( ( pRunOff.asDouble(x,y) * m_pVRFlowFac * pow(m_pDTM->Get_Cellsize(), 2) ) + m_pOffsetR ) * m_pTStep; // Vertikaler Runoff pro Zellenflaeche (x,y): [m^3] pro Zeitschrittlaenge (Input = m/s) multipliziert mit dem Zuflussfaktor m_pVFlowFac (Moeglichkeit der prozentuelle Reduzierung des Runoff-Zuflusses) + OFFSET //Reduzierungsbetrag RunOff double redSumRunOff = pRunOff.asDouble(x,y) * m_pRedFacR; if(Parameters("autoFacD")->asBool()) m_pDrain = ( ( pDrainage.asDouble(x,y) + redSumRunOff ) * pow(m_pDTM->Get_Cellsize(), 2) ) * m_pTStep; // Vertikale Drainage pro Zellenflaeche (x,y): [m^3] pro Zeitschrittlaenge (Input = m/s) + Reduzierungsbetrag des RunOffs else m_pDrain = ( ( pDrainage.asDouble(x,y) * m_pVDFlowFac * pow(m_pDTM->Get_Cellsize(), 2) ) + m_pOffsetD ) * m_pTStep; // Vertikale Drainage pro Zellenflaeche (x,y): [m^3] pro Zeitschrittlaenge (Input = m/s) multipliziert mit dem Zuflussfaktor m_pVFlowFac (Moeglichkeit der prozentuelle Reduzierung des Drainage-Zuflusses) + OFFSET //----------------------------------------------------- //HAUPTFUNKTION-> //###################### Calc_MainFlow(x,y); //###################### //HAUPTFUNKTION-> /**///%%%% Monitoring %%%%%%%%%% /**///WCCache Werte Schreiben /**/WCCache = WCCache + nCArray[x][y][nMax]; //%%%%%%%%%%%%%%%%%%%%%%%%%% } } } } m_pCCacheOut->Assign(m_pTempC); //uebernahme des Flussinhaltes (Gerinne- und Hauptgerinnnerasterzellen) nach einem Zeitschritt dt m_pTempK->Assign(m_pTemp); //Speichern des Gitterboxzuflusses (== Zufluss in Speicherkaskade N) dieses Zeitschritts zur Verwendung im nae Zeitschritt DataObject_Update(m_pCCacheOut); DataObject_Update(m_pChannelFlow); Process_Set_Text(CSG_String::Format(SG_T("dt = %d Dt = %g Vmax = %g || Tag: %d"), m_pTStep, dT+m_pTStep, vMax, dC)); //###################################################### //----------------------------------------------------- //Zeitoperation -> naechster Zeitschritt // dT = dT + m_pTStep; //Tageszeitzaehler // timeS.operator+=(m_pTStep); //SimulationsUhr timeS += CSG_TimeSpan(0, 0, m_pTStep); //SimulationsUhr //----------------------------------------------------- //Test--------------------- Td = timeS.Get_Day(); if(Th != timeS.Get_Hour()) Th = timeS.Get_Hour(); if(Tmi != timeS.Get_Minute()) Tmi = timeS.Get_Minute(); if(Tm != timeS.Get_Month()) Tm = timeS.Get_Month(); if(Ty != timeS.Get_Year()) Ty = timeS.Get_Year(); if(timeS.Get_Day() != dMC) //------------------------- //----------------------------------------------------- //TAGESWECHSEL ////if(dT > 86400) { /**///%%%% Monitoring %%%%%%%%%% /**///WSystem Werte Schreiben /**/if(var3) /**/{ /**/ file0; /**/ file0.str(""); /**/ file0 << dC << " " << WSystemDayIn << " " << WSystemDayOut << " " << WSystemIn << " " << WSystemOut << " " << WSystem << " " << (WSystemIn-WSystemOut) << " " << WCCache << " " << WSystemDayWithd; /**/ file = file0.str(); /**/ TestLog2( file ); /**/} /**/ /**///RivBasin Werte schreiben /**/if(var2) /**/{ /**/ file0.str(""); /**/ file0 << dC << " " << RivBasDayIn << " " << RivDayOut << " " << RivBasIn << " " << RivOut << " " << RivBas << " " << (RivBasIn - RivOut) << " " << RivBasSink << " " << RivBasDayWithd; /**/ file = file0.str(); /**/ /**/ TestLog1( file ); /**/} /**/ /**/WSystemDayOut = 0; //Auf Null setzen um naechsten Tageswert erfaassen zu koennen /**/WSystemDayIn = 0; //Auf Null setzen um naechsten Tageswert erfaassen zu koennen /**/WSystemDayWithd = 0;//Auf Null setzen um naechsten Tageswert erfaassen zu koennen /**/RivBasDayIn = 0; //Auf Null setzen um naechsten Tageswert erfaassen zu koennen /**/RivDayOut = 0; //Auf Null setzen um naechsten Tageswert erfaassen zu koennen /**/RivBasDayWithd = 0; //Auf Null setzen um naechsten Tageswert erfaassen zu koennen //%%%%%%%%%%%%%%%%%%%%%%%%%% //----------------------------------------------------- //AUSLESEN // //Fixe Messstationen (Auslesekoordinaten) - Tagesmittel in [m3/s] berechnen, Werte speichern //Schreiben in Textdatei // /*ELBE1 dV1 = m_pChannelFlow->asDouble(155,698) / 86400; // [m3/s]*/ /*ELBE2 dV1 = m_pChannelFlow->asDouble(145,578) / 86400; // [m3/s]*/ /*ELBE2_5 dV1 = m_pChannelFlow->asDouble(30,115) / 86400; // [m3/s]*/ dV1 = m_pChannelFlow->asDouble(Parameters("EvP1x")->asInt(),Parameters("EvP1y")->asInt()) / 86400; WriteOutput(m_pEvP1s.b_str(), dDC, dV1, -1, -1); dV1 =0; /*Nile dV1 = m_pChannelFlow->asDouble(222,563) / 86400; // [m3/s] WriteOutput("Dongola.txt",dDC, dV1, -1, -1); dV1 =0;*/ /*ELBE1 dV2 = m_pChannelFlow->asDouble(278,547) / 86400; // [m3/s]*/ /*ELBE2 dV2 = m_pChannelFlow->asDouble(269,428) / 86400; // [m3/s]*/ /*ELBE2_5 dV2 = m_pChannelFlow->asDouble(54,85) / 86400; // [m3/s]*/ dV2 = m_pChannelFlow->asDouble(Parameters("EvP2x")->asInt(),Parameters("EvP2y")->asInt()) / 86400; WriteOutput(m_pEvP2s.b_str(), dDC, dV2, -1, -1); dV2 =0; /*Nile dV2 = m_pChannelFlow->asDouble(280,487) / 86400; // [m3/s] WriteOutput("Khartoum.txt",dDC, dV2, -1, -1); dV2 =0;*/ /*ELBE1 dV3 = m_pChannelFlow->asDouble(399,434) / 86400; // [m3/s]*/ /*ELBE2 dV3 = m_pChannelFlow->asDouble(388,327) / 86400; // [m3/s]*/ /*ELBE2_5 dV3 = m_pChannelFlow->asDouble(78,65) / 86400; // [m3/s]*/ dV3 = m_pChannelFlow->asDouble(Parameters("EvP3x")->asInt(),Parameters("EvP3y")->asInt()) / 86400; WriteOutput(m_pEvP3s.b_str(), dDC, dV3, -1, -1); dV3 =0; /*Nile dV3 = m_pChannelFlow->asDouble(272,342) / 86400; // [m3/s] WriteOutput("Malakal.txt",dDC, dV3, -1, -1); dV3 =0;*/ //----------------------------------------------------- //----------------------------------------------------- //Datei der FlussWasserBilanz pro Kilometer des letzten Simulationstages schreiben if(m_pRivBalanceGrid) { WriteRivBalance(m_sYear, dC, -1, -1); int rx, ry; for(int l=0; l < m_pDTM->Get_NCells() && Set_Progress_NCells(l); l++) //ueber alle Zellen des m_pDEM-Grids { m_pDTM->Get_Sorted(l, rx, ry); //sortieren der Zellen von hoechster (l=0) nach niedrigster... if( m_pRivBalanceGrid->asDouble(rx,ry) != 0) { WriteRivBalance(rx, ry, m_pRivBalanceGrid->asDouble(rx,ry), m_pChannelFlow->asDouble(rx,ry) / 86400 ); } } } //----------------------------------------------------- dMC++; dDC++; dC++; dT = 0; WCCache = 0; //WCCACHE immer NCache-SpeicherAbbild am Ende jedes Simulationstages - daher nach jedem Tageswechsel wieder auf Null setzten if(m_pWConsD > 0) //Tageszaehler "Vorlauf vor Wasserentnahme" minus einen Tag m_pWConsD--; //----------------------------------------------------- //MONATSWECHSEL // if(timeS.Get_Month() != mYC) { /**///%%%% Monitoring %%%%%%%%%% /**///monthRivBasCon Werte schreiben /**/if(var4) /**/{ /**/ file0.str(""); /**/ file0 << m_sYear << " " << mYC << " " << SumRDMonth << " " << RivMonthOut << " " << RivBasConMonth << " " << resRivBasConMonth << " " << remRivBasConMonth << " " << SumRMonth << " " << SumDMonth; /**/ file = file0.str(); /**/ /**/ TestLog3( file ); /**/} /**/ /**/RivBasConMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/RivMonthOut = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/resRivBasConMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/remRivBasConMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/SumRDMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/SumRMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen /**/SumDMonth = 0; //Auf Null setzen um naechsten Monatswert erfaassen zu koennen //%%%%%%%%%%%%%%%%%%%%%%%%%% if(Parameters("Test1")->asInt() > 0 && m_pRivGrids->asDouble(Parameters("xt1")->asInt(),Parameters("yt1")->asInt()) != 0 ) { /**/SubBasinId(Parameters("xt1")->asInt(), Parameters("yt1")->asInt()); /**/ /**/ file0.str(""); /**/ file0 << m_sYear << " " << mYC << " " << m_pTestR1RDm << " " << m_pTestR1m << " " << m_pTestR1Cm << " " << m_pTestR1resCm << " " << m_pTestR1remCm; /**/ file = file0.str(); /**/ TestLog4( file ); /**/ /**/ m_pTestR1m = 0; /**/ m_pTestR1RDm = 0; /**/ m_pTestR1Cm = 0; /**/ m_pTestR1resCm = 0; /**/ m_pTestR1remCm = 0; } if(mYC >= 12) mYC = 1; else mYC++; dMC = 1; //auf ersten Tag des Monats setzen //Dynamische WCons-Data Grids fuer neuen Monat berechnen //----------------------------------------------------- if(Parameters("WCons")->asInt() > 0) { int Year; if(m_sYear <= 2000) //Sicherheitsabfrage fuer WaterGapDaten, die nur bis 2000 vorliegen - falls Jahr groeszer als 2000, werden weiterhin 2000er Daten verwendet Year = m_sYear; else Year = 2000; m_pWConsFile.Printf(SG_T("%s/TotalWUse_%d_%d.sgrd"), m_pWConDataFolder.w_str(), Year, mYC); pWConsData.Create(m_pWConsFile); if( !WConsRiv( Parameters("WCons")->asInt() )) Message_Dlg("Fehler beim Berechnen der dynamischen Entnahmen!"); } //----------------------------------------------------- } //----------------------------------------------------- //----------------------------------------------------- //JAHRESWECHSEL // if(timeS.Get_Year() > m_sYear) //if(dDC > m_pDDays) { dDC = 1; m_sYear = m_sYear + 1; mYC = 1; m_pDDays = timeS.Get_NumberOfDays(m_sYear); // if(m_sYear == 1980 || m_sYear == 1984 || m_sYear == 1988 || m_sYear == 1992 || m_sYear == 1996 || m_sYear == 2000 || m_sYear == 2004 || m_sYear == 2008 ) // m_pDDays = 366; // else // m_pDDays = 365; } if(m_sYear > 2009 || dDC > 366) //STATISCHE SICHERHEITSANGABEN break; if(dC <= m_pDays) { //Aktuelle LS-Data Grids einlesen //----------------------------------------------------- m_pLSData26File.Printf(SG_T("%s/%d/srunoff_%d_%d.sgrd"), m_pLSDataFolder.w_str(), m_sYear, m_sYear, dDC); m_pLSData27File.Printf(SG_T("%s/%d/drainage_%d_%d.sgrd"), m_pLSDataFolder.w_str(), m_sYear, m_sYear, dDC); pRunOff.Create(m_pLSData26File); pDrainage.Create(m_pLSData27File); //----------------------------------------------------- m_pChannelFlow->Assign(0.0); m_pTest = 0; } //----------------------------------------------------- } //----------------------------------------------------- } // //###################################################### // //###################################################### //----------------------------------------------------- // Testroutine 1 durchfuehren if(Parameters("Test1")->asInt() > 0 && m_pRivGrids->asDouble(Parameters("xt1")->asInt(),Parameters("yt1")->asInt()) != 0 ) { SubBasinId(Parameters("xt1")->asInt(), Parameters("yt1")->asInt()); } //----------------------------------------------------- //----------------------------------------------------- // Speichern in den Ausgabedateien m_pRCacheOut->Assign(m_pTempR); //uebernahme des Gitterboxflusses nach m_pDays Simulationstagen m_pDCacheOut->Assign(m_pTempD); //uebernahme des Gitterboxflusses nach m_pDays Simulationstagen if(Parameters("wNC")->asBool()) SaveNcCache(nMax); if(Parameters("wP")->asBool()) SaveParameters(); //Speichern der AusgabeGrids in Unterordner "grids" CSG_String SaveAsFile; CSG_String SPath = m_pSPath2.c_str(); SaveAsFile.Printf(SG_T("%s/CFCache.sgrd"), SPath.w_str()); m_pCCacheOut->Save(SaveAsFile); //GridSave CCCache SaveAsFile.Printf(SG_T("%s/OFCache.sgrd"), SPath.w_str()); m_pRCacheOut->Save(SaveAsFile); //GridSave RCache SaveAsFile.Printf(SG_T("%s/BFCache.sgrd"), SPath.w_str()); m_pDCacheOut->Save(SaveAsFile); //GridSave DCache SaveAsFile.Printf(SG_T("%s/SumRunoffDrainage.sgrd"), SPath.w_str()); m_pSumRunoffDrainage->Save(SaveAsFile); //GridSave SumRunoffDrainage SaveAsFile.Printf(SG_T("%s/ChannelFlow.sgrd"), SPath.w_str()); m_pChannelFlow->Save(SaveAsFile); //GridSave ChannelFlow //----------------------------------------------------- if(Parameters("Test1")->asInt() == 2) { SaveAsFile.Printf(SG_T("%s/m_pTestR1Share.sgrd"), SPath.w_str()); m_pTestR1Share->Save(SaveAsFile); //GridSave ChannelFlow delete(m_pTestR1Share); } //----------------------------------------------------- // Loeschen der temporaeren Speicher // delete(m_pTempR); delete(m_pTempC); delete(m_pTempD); delete(m_pTempK); delete(m_pTemp); delete(m_pSumCon); delete(m_pSumRemCon); delete(m_pSumResCon); CLandFlow::DeleteKArray(); //CLandFlow::DeleteLSMArray(); //ersetzt durch direktes Laden der LSSchmea-Grids CLandFlow::DeleteNcArray(); //CLandFlow::DeletePArray(); // zur Zeit : nicht verwendet //----------------------------------------------------- return( true ); } //######################################################### //--------------------------------------------------------- //######################################################### /////////////////////////////////////////////////////////// // // // Funktionen // // // /////////////////////////////////////////////////////////// //###################################################### // void CLandFlow::Calc_MainFlow(int x, int y) { int i = -1; int ix, iy; double c, r, d; stCons = 0; varCons = 0; r = m_pTempR->asDouble(x,y) + m_pRun; // Einlesen des Inhalts des Runoff-Speichers + Runoff m_pRun des Zeitschritts d = m_pTempD->asDouble(x,y) + m_pDrain; // Einlesen des Inhalts des Drainage-Speichers + Drainage m_pDrain des Zeitschritts c = m_pTempK->asDouble(x,y); // Einlesens des Inhalts des Gitterboxzuflusses des letzten Zeitschritts /**///%%%% Monitoring %%%%%%%%%% /**/WSystemIn = WSystemIn + m_pRun + m_pDrain; /**/WSystem = WSystem + m_pRun + m_pDrain; /**/ /**/WSystemDayIn = WSystemDayIn + m_pRun + m_pDrain; /**/ /**/m_pSumRunoffDrainage->Add_Value(x, y, (m_pRun + m_pDrain)); //Grid ueber die Summe aller abflussrelevanten, vertikalen Zufluesse je Gitterzelle (x,y) des gesamten Berechnugszeitraums /**/ /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Abfrage ob (x,y) Koordinate im RiverBasin liegt /**/{ /**/ RivBasIn = RivBasIn + m_pRun + m_pDrain; /**/ RivBas = RivBas + m_pRun + m_pDrain; /**/ /**/ RivBasDayIn = RivBasDayIn + m_pRun + m_pDrain; //Summe der RunOff und DrainagWerte innerhalb des Flusseinzugsgebietes ueber einen Monat /**/ SumRDMonth = SumRDMonth + m_pRun + m_pDrain; /**/ SumRMonth = SumRMonth + m_pRun; /**/ SumDMonth = SumDMonth + m_pDrain; /**/} /**///%%%%%%%%%%%%%%%%%%%%%%%%%% /**///%%%%%%%%%%%%%%%%%%%%%%%%%% //--------------------------------------------------------- //Berechnung der Abfluesse m_pGFlow = Calc_GFlow(x, y, r); // Berechnung Oberflaechenabflusses m_pBFlow = Calc_BFlow(x,y,d); // Berechnung Grundwasserabfluss if( Parameters("RivG")->asInt() > 0 && m_pRivGrids->asDouble(x,y) != 0) m_pCFlow = Calc_CFlow(x, y, c, nCr); // Berechnung Hauptgerinnerasterzellen-Abfluss-Speicherkaskade else m_pCFlow = Calc_CFlow(x, y, c, nC); // Berechnung Gerinneabfluss-Speicherkaskade //--------------------------------------------------------- /**///%%%%%%%%%%%%%%%%%%%%%%%%%% /**///TempSpeicherwert /**/double tempN = m_pCFlow; /**/ /**///TempSpeicherwerte //%%%%%%%%%%%%%%%%%%%%%%%%%% Punktuelle Abflussmanipulation - Anfang %%%%%%%%%%%%%%%%%%%%%%%%%% //Rasterzelle 1 if( x == Parameters("RM1x")->asInt() && y == Parameters("RM1y")->asInt() && Parameters("vRM1")->asInt() != 0) if(Parameters("vRM1")->asInt() == 1) m_pCFlow = ( m_pCFlow * Parameters("RM1q")->asDouble() ) + (Parameters("RM1a")->asDouble() * m_pTStep); //Abfluss des HD-Modells veraendern else m_pCFlow = ( m_pCCacheOut->asDouble(x,y) * Parameters("RM1q")->asDouble() ) + (Parameters("RM1a")->asDouble() * m_pTStep); //Abfluss aus Speicher manuell vorgeben //Rasterzelle 2 if( x == Parameters("RM2x")->asInt() && y == Parameters("RM2y")->asInt() && Parameters("vRM2")->asInt() != 0) if(Parameters("vRM2")->asInt() == 1) m_pCFlow = ( m_pCFlow * Parameters("RM2q")->asDouble() ) + (Parameters("RM2a")->asDouble() * m_pTStep); //Abfluss des HD-Modells veraendern else m_pCFlow = ( m_pCCacheOut->asDouble(x,y) * Parameters("RM2q")->asDouble() ) + (Parameters("RM2a")->asDouble() * m_pTStep); //Abfluss aus Speicher manuell vorgeben if(m_pCFlow < 0) { Message_Dlg("Negativer Abfluss errechnet -> Punktuelle Rasterzellenmanipulation in diesem Schritt auszer Kraft gesetzt"); m_pCFlow = tempN; } else //Monitoring der Manipulierten Wasserflussvolumen (pos. Wert == Wasser hinzugefuegt) manWithd = manWithd + m_pCFlow - tempN; //%%%%%%%%%%%%%%%%%%%%%%%%%% Punktuelle Abflussmanipulation - Ende %%%%%%%%%%%%%%%%%%%%%%%%%% //--------------------------------------------------------- //Abfluesse aus den Speichern der Rasterzelle (x,y) m_pTempR->Set_Value( x, y, (r - m_pGFlow) ); // Inhalt Runoff-Speicher der in Zelle (x,y) verbleibt m_pTempD->Set_Value( x, y, (d - m_pBFlow ) ); // Inhalt Drainage-Speicher der in Zelle (x,y) verbleibt m_pTempC->Add_Value( x, y, (m_pCCacheOut->asDouble(x,y) - m_pCFlow) ); //Add_ist_richtig!! Alter Inhalt des ChannelGitterbox-Speichers minus Abfluss dieses Zeitschritts, gleich: verbleibender Inhalt in der Zelle (x,y) - (Grid: m_pCCacheOut == Summe des Volumens aller n Kaskadenspeicher) (Achtung! aus anderen Zellen kann aber immer auch nocht etwas in m_pTempC zuflieszen) //--------------------------------------------------------- //%%%%%%%%%%%%%%%%%%%%%%%%%% EntnahmenCode - Anfang %%%%%%%%%%%%%%%%%%%%%%%%%% //...aus dem Gesamtabfluss (m_pGFlow + m_pBFlow + m_pCFlow) der rasterzelle (x,y) //--------------------------------------------------------- //Wasserentnahme - flaechenbasiert ueber das Flussgrid // //Wenn bei gesetzter Wasserentnahme kein WCons-Grid vorhanden -> Fehlermeldung if(Parameters("WCons")->asInt() > 0 && !pWConsData.is_Valid()) { WriteLog("Fehler! Kein WConsDaten als Input!"); errC = 1; } m_pCon = 0; //Entnahme statisch (WConsIn) und/oder dynamisch nach Auswahl 1 oder 2 (WConsData) if( m_pWConsIn && m_pWConsD == 0 ) m_pCon = (m_pWConsIn->asDouble(x,y) / 1000 ) * pow(m_pDTM->Get_Cellsize(), 2) * m_pTStep; //Statische Wasserentnahme Eingangsdaten in m3/s -> [0,001m^3 m^-2 s^-1 == 1 mm s^-1] * (Zellgroesze)^2 * Zeitschritt(s) if( Parameters("WCons")->asInt() != 0 && pWConsData.is_Valid() && m_pWConsOut->is_Valid() && m_pWConsD == 0 ) if(Parameters("WConUnit")->asInt() == 0) m_pCon = m_pCon + (m_pWConsOut->asDouble(x,y) / 1000 ) * pow(m_pDTM->Get_Cellsize(), 2) * m_pTStep; //Wasserentnahme Eingangsdaten in m3/s -> [0,001m^3 m^-2 s^-1 == 1 mm s^-1] * (Zellgroesze)^2 * Zeitschritt(s) else m_pCon = m_pCon + (m_pWConsOut->asDouble(x,y) / 1000 / 86400 / 30) * pow(m_pDTM->Get_Cellsize(), 2) * m_pTStep; //Wasserentnahme Eingangsdaten in m3/Monat, deshalb teilen durch (86400*monthDays) -> [0,001m^3 m^-2 s^-1 == 1 mm s^-1] * (Zellgroesze)^2 * Zeitschritt(s) //--------------------------------------------------------- /**///%%%% Monitoring %%%%%%%%%% /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/ RivBasConMonth = RivBasConMonth + m_pCon; /**/m_pSumCon->Add_Value(x, y, m_pCon); /**///%%%%%%%%%%%%%%%%%%%%%%%%%% //prozentualle Abflussreduktion vornehmen - abhaengig davon, ob Gitterbox oder Flussgitterbox. if( Parameters("RivG")->asInt() > 0 && m_pRivGrids->asDouble(x,y) != 0) m_pFlowFac = m_pRFlowFac; //Weiterleitungsfaktor-Fluss-Gitterbox setzten else m_pFlowFac = m_pHFlowFac; //Weiterleitungsfaktor-Gitterbox setzen //--------------------------------------------------------- i = m_pDTM->Get_Gradient_NeighborDir(x, y); // Falls kein niedrigerer Nachbar -> Wert=-1 //Falls Abfluesse stattfinden koennen, weil es eine niedrigere Nachbarzelle gibt bzw. ein Gradient groeszer Null vorliegt... if( i >= 0 || m_pGrad->asDouble(x,y) > 0) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); //--------------------------------------------------------- //Pruefen ob Zellenabfluss [(m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac] aus Gitterzelle (x,y) kleiner etwaiger Entnahme m_pCon //...wenn der Fall: dann Entnahmen auf Groesze des Zellabflusses setzen -> es resultiert Nullabfluss in diesem Zeitschritt double resFlow = (m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac; //Fall Schwellenwert... -> m_pCon Veraenderung if(m_pWConThres != 0 && Parameters("RivG")->asInt() > 0 && m_pRivGrids->asDouble(x,y) != 0) { if(resFlow >= ( m_pWConThres * m_pTStep)) { if( (resFlow - ( m_pWConThres * m_pTStep)) < m_pCon) //wenn resultierender Abfluss nach Abzug des Schwellewertes kleiner als m_pCon, dann Entnahme nur in Hoehe von resFlow - m_pWConThres { if(Parameters("eP")->asBool() && errC2 == 0) { WriteLog("Warnung! Es wurde in mindestens einem Fall bei Beruecksichtigung des Schwellenwertes und einer Entnaheme, ein negativer Abfluss ermittelt!!"); errC2 = -1; } /**///%%%% Monitoring %%%%%%%%%% /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/ remRivBasConMonth = remRivBasConMonth + (m_pCon - ( resFlow - ( m_pWConThres * m_pTStep)) ); //Summe der Entnahmen die dem RivBasin nicht entnommen werden konnten (weil resFlow kleiner als m_pCon) pro Monat /**/m_pSumRemCon->Add_Value(x, y, (m_pCon - ( resFlow - ( m_pWConThres * m_pTStep))) ); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% m_pCon = resFlow - ( m_pWConThres * m_pTStep); } //else: m_pCon bleibt unveraendert... } else //Falls Schwellenwert schon hoeher als berechneter Abfluss, keine Entnahme mehr... { if(Parameters("eP")->asBool() && errC3 == 0) { WriteLog("Warnung! In mindestens einem Fall war der resultierdene Abfluss kleiner als der eingestellte Schwellenwert!!"); errC3 = -1; } /**///%%%% Monitoring %%%%%%%%%% /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/ remRivBasConMonth = remRivBasConMonth + m_pCon; //Summe der Entnahmen die dem RivBasin nicht entnommen werden konnten (weil resFlow kleiner als m_pCon) pro Monat /**/m_pSumRemCon->Add_Value(x, y, m_pCon); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% m_pCon = 0; } } else // falls kein Schwellenwert und/oder keine Hauptgerinnerasterzelle if( resFlow < m_pCon) { if(Parameters("eP")->asBool() && errC4 == 0) { WriteLog("Warnung! Es wurde in mindestens einem Fall ein negativer Abfluss ermittelt!!"); errC4 = -1; } /**///%%%% Monitoring %%%%%%%%%% /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/ remRivBasConMonth = remRivBasConMonth + (m_pCon - resFlow); //Summe der Entnahmen die dem RivBasin nicht entnommen werden konnten (weil resFlow kleiner als m_pCon) pro Monat /**/m_pSumRemCon->Add_Value(x, y, (m_pCon - resFlow)); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% m_pCon = resFlow; } //--------------------------------------------------------- /**///%%%% Monitoring %%%%%%%%%% /**/WSystemDayWithd = WSystemDayWithd + (m_pGFlow + m_pBFlow + m_pCFlow)*(1-m_pFlowFac); //faktorielle Tageswasserverluste aus WSystem /**/WSystem = WSystem - (m_pGFlow + m_pBFlow + m_pCFlow)*(1-m_pFlowFac); //faktorielle Wasserverluste aus WSystem pro Zeitschritt /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/{ /**/ RivBasDayWithd = RivBasDayWithd + (m_pGFlow + m_pBFlow + m_pCFlow)*(1-m_pFlowFac); //faktorielle tageswasserverluste aus RivBasin /**/ RivBas = RivBas - (m_pGFlow + m_pBFlow + m_pCFlow)*(1-m_pFlowFac); //faktorielle Wasserverluste aus RivBasin pro Zeitschritt /**/} /**///%%%%%%%%%%%%%%%%%%%%%%%%%% /**///%%%% Monitoring %%%%%%%%%% /**/WSystemDayWithd = WSystemDayWithd + m_pCon; //flaechenbasierte Tagesentnhamen aus WSystem /**/WSystem = WSystem - m_pCon; //Entnommenes Wasser aus WSystem ueber die Flaeche pro Zeitschritt /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Nur Monitoren wenn (x,y) Koordinate im RiverBasin liegt /**/{ /**/ RivBasDayWithd = RivBasDayWithd + m_pCon; //flaecenbasierte Tagesentnahmen aus RivBasin /**/ RivBas = RivBas - m_pCon; //Entnommenes Wasser aus RivBasin ueber die Flaeche pro Zeitschritt /**/ resRivBasConMonth = resRivBasConMonth + m_pCon; /**/} /**/m_pSumResCon->Add_Value(x, y, m_pCon); /**///%%%%%%%%%%%%%%%%%%%%%%%%%% //FehlerAbfrage! if( (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon) < 0 ) Message_Dlg("Negativer Abfluss errechnet -> FEHLER"); //%%%%%%%%%%%%%%%%%%%%%%%%%% EntnahmenCode - Ende %%%%%%%%%%%%%%%%%%%%%%%%%% //--------------------------------------------------------- //resultierende Zufluesse in die Rasterzelle (ix,iy) entspricht (Abfluss der Rasterzelle (x,y) minus der Entnahmen bzw. faktoriellen Minderungen) if( m_pDTM->is_InGrid(ix,iy) && !m_pDTM->is_NoData(ix,iy)) //wenn (ix,iy) im Grid liegen und keine noData-Gitterzellen sind... -> Zufluss in die Zelle (ix,iy) { m_pChannelFlow->Add_Value(ix, iy, ( (m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); // GitterboxZUFLUSS in Gitterbox [ix,iy] minus Entnahme (WCon). Es gilt jeweils am Tagesende (da immer bei Tageswechsel Null gesetzt wird): [m3/d] m_pTempC->Add_Value( ix, iy, ( (m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); // GitterboxZUFLUSS: Zelle (x,y) 'uebergibt' Inhalt (OverlandFlow+BaseFlow+ChannelFlow - Entnahme(WCon) ) an niedrigste Umgebungszelle (ix,iy) m_pTemp->Add_Value (ix, iy , ( (m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); // Zwischenspeicher GitterboxZUFLUSS minus Entnahme(WCon) um diesen im nae Zeitschritt in den ersten Speicher der ChannelKaskade zu schreiben } else //wenn (ix,iy) nicht im Grid und/oder eine NoData-Gitterzelle ist... -> SYSTEMabfluss (dieser Wasserabfluss wird nicht mehr beruecksichtigt) { /**///%%%% Monitoring %%%%%%%%%% //Da Senke oder Rand -> Speicherrinhalt m_pTempC seit dem letzten Zeitschritts flieszt ab (bzw. wird geloescht). //Fuer das RiverBasin sollte diese bedingung hoechstens fuer die Ausgangsbox des Basin zutreffen (siehe naechsten MonitoringSchritt) /**/WSystemOut = WSystemOut + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/WSystem = WSystem - (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/ /**/WSystemDayOut = WSystemDayOut + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**///%%%%%%%%%%%%%%%%%%%%%%%%%% } //--------------------------------------------------------- /**///%%%% Monitoring %%%%%%%%%% RiverBasin-AUSGANG (Effektiver Abfluss aus Flusseinzugsgebiet) /**/if(x==Parameters("RBMx")->asInt() && y==Parameters("RBMy")->asInt()) //(x==16 && y==121)//Elbe2_5000m | (x==78 && y==607)//Elbe2_1000m | (x==166 && y==843)//Nile_5000m // STATISCH!! Abfrage ob Ausgangsbox aus RiverBasine vorliegt -> RivOut setzen == RiverBasine-Abfluss (Flussabfluss) /**/{ /**/RivOut = RivOut + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/RivBas = RivBas - (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/ /**/RivDayOut = RivDayOut + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/RivMonthOut = RivMonthOut + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); /**/} /**///------------------------------------------------------- /**/// TestRoutine 1 ---------------------------------------- if(Parameters("Test1")->asInt() > 0 && x == Parameters("xt1")->asInt() && y == Parameters("yt1")->asInt()) {//Effektiver Abfluss aus der Hauptgerinnerasterzelle der TestRoutine1 m_pTestR1 = m_pTestR1 + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); //Summe der errechneten Abfluesse aus Flussrasterzelle (x,y) ueber alle Zeitschritte m_pTestR1m = m_pTestR1m + (((m_pGFlow + m_pBFlow + m_pCFlow)*m_pFlowFac) - m_pCon); //Summe der errechneten Abfluesse aus Flussrasterzelle (x,y) pro Monat } /**///%%%%%%%%%%%%%%%%%%%%%%%%%% } else //Falls KEINE Abfluesse stattfinden koennen, Systemabfluss des Wassers des vorherigen Zeitschritts!! { double outflow1 = r - m_pRun; //Inhalt von m_pTempR->asDouble(x,y) des letzten Zeitschritts abflieszen lassen double outflow2 = d - m_pDrain; //Inhalt von m_pTempD->asDouble(x,y) des letzten Zeitschritts abflieszen lassen double outflow0 = 0; double remWith = 0; //Wassermenge die nicht entnommen werden kann, weil zuwenig Speicherabfluss nach drauszen if( (m_pCCacheOut->asDouble(x,y) + outflow1 + outflow2) >= m_pCon) outflow0 = (m_pCCacheOut->asDouble(x,y) + outflow1 + outflow2) - m_pCon; else remWith = m_pCon - m_pCCacheOut->asDouble(x,y) + outflow1 + outflow2; //bedeutet: outflow0 == 0 /**///%%%% Monitoring %%%%%%%%%% //Da Senke oder Rand -> Speicherrinhalte seit dem letzten Zeitschritts fliessen ab (bzw. wird geloescht). /**/WSystemOut = WSystemOut + outflow0; /**/WSystem = WSystem - outflow0; /**/ /**/WSystemDayOut = WSystemDayOut + outflow0; /**/WSystemDayWithd = WSystemDayWithd + m_pCon - remWith; /**/ /**/if(m_pBasinShare->asDouble(x,y) >= 0 ) //Abfrage ob (x,y) Koordinate im RiverBasin liegt /**/{ /**/ RivBas = RivBas - outflow0; /**/ RivBasSink = RivBasSink + outflow0; /**/ RivBasDayWithd = RivBasDayWithd + m_pCon - remWith; /**/ resRivBasConMonth = resRivBasConMonth + m_pCon - remWith; /**/ remRivBasConMonth = remRivBasConMonth + remWith; /**/// m_pSumRemCon->Add_Value(x,y,remWith); //aeNDERUNG: 081114 - Anscheinden doppelter Eintrag s. Zeilen drunter (verantwortlich fuer Fehler in der Bilanz?) /**/} /**/m_pSumRemCon->Add_Value(x, y, remWith); /**/m_pSumResCon->Add_Value(x, y, m_pCon - remWith); /**///%%%%%%%%%%%%%%%%%%%%%%%%%% m_pTempR->Set_Value(x, y, m_pRun); //Speicher nur auf verikalen Zufluss dieses Zeitschritts setzen m_pTempD->Set_Value(x, y, m_pDrain); //Speicher nur auf verikalen Zufluss dieses Zeitschritts setzten m_pCCacheOut->Set_Value( x, y, 0); // Wenn Senke vorliegt (haeufig am Rande des Grids der Fall), wird Inhalt des letzten Zeitschrittes dt_n-1 (m_pCCacheOut(x,y)) geloescht (forcierter Abfluss nach auszen). Zufluss in die Box waehrend des jeweiligen Zeitschrittes dt_n (aus anderen Zellen in m_pTempC(x,y)) wird aber reingeschrieben. } } // //###################################################### //###################################################### // double CLandFlow::Calc_GFlow(int x, int y, double f) //OverlandFlow ACHTUNG!! Funktioniert so nur mit nO = 1 !! { double g = 0.0; int i; if(kArray[x][y][0] > 0) { for(i=0; i < nG; i++) { //--Test double w = kArray[x][y][0]; double q = CalcRet(kArray[x][y][0], nG); //--Test g = f / CalcRet(kArray[x][y][0], nG); } } return( g ); } // //###################################################### //###################################################### // double CLandFlow::Calc_CFlow(int x, int y, double f, int n) //ChannelFlow/Gerinneabfluss { double g = 0.0; double h = 0.0; int i; /**///%%%% Monitoring %%%%%%%%%% /**/nCArray[x][y][nMax] = 0; /**///%%%%%%%%%%%%%%%%%%%%%%%%%% if(kArray[x][y][1] > 0 ) { g = f; // Gitterboxzufluss des letzten Zeitschritts in den ersten Kaskadenspeicher [0] for(i=0; i < n; i++) { h = (nCArray[x][y][i] + g); // Speicherinhalt + Zufluss //Entnahme wird bisher immer beim Gitterboxzufluss (hier Eingangswert f) des letzten Zeitschritts beruecksichtigt!! if(n == 1 && f > 0) //testStop { int ay = 1; } if(h< 0) //testStop { int ay = 1; } //--Test double w = kArray[x][y][1]; double q = CalcRet(kArray[x][y][1], n); //--Test if( h >= 0) g = h / CalcRet(kArray[x][y][1], n); //Abfluss aus Speicher else { g = 0; if(Parameters("eP")->asBool()) WriteLog("FEHLER errC! Negativer Abfluss ermittelt - Abfluss fuer diesen Zeitschritt auf Null gesetzt"); errC = 1; } if( (h-g) < 0) //testStop { int az = 1; } nCArray[x][y][i] = h - g; //verbleibender Speicherinhalt -> g == Zufluss des naechsten Speichers /**///%%%% Monitoring %%%%%%%%%% /**/nCArray[x][y][nMax] = nCArray[x][y][nMax] + nCArray[x][y][i]; /**///%%%%%%%%%%%%%%%%%%%%%%%%%% } } if(g < 0) //Falls kein positiver Abfluss aus letztem Speicher -> Abfluss gleich Null g = 0; return( g ); //Abfluss des letzten Speichers == Abfluss der Gitterbox in diesem Zeitschritt } // //###################################################### //###################################################### double CLandFlow::Calc_BFlow(int x, int y, double f) //BaseFlow/Grundwasserabfluss ACHTUNG!! Funktioniert so nur mit nB = 1 !! { double g = 0.0; if(kArray[x][y][2] > 0) { //--Test double w = kArray[x][y][2]; double q = CalcRet(kArray[x][y][2], 1); //--Test g = f / CalcRet(kArray[x][y][2], 1); } return( g ); } //###################################################### //###################################################### double CLandFlow::CalcRet(double q, int n) { return(q * 86400 / m_pTStep); // f[d] und m_pTSTep [s] - ACHTUNG n hier NICHT mehr miteinbezogen (17.02.14) [vormals: q * 86400 / m_pTStep*n ] } //###################################################### //SubBasinId //###################################################### bool CLandFlow::SubBasinId(int x, int y) //Funktion gibt aus dem m_pSumRunoffDrainage-Raster die Summe der RunOff und Drainage Werte aller Rasterzellen des Teileinzugsgebiets der Flussrasterzelle (x,y), //ODER aller Rasterzellen des Abflusspfades bis zum Erreichen der HG-Rasterzelle { //KoordinatenDouble erzeugen FORMAT: xxxxyyyy double r = 0; int u = 10000*x + y; r = u; //Koordinate der Flussrasterzelle des Teileinzugsgebietes - FORMAT: xxxxyyyy NumGridsTestR1 = 1; //entspricht zumindest einer HG-Raterzelle im Teileinzugsgebiet/Einzugsgebiet double SumRD = m_pSumRunoffDrainage->asDouble(x,y); //als erstes die Summe der RunOff und Drainage Werte der Muendungs-HG-Rasterzelle des Teileinzugsgebiets/Einzugsgebiets setzten double SumCon = m_pSumCon->asDouble(x,y); double SumResCon = m_pSumResCon->asDouble(x,y); double SumRemCon = m_pSumRemCon->asDouble(x,y); if(Parameters("Test1")->asInt() == 1) { if(m_pBasinShare) { for(int ix=0; ix < NX; ix++) { for(int iy=0; iy < NY; iy++) { if(!m_pDTM->is_NoData(ix,iy) && m_pBasinShare->asDouble(ix,iy) == r) { SumRD = SumRD + m_pSumRunoffDrainage->asDouble(ix,iy); SumCon = SumCon + m_pSumCon->asDouble(ix,iy); SumResCon = SumResCon + m_pSumResCon->asDouble(ix,iy); SumRemCon = SumRemCon + m_pSumRemCon->asDouble(ix,iy); NumGridsTestR1++; } } } } else return(false); } if(Parameters("Test1")->asInt() == 2) { if(m_pTestR1Share) { for(int ix=0; ix < NX; ix++) { for(int iy=0; iy < NY; iy++) { if(!m_pDTM->is_NoData(ix,iy) && m_pTestR1Share->asDouble(ix,iy) == r) { SumRD = SumRD + m_pSumRunoffDrainage->asDouble(ix,iy); SumCon = SumCon + m_pSumCon->asDouble(ix,iy); SumResCon = SumResCon + m_pSumResCon->asDouble(ix,iy); SumRemCon = SumRemCon + m_pSumRemCon->asDouble(ix,iy); NumGridsTestR1++; } } } } else return(false); } m_pTestR1RDm = SumRD - SumRD_SubBasin; m_pTestR1Cm = SumCon - SumCon_SubBasin; m_pTestR1resCm = SumResCon - SumResCon_SubBasin; m_pTestR1remCm = SumRemCon - SumRemCon_SubBasin; SumRD_SubBasin = SumRD; SumCon_SubBasin = SumCon; SumResCon_SubBasin = SumResCon; SumRemCon_SubBasin = SumRemCon; return(true); } //###################################################### //###################################################### //Gesamtes Einzugsgebiet der HG-Rasterzelle (HGx,HGy) von TestR1 bestimmen void CLandFlow::TestR1Share(int HGx, int HGy) { int x, y; //KoordinatenDouble der HG-Rasterzelle erzeugen FORMAT: xxxxyyyy double r = 0; int u = 10000*HGx + HGy; // r = u; //Wert der gesetzt wird : FORMAT: xxxxyyyy (Koordinate der "Ziel"HG-Rasterzelle in alle im Abflusspfad voherigen Rasterzellen muenden) if(m_pTestR1Share) { for(int l=0; l < m_pDTM->Get_NCells() && Set_Progress_NCells(l); l++) //ueber alle Zellen des m_pDEM-Grids { m_pDTM->Get_Sorted(l, x, y); //sortieren der Zellen von hoechster (l=0) nach niedrigster - 1.Durchlauf um zu gucken, ob Abflusspfad in (HGx, HGy) endet while( !m_pDTM->is_NoData(x,y) && ( x != HGx || y != HGy ) ) { int i = m_pDTM->Get_Gradient_NeighborDir(x, y); if(i >= 0) //es gibt eine niedrigere Nachbarzelle... { x = Get_xTo(i, x); y = Get_yTo(i, y); if(x == HGx && y == HGy) { m_pDTM->Get_Sorted(l, x, y); //2.Durchlauf um Abflusspfad mit den koordinaten der HG-Rasterzelle (HGx, HGy) zu markieren. while( !m_pDTM->is_NoData(x,y) && ( x != HGx || y != HGy ) ) { int j = m_pDTM->Get_Gradient_NeighborDir(x, y); if(j >= 0) //es gibt eine niedrigere Nachbarzelle... { m_pTestR1Share->Set_Value(x, y, r); //Koordinaten der Ziel-Flussgridbox werden gesetzt x = Get_xTo(j, x); y = Get_yTo(j, y); } else {break;} //Nur fuer den Fall; j = -1 sollte eigentlich nicht mehr moeglich sein, da letzte Gridbox ja HG-Rasterzelle... } } } else break; //Senke liegt vor } } } } //###################################################### // //###################################################### bool CLandFlow::WConsRiv(int i) //Berechnung der dynamschen Wasserentnahmewerte nach Funktionsauswahl 1 oder 2 (bisher auf Monatsbasis) { double SumCons = 0; double SumInFlow = 0; double valTest = 0; double BasinCon = 0; int m = 1; //Multiplikativer Faktor fuer die Wasserentnahme (NUR fuer Entnahme aus HG-Rasterzelle) - PARAMETERWAHL wird bisher NICHT gelogt! m_pWConsOut->Assign(0.0); if(i == 3) // falls Entnahme Funktion 3 (Entnahme des genauen Wertes der Eingangsdaten aus jeder Raterzelle) -> dann entspricht WasserentnahmeRaster genau den Eingangsdaten m_pWConsOut->Assign(&pWConsData); else if(m_pNumInFlow && m_pBasinShare) { //FlussGrids Identifizieren und damit jeweiliges Teileinzugsgebiet bestimmen for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if( m_pRivGrids && Parameters("RivG")->asInt() > 0 && m_pRivGrids->asDouble(x,y) != 0) //Wenn HG-Rasterzelle { double r = 0; //KoordinatenDouble erzeugen FORMAT: xxxxyyyy int u = 10000*x + y; r = u; //Wert der gesetzt wird : FORMAT: xxxxyyyy (Koordinate der Flussrasterzelle des Teileinzugsgebietes) //Falls Entnahme Funktion 1: Entnahme des Teileinzugsgebietes NUR aus der HauptgerinneRasterzelle if(i == 1) { m_pWConsOut->Add_Value(x, y, m*pWConsData.asDouble(x, y)); //Entnahmewert der HG-Rasterzelle aus HG-Rasterzelle entnehmen BasinCon = BasinCon + m*pWConsData.asDouble(x, y); //Aufsummierung der Entnahme im gesamten Einzugsgebiet for(int ix=0; ix < NX; ix++) { for(int iy=0; iy < NY; iy++) { if(!m_pDTM->is_NoData(ix,iy) && m_pBasinShare->asDouble(ix,iy) == r) m_pWConsOut->Add_Value(x, y, (m*pWConsData.asDouble(ix, iy)) ); //Entnahmewert der Teileinzugsgebiets-Rasterzelle aus HG-Rasterzelle entnehemn BasinCon = BasinCon + (m*pWConsData.asDouble(ix, iy)); //Aufsummierung der Entnahme im gesamten Einzugsgebiet } } } //Falls Entnahme Funktion 2: Entnahme des Teileinzugsgebietes ANTEILIG aus jeder Rasterzelle des Teileinzuggebietes //Berechnugsparameter bestimmen: //SumCons=Summe aller Ennahmen des Teileinzuggebietes (inkl HG-Rasterzelle) //SumInFlow=Aufsummierte InFlowCell Werte aller Rasterzellen des Teileinzuggebietes if(i == 2) { SumCons = pWConsData.asDouble(x, y); //Entnahmen im Teileinzugsgebiet: Entnahme der HG-Rasterzelle (x,y) setzten SumInFlow = m_pNumInFlow->asDouble(x, y); for(int ix=0; ix < NX; ix++) { for(int iy=0; iy < NY; iy++) { if(!m_pDTM->is_NoData(ix,iy) && m_pBasinShare->asDouble(ix,iy) == r) { //TEST double Tst = pWConsData.asDouble(ix, iy); double Tst2 = m_pNumInFlow->asDouble(ix, iy); SumCons = SumCons + pWConsData.asDouble(ix, iy); SumInFlow = SumInFlow + m_pNumInFlow->asDouble(ix, iy); } } } BasinCon = BasinCon + SumCons; //Aufsummierung der Entnahme im gesamten Einzugsgebiet //Auf Basis des Entnahmeanteils P = m_pNumInFlow(Rasterzelle) / SumInFlow , bestimmen des Entnahmewertes ueber P*SumCons und schreiben in m_pWConsOut if(m_pNumInFlow->asDouble(x, y) == 0) //Wenn SONDERFALL: HG-Rasterzelle hat keine Zufluesse, daher m_pNumInFlow und SumInFlow == 0 -> keine antielige sonder absolute Entnahme! { m_pWConsOut->Set_Value(x, y, SumCons); //...bestimmen des Entnahmewertes der HG-Zelle valTest = SumCons; //Validierungstest: Summe der anteiligen Entnahmen im Teileinzugsgebiet } else //anteilige Entnahme { m_pWConsOut->Set_Value(x, y, (m_pNumInFlow->asDouble(x, y) / SumInFlow * SumCons)); //...bestimmen des Entnahmewertes der HG-Zelle valTest = m_pNumInFlow->asDouble(x, y) / SumInFlow * SumCons; //Validierungstest: Summe der anteiligen Entnahmen im Teileinzugsgebiet } for(int ix=0; ix < NX; ix++) { for(int iy=0; iy < NY; iy++) { if(!m_pDTM->is_NoData(ix,iy) && m_pBasinShare->asDouble(ix,iy) == r && m_pNumInFlow->asDouble(x, y) > 0) { double partCon = (m_pNumInFlow->asDouble(ix, iy) / SumInFlow * SumCons); valTest = valTest + partCon; //Validierungstest: Summe der anteiligen Entnahmen im Teileinzugsgebiet m_pWConsOut->Set_Value(ix, iy, partCon); //...bestimmen des Entnahmewertes der uebrigen Rasterzelle } } } } } } } } //valTest Breakpoint: valTest ungefaehr SumCons ?? else return(false); return(true); } //###################################################### //######################################################### //--------------------------------------------------------- //######################################################### /////////////////////////////////////////////////////////// // // // Sekundaer-Funktionen // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //Initiierungsfunktionen //--------------------------------------------------------- // void CLandFlow::InitKArray() //Warnung : Funktion statisch auf Grid m_pGrad eingestellt { double Cx; int nCx; for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if(m_pGrad->is_NoData(x,y) || m_pGrad->asDouble(x,y) == 0) { kArray[x][y][0] = -1; kArray[x][y][1] = -1; kArray[x][y][2] = -1; } else { if( Parameters("RivG")->asInt() > 0 && m_pRivGrids->asDouble(x,y) != 0) // falls Flusssgrids beruecksichtigt werden und Flussgrid... { Cx = C0r; nCx = nCr; } else { Cx = C0; nCx = nC; } double kG = G0/(nG*2) * (m_pDTM->Get_Cellsize() / 1000 ) / pow(m_pGrad->asDouble(x,y), 0.1 ); // *0* DEFAULT: pG = 17.87e-2*dx/(grad)^0.1 -> dx in km double kC = Cx/(nCx*2) * (m_pDTM->Get_Cellsize() / 1000 ) / pow(m_pGrad->asDouble(x,y), 0.1 ); // *1* DEFAULT: pC = 9.92e-4*dx/(grad)^0.1 -> dx in km double kB = pB * (m_pDTM->Get_Cellsize() / 1000 ) / 50; // *2* kB [d], dx [km] / d0=50000 m ) if( kG > kMinG ) kArray[x][y][0] = kG; else kArray[x][y][0] = kMinG; if( kC > kMinC ) kArray[x][y][1] = kC; else kArray[x][y][1] = kMinC; if ( kB > kMinB ) kArray[x][y][2] = kB; else kArray[x][y][2] = kMinB; } } } } void CLandFlow::InitNcArray(int p1, int p2, int p3) { // Initiieren mit Wert Null for(int x=0; x < p1; x++) { for(int y=0; y < p2; y++) { for(int i = 0; i < p3; i++) { nCArray[x][y][i] = 0; } } } } /*void CLandFlow::InitPArray(int p1, int p2, int p3) //zur Zeit: nicht gesetzt { // Initiieren mit Wert Null for(int x=0; x < p1; x++) { for(int y=0; y < p2; y++) { for(int i = 0; i < p3; i++) { pArray[x][y][i] = 0; } } } }*/ //--------------------------------------------------------- //Speicherfunktionen bzw. Schreibefunktion //--------------------------------------------------------- // bool CLandFlow::SaveNcCache(int nMax) { int i = 0; int o = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\NcCache.txt"; path = path0.str(); int d = NX * NY; fstream myfile; myfile.open(path.c_str(), ios::out|ios::trunc); for(int x = 0; x < NX; x++) { for(int y = 0; y < NY; y++) { myfile << x << " " << y; for(o = 0; o < nMax; o++) { /**/ if(o == 0 && m_pTempK->asDouble(x,y) >= 0) // aenderung 181114: Gitterboxzufluss des letzten Zeitschritts wird im ersten Speicher gerspeichert... /**/ myfile << " " << ( nCArray[x][y][o] + m_pTempK->asDouble(x,y) ); /**/ else myfile << " " << nCArray[x][y][o]; } myfile << "\n"; i++; Process_Set_Text(CSG_String::Format(SG_T("NcCache || Schreibe Datensatz %d von %d"),i ,d)); } } myfile.close(); return true; } bool CLandFlow::SaveParameters() { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\SimParameters.txt"; path = path0.str(); int d = NX * NY; time_t rawtime; time(&rawtime); fstream myfile; myfile.open(path.c_str(), ios::out|ios::trunc); myfile << "KALIBRIERUNGSVERSION des Programms! EingangsPARAMETER C0, C0r und G0 unabhaengig von n." << "\n\n"; myfile << "Basierend auf: ProgrammBuild " << cVers << "\n"; myfile << "TimeStamp: " << ctime(&rawtime) << "\n\n"; myfile << "Parameter:\n\n"; myfile << "Startjahr = " << m_sYear0 << "\n"; myfile << "Simulation mit Speicherwerten initialisieren [0 = nein, 1 = ja]: " << Parameters("CacheUse")->asBool() << "\n"; myfile << "Wasservolumen in den Systemspeichern zu Beginn der Simulation: RivBasInit = " << RivBasInit << " und WSystemInit = " << WSystemInit << "\n"; myfile << "Rechentage [d] = " << m_pDays << "\n"; myfile << "Schrittlaenge [s] = " << m_pTStep << "\n\n"; myfile << "vMax [km/h] = " << vMax << "\n"; myfile << "Aufloesung [m] = " << m_pDTM->Get_Cellsize() << "\n"; myfile << "Anzahl der Reihen NX = " << NX << "\n"; myfile << "Anzahl der Zeilen NY = " << NY << "\n"; myfile << "Anzahl der Rasterzellen des DTM (ohne NoDataZellen): " << NumGrids << "\n"; myfile << "Anzahl der Rasterzellen im Flusseinzugsgebiet: " << NumRBGrids << "\n\n"; myfile << "LSSchemaDaten-Dateipfad [Ordner]: " << m_pLSDataFolder.b_str() << "\n"; myfile << "WaterGapDaten-Dateipfad [Ordner]: " << m_pWConDataFolder.b_str() << "\n"; myfile << "Datenpfad wo gespeicher werden soll: " << m_pDataSaveFolder.b_str() << "\n"; myfile << "Absoluter SpeicherDateipfad: " << m_pSPath << "\n\n"; myfile << "nG = " << nC << "\n"; myfile << "nHG = " << nCr << "\n"; myfile << "nO = " << nG << "\n"; myfile << "cG = " << C0 << "\n"; myfile << "cHG = " << C0r << "\n"; myfile << "cO = " << G0 << "\n"; myfile << "pB = " << pB << "\n\n"; myfile << "Fester Reduzierungsfaktor des Surface Runoff [%/100] = " << m_pRedFacR << "\n"; myfile << "Fester Reduzierungsfaktor der Drainage [%/100] = " << m_pRedFacD << "\n"; myfile << "Ausgleich der Surface Runoff Reduktion = " << Parameters("autoFacD")->asBool() << "\n2"; myfile << "Offsetwert Surface Runoff [m3/s] = " << m_pOffsetR << "\n"; myfile << "Offsetwert Drainage [m3/s] = " << m_pOffsetD << "\n";myfile << "Flussgrid-Beruecksichtigung/Bestimmung = " << Parameters("RivG")->asInt() << "\n"; myfile << "kMinG [d] = " << kMinC << "\n"; myfile << "kMinHG [d] = " << kMinCr << "\n"; myfile << "kMinO [d] = " << kMinG << "\n"; myfile << "kMinB [d] = " << kMinB << "\n"; myfile << "vMaxG [km/h] = " << vMaxC << "\n"; myfile << "vMaxHG [km/h] = " << vMaxCr << "\n"; myfile << "vMaxO [km/h] = " << vMaxG << "\n"; myfile << "Berechnung NUR im RiverBasin = " << Parameters("onlyRB")->asBool() << "\n\n"; myfile << "Flaechenwasserentnahme - Auswahl [0=keine] = " << Parameters("WCons")->asInt() << "\n"; myfile << "Fester Gitterbox-Wasserentnahmefaktor [%] = " << m_pConsFacAll << "\n"; myfile << "Fester FlussGitterbox-Wasserentnahmefaktor [%] = " << m_pConsFacRiv << "\n"; myfile << "Vorlauftage bevor Wasserentnahme beruecksichtigt wird [d] = " << m_pWConsDIn << "\n\n"; myfile << "Schwellenwert ab dem eine Entnahem erst vorgenommen wird [m3/s] = " << m_pWConThres << "\n"; myfile << "Einheit der eingelesenen WaterGapDaten ([m3/s] = 0, [m3/Monat] = 1): " << Parameters("WConUnit")->asInt() << "\n\n"; myfile << "m_pVTresh erzwingen = " << Parameters("EnfVmax")->asBool() << "\n"; myfile << "m_pVTresh [km/h] = " << m_pVTresh << "\n"; myfile << "Autom. Zeitschrittlaenge = " << Parameters("CalcT")->asBool() << "\n"; myfile << "k_Min [d] = " << k_Min << "\n\n"; myfile << "ErrorCode = " << errC << "\n\n"; myfile << "Evaluierungspunkte:" << "\n"; myfile << "Evaluierungspunkt 1 - " << m_pEvP1s.b_str() << ", x=" << Parameters("EvP1x")->asInt() << ", y=" << Parameters("EvP1y")->asInt() << "\n"; myfile << "Evaluierungspunkt 2 - " << m_pEvP2s.b_str() << ", x=" << Parameters("EvP2x")->asInt() << ", y=" << Parameters("EvP2y")->asInt() << "\n"; myfile << "Evaluierungspunkt 3 - " << m_pEvP3s.b_str() << ", x=" << Parameters("EvP3x")->asInt() << ", y=" << Parameters("EvP3y")->asInt() << "\n"; myfile << "Ausgangsrasterzelle des Flusseinzugsgebiet: " << "x=" << Parameters("RBMx")->asInt() << ", y=" << Parameters("RBMy")->asInt() << "\n\n"; if(Parameters("vRM1")->asInt() > 0 || Parameters("vRM2")->asInt() > 0) { myfile << "Abflussmanipulation Rasterzelle 1 - Manipulation des berechnteen Abflusses [1], Abfluss aus Speicher vorgeben [2]: " << Parameters("vRM1")->asInt() << "\n"; myfile << "Koordinate: x = " << Parameters("RM1x")->asInt() << ", y = " << Parameters("RM1y")->asInt() << "\n"; myfile << "Faktor q = " << Parameters("RM1q")->asDouble() << " und Offset a = " << Parameters("RM1a")->asDouble() << "\n\n"; myfile << "Abflussmanipulation Rasterzelle 2 - Manipulation des berechnteen Abflusses [1], Abfluss aus Speicher vorgeben [2]: " << Parameters("vRM2")->asInt() << "\n"; myfile << "Koordinate: x = " << Parameters("RM2x")->asInt() << ", y = " << Parameters("RM2y")->asInt() << "\n"; myfile << "Faktor q = " << Parameters("RM2q")->asDouble() << " und Offset a = " << Parameters("RM2a")->asDouble() << "\n\n"; myfile << "Gesamtmenge des Wassers, die waehrend des Simualtionszeitraumes durch die Rasterzellenmanipulation dem RivBasin hinzugefuegt (+) oder entnommen (-) wurde: " << manWithd << "\n\n"; } if(Parameters("Test1")->asInt() > 0) { myfile << "TestRoutine [1]: 1) nur fuer Teileinzugsgebiet der HG-Rasterzelle oder [2] fuer das Flusseinzugsgebiet bis zum Erreichen der HG-Rasterzelle: " << Parameters("Test1")->asInt() << "\n\n"; myfile << "TestRoutine 1: Flusseinzugsgebiet der Flussrasterzelle (" << Parameters("xt1")->asInt() << "," << Parameters("yt1")->asInt() << ")\n"; if(SumRD_SubBasin >= 0) { myfile << "Anzahl der Rasterzellen des Teileinzugsgebietes: " << NumGridsTestR1 << "\n"; myfile << "Summe der vertikalen Zufluesse im Teileinzugsgebiet ueber den gesamten Simulationszeitraum: " << SumRD_SubBasin << "\n"; myfile << "Summe der Abfluesse aus der Flussrasterzelle ueber den gesamten Simulationszeitraum: " << m_pTestR1 << "\n"; myfile << "Differenz: " << SumRD_SubBasin - m_pTestR1 << "\n\n"; } else myfile << "FEHLER beim Ausfuehren der TestRoutine 1.\n\n"; } /*myfile << "x | y | kG | kC | kB | Wcons" << "\n"; //Schreiben aller K-Werte zu den jeweiligen (x,y) Koordinaten for(int x = 0; x < NX; x++) { for(int y = 0; y < NY; y++) { myfile << x << " " << y; myfile << " " << kArray[x][y][0]; myfile << " " << kArray[x][y][1]; myfile << " " << kArray[x][y][2]; if( Parameters("WCons")->asBool() ) myfile << " " << (m_pWCons->asDouble(x,y) / 1000) * pow(m_pDEM->Get_Cellsize(), 2) * m_pTStep; myfile << "\n"; i++; Process_Set_Text(CSG_String::Format("Parameters || Schreibe Datensatz %d von %d",i ,d)); } }*/ myfile.close(); return true; } bool CLandFlow::WriteOutput(string s, double p1, double p2, int x, int y) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\" << s ; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); if(x >= 0 && y >= 0 ) myfile << x << " " << y << " " << p1 << " " << p2 << "\n"; else myfile << p1 << " " << p2 << "\n"; myfile.close(); return true; } bool CLandFlow::WriteRivBalance(int i1, int i2, double p1, double p2) { std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath3 << "\\" << "RivWaterBalance_" << m_sYear << "-" << dC << ".txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); if(p1 < 0 && p2 < 0 ) //nur schreiben des headers { myfile << "Jahr:" << i1 << " Tag:" << i2 << "\n"; myfile << "Koordinate Flusskilometer m3/s" << "\n"; } else myfile << "(" << i1 << "," << i2 << ") " << p1 << " " << p2 << "\n"; myfile.close(); return true; } //--------------------------------------------------------- // Logeintraege //--------------------------------------------------------- // bool CLandFlow::TestLog1(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\Monitoring_RivBasin.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } bool CLandFlow::TestLog2(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\Monitoring_WSystem.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } bool CLandFlow::TestLog3(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\Monitoring_monthWUseRivBasin.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } bool CLandFlow::TestLog4(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\TestRoutine1.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } bool CLandFlow::WriteLog(string s) { int i = 0; std::stringstream path0; std::string path; path0.str(""); path0 << m_pSPath << "\\ErrorLog.txt"; path = path0.str(); ofstream myfile; myfile.open(path.c_str(), ios_base::app); myfile << s << "\n"; Process_Set_Text(CSG_String::Format(SG_T("Schreibe in Logdatei"))); myfile.close(); return true; } //----------------------------------------------------- // ReadCacheFile Functions //----------------------------------------------------- // double CLandFlow::ReadNCacheFile(bool p0, string s1, int p1, int p2, int p3, int p4, int p5, char p6, int p7, bool p8) { //p0 - false : Opt1 (Datei in Array einelsen) / true : Opt2 (Spez Wert zu Koord (x,y) einlesen) //p1 - Anzahl der x-Eintraege / Anzahl der x-Eintraege //p2 - Anzahl der y-Eintraege / Anzahl der y-Eintraege //p3 - 0 / x-Koordinate (x0 = 0) //p4 - 0 / y-Koordinate (y0 = 0) //p5 - Anzahl der Speicherwerte pro x,y Koordinate / Anzahl n der Speicherwerte pro x,y Koordinate //p6 - Trennzeichen [char] / Trennzeichen [char] //p7 - 0 / spez einzulesender Speicherwert s von n //p8 - if(true) - erste Zeile enthaelt Sonderinf. / false int x = 0; int y = 0; int o = 0; int r = 0; std::string transfer; char a; double ret = -1; std::stringstream path0; std::string path; path0.str(""); path0 << m_pNCacheFolder.b_str(); path = path0.str(); ifstream myfile; myfile.open(path.c_str(), ios_base::in); if( myfile.is_open() && !myfile.eof() ) { if(p0 == false) //p0 - false : Opt1 (Datei in Array einelsen) { if(p8 == true) getline(myfile, transfer, '\n'); for(int x = 0; x < p1; x++) { for(int y = 0; y < p2; y++) { if(!myfile.eof()) { for(int m = 0; m < 2; m++) { while( (a = myfile.get()) != p6 && a != '\n') {} } for(o = 0; o < p5; o++) { if(a != 0) { if(o= 0) { for(int m = 0; m < (2+p6-1); m++) { while( (a = myfile.get()) != p6) {} if(a == '\n') { WriteLog("FEHLER!! Angabe der Anzahl der Speicherwerte pro Koordinate ist nicht korrekt - ABBRUCH"); return ret; } } if(p5 - p6 > 0) getline(myfile, transfer, p6); else getline(myfile, transfer, '\n'); ret = atof(transfer.c_str()); return ret; } else { WriteLog("FEHLER!! Einzulesend Speicherwert existiert nicht - ABBRUCH"); return ret; } } else { getline(myfile, transfer, '\n'); //ret = atof(transfer.c_str()); // testzwecke } } else { WriteLog("FEHLER!! Datei enthaelt weniger Speichereintraege als abgefragt werden - ABBRUCH"); return ret; } } } } } else { WriteLog("FEHLER!! Dateifehler - Datei NC konnte nicht geoeffnet werden - ABBRUCH."); return ret; } myfile.close(); return ret; } //----------------------------------------------------- // CreateArray Functions //----------------------------------------------------- // void CLandFlow::CreateKArray(int p1, int p2, int p3) { kArray = new double**[p1]; for (int i = 0; i < p1; i++) { kArray[i] = new double*[p2]; for (int j = 0; j < p2; j++) kArray[i][j] = new double[p3]; } } void CLandFlow::CreateLSMArray(int p1, int p2, int p3) { lsMArray = new double**[p1]; for (int i = 0; i < p1; i++) { lsMArray[i] = new double*[p2]; for (int j = 0; j < p2; j++) lsMArray[i][j] = new double[p3]; } } void CLandFlow::CreateNcArray(int p1, int p2, int p3) { nCArray = new double**[p1]; for (int i = 0; i < p1; i++) { nCArray[i] = new double*[p2]; for (int j = 0; j < p2; j++) nCArray[i][j] = new double[p3]; } } void CLandFlow::CreatePArray(int p1, int p2, int p3) { pArray = new double**[p1]; for (int i = 0; i < p1; i++) { pArray[i] = new double*[p2]; for (int j = 0; j < p2; j++) pArray[i][j] = new double[p3]; } } //----------------------------------------------------- // DeleteArray Functions //----------------------------------------------------- //ACHTUNG : statisch auf NX/NY festgelegt - Fehlerpotential, weil keine Groeszenabfrage void CLandFlow::DeleteKArray() { for(int x = 0; x < NX; x++) { for(int y = 0; y < NY; y++) { delete [] kArray[x][y]; } delete [] kArray[x]; } delete [] kArray; kArray = NULL; } void CLandFlow::DeletePArray() { for(int x = 0; x < NX; x++) { for(int y = 0; y < NY; y++) { delete [] pArray[x][y]; } delete [] pArray[x]; } delete [] pArray; pArray = NULL; } void CLandFlow::DeleteNcArray() { for(int x = 0; x < NX; x++) { for(int y = 0; y < NY; y++) { delete [] nCArray[x][y]; } delete [] nCArray[x]; } delete [] nCArray; nCArray = NULL; } //######################################################### //--------------------------------------------------------- //######################################################### //################################################################################################### // Vorlage //################################################################################################### ////////////////TEST /* if( dC >9 && dC > 12 && x == 145 && y == 578) { double pTest = m_pCCacheOut->asDouble(x,y) - m_pCFlow; std::stringstream file0; file0.str(""); file0 << "Neu Darchau-Cache: Tag = " << dC << ", Zeitschritt = " << dT << ", Entnahme m_pCFlow = " << m_pCFlow << ", Speicherwert = " << pTest; std::string file = file0.str(); TestLog1( file ); } if( dC >9 && dC > 12 && ix == 145 && iy == 578) { m_pTest = m_pTest + (m_pGFlow + m_pBFlow + m_pCFlow - m_pCon)*m_pStCons; std::stringstream file0; file0.str(""); file0 << "Neu Darchau-InFlow: Tag = " << dC << ", Zeitschritt = " << dT << ", InFlow in TStep = " << o << ", Entnahme WCons = " << varCons << ", Sum InFlow = " << m_pTest; std::string file = file0.str(); TestLog2( file ); }*/ /////////////// saga-2.3.1/src/modules/simulation/sim_rivflow/GridComb.h0000744000175000017500000001070512737416210024415 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // GridComb.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GridComb_H #define HEADER_INCLUDED__GridComb_H //--------------------------------------------------------- #include //--------------------------------------------------------- //######################################################### class CGridComb : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CGridComb(void); // constructor protected: /// protected members and functions: /////////// virtual bool On_Execute (void); // always overwrite this function private: ///// private members and functions: ///////////// int sY, eY; int NX, NY; int m_pFvA; //Auswahlplatzhalter ob Wasserentnahme oder Wassernutzung berücksichtigt werden soll CSG_String m_pDataFolder; CSG_String SPath; CSG_Grid *m_pRefGrid; CSG_Grid *m_pGridComb; CSG_Grid *m_pDomW; CSG_Grid *m_pElecW; CSG_Grid *m_pLiveW; CSG_Grid *m_pManW; CSG_Grid *m_pIrrW; bool SaveParameters(); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GridComb_H saga-2.3.1/src/modules/simulation/sim_rivflow/RivCourseImpr.cpp0000744000175000017500000001472312737416210026037 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivCourseImpr.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "RivCourseImpr.h" #include //--------------------------------------------------------- //######################################################### CRivCourseImpr::CRivCourseImpr(void) { //----------------------------------------------------- // Modul information Set_Name ("GridManipulation"); Set_Author ("Christian Alwardt"); Set_Description ("Improve RiverCourse by MouseClicks"); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "Input1" , "Geländemodell (DTM)", "Digitales Geländemodell des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_Value( NULL, "diffH" , "Höhendifferenz", "Höhe in [m] um die der Wert der Zelle erniedrigt (positiver Wert) oder erhöht (negativer Wert) wird. ", PARAMETER_TYPE_Double, 1 ); Parameters.Add_Value( NULL, "true", "Zufluss aus Nachbarzellen erzwingen", "Der Zufluss aus allen Nachbarzellen - ausgenommen die Zelle in die Wasser abfließt - wird erzwungen. Hierbei wird die gewählte Zelle um obigen Höhendifferenzwert kleiner, als alle Nachbarzellen gesetzt.", PARAMETER_TYPE_Bool, false ); } bool CRivCourseImpr::On_Execute(void){ m_pDTM = Parameters("Input1")->asGrid(); m_pDiffH = Parameters("diffH")->asDouble(); return (true); } bool CRivCourseImpr::On_Execute_Position(CSG_Point ptWorld, TSG_Module_Interactive_Mode Mode) { int iX, iY; //----------------------------------------------------- if( Mode != MODULE_INTERACTIVE_LDOWN || !Get_Grid_Pos(iX, iY) ) { return( false ); } double dValue = m_pDTM->asDouble(iX,iY); //Wert der ausgewählten Zelle if( Parameters("true")->asBool() ) { minVal = m_pDTM->asDouble(iX, iY); //minVal zunächst auf Wert der ausgwählten Zelle gesetzt int iN = m_pDTM->Get_Gradient_NeighborDir(iX, iY);//falls iN = -1 liegt Senke vor!! nX = Get_xTo(iN, iX);//Koordinaten der niedrigsten Nachbarzelle (ist niedriger als ausgewählte Zelle) nY = Get_yTo(iN, iY); double vN = m_pDTM->asDouble(nX, nY); //Wert der niedrigsten Nachbarzelle (ist niedriger als ausgewählte Zelle) double setVal; if(iN >= 0) { for(int i = 0; i < 7; i ++) { if(i != iN) getNeighFlowGridValue(iX, iY, minVal); } if(minVal > vN) { setVal = minVal - m_pDiffH; if(setVal <= vN ) setVal = minVal + ((minVal - vN) * 0.9999); } else { Message_Dlg("Achtung, eine Senke wurde generiert!", SG_T("caption")); setVal = minVal * 1.0001; } m_pDTM->Set_Value( iX, iY, setVal ); } else m_pDTM->Set_Value( iX, iY, minVal ); DataObject_Update(m_pDTM, SG_UI_DATAOBJECT_UPDATE_ONLY); } else { m_pDTM->Set_Value( iX, iY, dValue - m_pDiffH ); DataObject_Update(m_pDTM, SG_UI_DATAOBJECT_UPDATE_ONLY); } return (true); } void CRivCourseImpr::getNeighFlowGridValue(int x, int y, double kVal) { int i = m_pDTM->Get_Gradient_NeighborDir(x, y); int ix = Get_xTo(i, x); int iy = Get_yTo(i, y); if(i >= 0) { if( ix == nX && iy == nY) {} else { if (m_pDTM->asDouble(ix, iy) <= kVal) minVal = m_pDTM->asDouble(ix, iy); } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_rivflow/RivBasin.h0000744000175000017500000001070212737416210024441 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivBasin.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__RivBasin_H #define HEADER_INCLUDED__RivBasin_H //--------------------------------------------------------- #include #include using namespace std; //--------------------------------------------------------- //######################################################### class CRivBasin : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CRivBasin(void); // constructor protected: /// protected members and functions: /////////// virtual bool On_Execute (void); // always overwrite this function private: ///// private members and functions: ///////////// CSG_Grid *m_pDTM, *m_pGrad, *m_pDirec, *m_pRivGrids, *m_pRivGrad, *m_pRaster, *m_pRSpeed, *m_pBasinShare, *m_pSharedRivCons, *m_pWCons, *m_pNumInFlowCells; double pCr, BasinGrids, statV, m_pVTresh; int nCr, statN; void Set_RivParam(int x, int y); bool Set_BasinShare(void); bool WriteLog(string s); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__RivBasin_H saga-2.3.1/src/modules/simulation/sim_rivflow/LandFlow.h0000744000175000017500000003261612737416210024442 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // LandFlow.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__LandFlow_H #define HEADER_INCLUDED__LandFlow_H //--------------------------------------------------------- #include #include using namespace std; //--------------------------------------------------------- //######################################################### class CLandFlow : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CLandFlow(void); // constructor protected: /// protected members and functions: /////////// virtual bool On_Execute (void); // always overwrite this function private: ///// private members and functions: ///////////// /// Members //Grids CSG_Grid *m_pDTM; CSG_Grid *m_pGrad; CSG_Grid *m_pDirec; CSG_Grid *m_pRFlow; CSG_Grid *m_pDFlow; CSG_Grid *m_pWConsIn; //statisches WaterConsumption Grid in [kg m-2 s-1] CSG_Grid *m_pWConsOut; //dynamisch generiertes WaterConsumption Grid in [kg m-2 s-1] CSG_Grid *m_pCCacheIn; CSG_Grid *m_pRCacheIn; CSG_Grid *m_pDCacheIn; CSG_Grid *m_pCCacheOut; CSG_Grid *m_pRCacheOut; CSG_Grid *m_pDCacheOut; CSG_Grid *m_pTempR; CSG_Grid *m_pTempC; CSG_Grid *m_pTempD; CSG_Grid *m_pChannelFlow; CSG_Grid *m_pSumRunoffDrainage; CSG_Grid *m_pTemp; CSG_Grid *m_pTempK; CSG_Grid *m_pRivGrids; CSG_Grid *m_pRivGrad; CSG_Grid *m_pBasinShare; CSG_Grid *m_pRivBalanceGrid; CSG_Grid *m_pNumInFlow; CSG_Grid *m_pSumCon; //eigentliche Entnahme CSG_Grid *m_pSumResCon; //resultierende Entnahme CSG_Grid *m_pSumRemCon; //nicht berücksichtigte Entnahmen CSG_Grid *m_pTestR1Share; //gesammtes Einzugsgebiet zu HG-Rasterzelle (x,y) der TestR1 Routine CSG_Grid pWConsData; CSG_String m_pWConsFile; CSG_String m_pLSDataFolder; CSG_String m_pDataSaveFolder; CSG_String m_pWConDataFolder; CSG_String m_pNCacheFolder; CSG_String m_pDateipfad; //CSG_String m_pLSData26File; //CSG_String m_pLSData27File; CSG_String m_pEvP1s; CSG_String m_pEvP2s; CSG_String m_pEvP3s; std::string m_pSPath; std::string m_pSPath2; std::string m_pSPath3; //std::string m_pLPath; //Int int m_pDays; //Festgelegte Anzahl an Simulationstagen (Input Parameter) int nC; //Anzahl der Speicherkaskaden des ChannelFlow Speichers int nCr; //Anzahl der Speicherkaskaden des ChannelFlow River-Speichers int nMax; int nG; int NX; int NY; int dC; //dayCounter - Tageszähler [d] int dDC; //dayDataCounter - Datentag-Zähler [d] (1-365/366) int mYC; //MonthOfYear Monatszähler (1-12) int dMC; //DayOfMonth Tageszähler [d] (1-28/29/30/31) int m_pDDays; int m_pTStep; //Zeitschrittlänge dt int errC; int errC2; int errC3; int errC4; int m_sYear0; int m_sYear; int m_pWConsD; // verbleibende Tage bevor Entnahme (Operator) es gilt: m_pWConsD <= m_pWConsDIn, m_pWConsD-- int m_pWConsDIn; // Tage bevor jedwede Entnahme beginnt (Input-Variable) int numTS; // Anzahl der Zeitschritte pro Tag int NumRBGrids; //Anzahl der Rasterzellen im Flusseinzugsgebiet int NumGrids; //Anzahl der Rasterzellen des DTM (ohne NoDataValues) int NumGridsTestR1; //Anzahl der Rasterzellen des Teileinzugsgebietes der TestRoutine1 int var1; //Programmvariable : Prozentuale Wasserentnahme initiieren int var2; //Programmvariable : Testlog 1 int var3; //Programmvariable : Testlog 2 int var4; //Programmvariable : //double double cVers; //Compelierungs-Version double m_pGFlow; double m_pCFlow; double m_pBFlow; double m_pRun; double m_pDrain; double m_pVTresh; double k_Min; double kMinG; double kMinC; double kMinCr; double kMinB; double vMaxC; double vMaxCr; double vMaxG; double vMax; double dT; //daytimeCounter - Tageszeitzähler [s] double G0; double C0; double C0r; //Parameter für ChannelFlow im River [optional] double pB; double m_pCon; //Flächenbasierte Entnahmen (absoluter Wert) double m_pConsFacAll; //Entnahmefaktor aus Gitterboxen [%]/[dt] double m_pConsFacRiv; //Entnahmefaktor aus Fluss-Gitterboxen [%]/[dt] double m_pRedFacR; //Reduzierungsfaktor RunOff [%]/[dt] double m_pRedFacD; //Reduzierungsfaktor Drainage [%]/[dt] double m_pHFlowFac; //Weiterleitungsfaktor des Abfluss aus Gitterboxen in % des tatsächlichen Abflusses double m_pRFlowFac; //Weiterleitungsfaktor des Fluss-Gitterboxen in % des tatsächlichen Abflusses double m_pVRFlowFac; //reduzierter vertikaler Zufluss (Runnoff) in % des tatsächlichen RunOff-Zuflusses double m_pVDFlowFac; //reduzierter vertikaler Zufluss (Drainage) in % des tatsächlichen Drainage-Zuflusses double m_pFlowFac; //Abfrageplatzhalter für m_pHFlowFac oder m_pRFlowFac double m_pTest; double stCons; double varCons; double SumRDMonth; //Summe der Runoff und Drainage Werte des Einzugsgebietes eines Monats double SumRMonth; //NUR Summe der Runoff-Werte des Einzugsgebietes eines Monats double SumDMonth; //NUR Summe der Drainage-Werte des Einzugsgebietes eines Monats double SumRD_SubBasin; //Summe der Runoff und Drainage Werte eines SubBasin [TestRoutine 1] double SumCon_SubBasin; //Summe der beabsichtigten Entnahmen eines SubBasin [TestRoutine 1] double SumResCon_SubBasin; //Summe der tatsächlichen Entnahmen eines SubBasin [TestRoutine 1] double SumRemCon_SubBasin; //Summe der nicht berücksichtigten Entnahmen eines SubBasin [TestRoutine 1] double m_pTestR1; //SpeicherVariable TestRoutine 1 double m_pTestR1m; //SpeicherVariable TestRoutine 1 double m_pTestR1RDm; //SpeicherVariable TestRoutine 1 double m_pTestR1Cm; //SpeicherVariable TestRoutine 1 double m_pTestR1resCm; //SpeicherVariable TestRoutine 1 double m_pTestR1remCm; //SpeicherVariable TestRoutine 1 double m_pWConThres; //Schwellenwert für HG-Abfluss der auch bei Entnahmen nicht unterschritten werden soll double m_pOffsetR; //Offsetwert auf den vertikalen Zufluss 'RunOff' pro Rasterzelle in m³/s double m_pOffsetD; //Offsetwert auf den vertikalen Zufluss 'Drainage' pro Rasterzelle in m³/s double WSystemDayWithd; //Summe allen Wassers, dass dem WSystem pro Tag entnommen wird oder über Entnahmefaktor verloren geht double WSystem; // Im System befindliches Wasser double WSystemInit; // Anfänglicher Speicherinhalt WSystem nach Speicherinitilisierung double WSystemIn; // Summe des Wassers was ins System gelangt (Drainage, RunOff) double WSystemOut; // Summe des Wassers welches das System verläßt (Systemabfluss) double WSystemDayIn; // Summe des Wassers was am jeweiligen Tag ins System gelangt (Drainage, RunOff) double WSystemDayOut; // Summe des Wassers welches am je weiligenTag das System verläßt (Systemabfluss) double RivBas; // Im RivBasin befindliches Wasser double RivBasInit; // Anfänglicher Speicherinhalt RivBasin nach Speicherinitilisierung double RivBasIn; // Summe des Wassers was ins RiverBasin gelangt (Drainage, RunOff) double RivOut; // Summe des Wassers welches das RiverBasin über den Fluss verläßt (Flussabfluss) double RivBasDayIn; // Summe des Wassers was am jeweiligen Tag ins RiverBasin gelangt (Drainage, RunOff) double RivDayOut; // Summe des Wassers welches am jeweiligen Tag das RiverBasin über den Fluss verläßt (Flussabfluss) double RivMonthOut; // Summe des Wassers welches im jeweiligen Monat das RiverBasin über den Fluss verläßt (Flussabfluss) double WCCache; // Speicherabbild des Wassers in den Kaskaden Speichern double RivBasSink; // Summe allen Wasser das über dem Rechenzeitraum im RivBas in Senken verschwindet (gelöscht wird) double RivBasDayWithd; // Summe allen Wassers, dass dem RivBasin pro Tag entnommen wird oder über Entnahmefaktor verloren geht double RivBasConMonth; // Summe der auftretenden Flächenentnahmen innerhalb des gesamten Flusseinzugsgebietes pro Monat double resRivBasConMonth; // Summe der tatsächlichen durchgeführten Flächenentnahmen innerhalb des gesamten Flusseinzugsgebietes pro Monat double remRivBasConMonth; // Summe der Entnahmen die dem RivBasin nicht entnommen werden konnten (weil resFlow kleiner als m_pCon) pro Monat double manWithd; // Wasser das durch Rasterzellen Manipulation aus dem RivBasinSystem entfernt oder hinzugefügt wurde double ***kArray; double ***nCArray; //Array von n-ChannelFlow-Speichern je (x,y) Koordinate double ***lsMArray; double ***pArray; /// Functions void Calc_MainFlow(int x, int y); double Calc_GFlow(int x, int y, double f); double Calc_CFlow(int x, int y, double f, int n); double Calc_BFlow(int x, int y, double f); double CalcRet(double f, int n); bool SubBasinId(int x, int y); //Funktion gibt aus dem m_pSumRunoffDrainage-Raster die Summe der RunOff und Drainage Werte aller Rasterzellen des Teileinzugsgebiets der Flussrasterzelle (x,y) bool WConsRiv(int i); void TestR1Share(int HGx, int HGy); void InitKArray(); void InitNcArray(int p1, int p2, int p3); //Array von n-Speichern je (x,y) Koordinate void InitPArray(int p1, int p2, int p3); void CreateKArray(int p1, int p2, int p3); void CreateLSMArray(int p1, int p2, int p3); void CreateNcArray(int p1, int p2, int p3); void CreatePArray(int p1, int p2, int p3); void DeleteKArray(); void DeleteLSMArray(); void DeleteNcArray(); void DeletePArray(); double ReadNCacheFile(bool p0, string s1, int p1, int p2, int p3, int p4, int p5, char p6, int p7, bool p8); double ReadLSMCacheFile(bool p0, string s1, int p1, int p2, int p3, int p4, int p5, char p6, int p7, bool p8); // double ReadDNCacheFile(bool p0, string s1, int p1, int p2, int p3, int p4, int p5, char p6, int p7, bool p8); bool SaveNcCache(int n); bool SaveParameters(); bool WriteLog(string s); bool TestLog1(string s); bool TestLog2(string s); bool TestLog3(string s); bool TestLog4(string s); bool WriteOutput(string s, double p1, double p2, int x, int y); bool WriteRivBalance(int i1, int i2, double p1, double p2); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__LandFlow_Hsaga-2.3.1/src/modules/simulation/sim_rivflow/GridComb.cpp0000744000175000017500000003251612737416210024754 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // GridComb.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "GridComb.h" #include #include #include #include #include #include using namespace std; //ACHTUNG ////////////////////////////////////////////////////////////////////// //ACHTUNG: Bisher keine Fehlerroutine, die auf unterschiedlich große InputGrids im DateiOrdner hinweist -> moegliche Fehlerursache!!! ////////////////////////////////////////////////////////////////////// //--------------------------------------------------------- //######################################################### CGridComb::CGridComb(void) { //----------------------------------------------------- // Modul information Set_Name ("GridCombination"); Set_Author ("Christian Alwardt"); Set_Description ("Grid Combination"); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT" , "Gelaendemodell (DTM)", "Digitales Gelaendemodell des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_FilePath( Parameters("GENERAL_NODE") , "Folder1", _TL("Pfad WaterGap Raster"), _TL("Ordnerpfad in dem alle zu bearbeitenden WaterGap Raster abgelegt sind"), _TL("SAGA Grid Files (*.sgrd)|*.sgrd|All Files|*.*"),0 ,false ,true ,false ); Parameters.Add_Value( NULL, "sY" , "Start-Jahr", "Jahr in dem die Gridoperation startet", PARAMETER_TYPE_Int, 1990, 1906, true, 2000, true ); Parameters.Add_Value( NULL, "eY" , "End-Jahr", "Jahr in dem der Verarbeitungsprozess enden soll", PARAMETER_TYPE_Int, 1990, 1906, true, 2000, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "DomW", "Domestic Water", "Beruecksichtigung der Domestic Water im resultieren Raster.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "ElecW", "Electricity Water", "Beruecksichtigung der Electricity Water im resultieren Raster.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "LiveW", "Livestock Water", "Beruecksichtigung der Livestock Water im resultieren Raster.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "ManW", "Manufacturing Water", "Beruecksichtigung des Manufacturing Water im resultieren Raster.", PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( Parameters("GENERAL_NODE"), "IrrW", "Irrigation Water", "Beruecksichtigung des Irrigation Water im resultieren Raster (moeglicher Einheitenfehler im WaterGapDatensatz!!).", PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( Parameters("GENERAL_NODE") , "FvA" , _TL("Flaechenverbrauch-Auswahl (FvA)"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Resultierendes Raster ueber WasserENTNAHME erstellen"), _TL("Resultierendes Raster ueber WasserNUTZUNG erstellen") ), 0 ); } //--------------------------------------------------------- //######################################################### bool CGridComb::On_Execute(void) { //----------------------------------------------------- // Get the parameter settings... m_pRefGrid = Parameters("INPUT")->asGrid(); m_pDataFolder = Parameters("Folder1")->asString(); sY = Parameters("sY")->asInt(); eY = Parameters("eY")->asInt(); m_pGridComb = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pDomW = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pElecW = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pLiveW = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pManW = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pIrrW = SG_Create_Grid(m_pRefGrid, SG_DATATYPE_Double); m_pFvA = Parameters("FvA")->asInt(); //Auswahlplatzhalter ob Wasserentnahme oder Wassernutzung beruecksichtigt werden soll //----------------------------------------------------- //Startdatum/Zeit erfassen time_t rawtime; struct tm * timeinfo; time (&rawtime); timeinfo = localtime (&rawtime); //----------------------------------------------------- //----------------------------------------------------- // Do something... //----------------------------------------------------- //SpeicherDateipfad (sfile) fuer diese Simulation wird generiert und entsprechender Ordner erstellt - Ordnerformat : ddmmyy_HHMM std::stringstream sPath0; sPath0.str(""); char buffer [20]; strftime(buffer,20,"%d%m%y_%H%M",timeinfo); sPath0 << m_pDataFolder.b_str() << "\\Total-" << "FvA" << m_pFvA << "-D" << Parameters("DomW")->asBool() << "E" << Parameters("ElecW")->asBool() << "L" << Parameters("LiveW")->asBool() << "M" << Parameters("ManW")->asBool() << "I" << Parameters("IrrW")->asBool() << "-" << buffer; std::string m_pSPath; m_pSPath = sPath0.str(); //Speicherdateipfad SG_Dir_Create(CSG_String(m_pSPath.c_str())); //Ordner wird erstellt SPath = m_pSPath.c_str(); //----------------------------------------------------- //----------------------------------------------------- //Fehlerroutine if((eY - sY) < 0) { Message_Dlg("Fehler: Das EndJahr liegt vor dem Startjahr"); return (false); } if( (m_pFvA == 0) && Parameters("LiveW")->asBool() ) Message_Dlg("Hinweis: Fuer den Livestock liegen nur Wassernutzungsdaten vor. Diese werden deshalb auch fuer die Kalkulation der Wasserentnahme herangezogen"); //----------------------------------------------------- NX = m_pRefGrid->Get_NX(); //Anzahl der Reihen x NY = m_pRefGrid->Get_NY(); //Anzahl der Zeilen y //----------------------------------------------------- //Jahresschleife for(int n = sY; n <= eY; n++ ) { if(Parameters("DomW")->asBool()) { CSG_String sDomW; if( m_pFvA == 0 ) sDomW.Printf(SG_T("%s/domwith_%d.sgrd"), m_pDataFolder.c_str(), n); else sDomW.Printf(SG_T("%s/domcon_%d.sgrd"), m_pDataFolder.c_str(), n); if(!m_pDomW->Create(sDomW)) m_pDomW->Assign(0.0); } if(Parameters("ElecW")->asBool()) { CSG_String sElecW; if( m_pFvA == 0 ) sElecW.Printf(SG_T("%s/elecwith_%d.sgrd"), m_pDataFolder.c_str(), n); else sElecW.Printf(SG_T("%s/eleccon_%d.sgrd"), m_pDataFolder.c_str(), n); if(!m_pElecW->Create(sElecW)) m_pElecW->Assign(0.0); } if(Parameters("LiveW")->asBool()) { CSG_String sLiveW; sLiveW.Printf(SG_T("%s/livecon_%d.sgrd"), m_pDataFolder.c_str(), n); if(!m_pLiveW->Create(sLiveW)) m_pLiveW->Assign(0.0); } if(Parameters("ManW")->asBool()) { CSG_String sManW; if( m_pFvA == 0 ) sManW.Printf(SG_T("%s/manwith_%d.sgrd"), m_pDataFolder.c_str(), n); else sManW.Printf(SG_T("%s/mancon_%d.sgrd"), m_pDataFolder.c_str(), n); if(!m_pManW->Create(sManW)) m_pManW->Assign(0.0); } if(Parameters("IrrW")->asBool()) { CSG_String sIrrW; //----------------------------------------------------- //Im Fall von IrrigationData -> extra Monatsschleife //####ACHTUNG!!###### //Annahme, dass die Einheit fuer IrrigationData falsch angegebn ist und in Wirklichkeit und m3/month betraegt, //deshalb wird durch (86400*30) getielt um Einheit m3/s zu erhalten - siehe unten !! for(int i=0; i<12; i++) { if( m_pFvA == 0 ) sIrrW.Printf(SG_T("%s/PIrrWW_%d_%d.sgrd"), m_pDataFolder.c_str(), n, i+1); else sIrrW.Printf(SG_T("%s/PIrrUse_%d_%d.sgrd"), m_pDataFolder.c_str(), n, i+1); if(!m_pIrrW->Create(sIrrW)) m_pIrrW->Assign(0.0); for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if(m_pRefGrid->is_NoData(x,y)) m_pGridComb->Set_NoData(x,y); else { m_pGridComb->Set_Value(x, y, (m_pDomW->asDouble(x,y) + m_pElecW->asDouble(x,y) + m_pLiveW->asDouble(x,y) + m_pManW->asDouble(x,y) + ( m_pIrrW->asDouble(x,y) / 86400 / 30 ) )); //Monitoring: double a = m_pDomW->asDouble(x,y); double b = m_pElecW->asDouble(x,y); double c = m_pLiveW->asDouble(x,y); double d = m_pManW->asDouble(x,y); double e = ( m_pIrrW->asDouble(x,y) / 86400 / 30 ); // } } } CSG_String SaveAsFile; SaveAsFile.Printf(SG_T("%s/TotalWUse_%d_%d.sgrd"), SPath.c_str(), n, i+1); m_pGridComb->Save(SaveAsFile); } //----------------------------------------------------- } else { for(int x=0; x < NX; x++) { for(int y=0; y < NY; y++) { if(m_pRefGrid->is_NoData(x,y)) m_pGridComb->Set_NoData(x,y); else m_pGridComb->Set_Value(x, y, (m_pDomW->asDouble(x,y) + m_pElecW->asDouble(x,y) + m_pLiveW->asDouble(x,y) + m_pManW->asDouble(x,y)) ); } } CSG_String SaveAsFile; SaveAsFile.Printf(SG_T("%s/TotalWUse_%d.sgrd"), SPath.c_str(), n); m_pGridComb->Save(SaveAsFile); } } //----------------------------------------------------- SaveParameters(); delete(m_pDomW); delete(m_pElecW); delete(m_pLiveW); delete(m_pManW); delete(m_pIrrW); delete(m_pGridComb); //----------------------------------------------------- // Return 'true' if everything is okay... return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGridComb::SaveParameters() { int i = 0; int d = NX * NY; time_t rawtime; time(&rawtime); CSG_String sSaveFile; sSaveFile.Printf(SG_T("%s/Parameters.txt"), SPath.c_str() ); fstream myfile; myfile.open(sSaveFile.b_str(), ios::out|ios::trunc); myfile << "Einstellungen der Grid-Kombination." << "\n\n"; myfile << "Timestamp: " << ctime(&rawtime) << "\n\n"; myfile << "Einstellungen:\n\n"; myfile << "StartJahr = " << sY << "\n"; myfile << "EndJahr = " << eY << "\n\n"; myfile << "DomW: " << Parameters("DomW")->asBool() << "\n"; myfile << "ElecW: " << Parameters("ElecW")->asBool() << "\n"; myfile << "LiveW: " << Parameters("LiveW")->asBool() << "\n"; myfile << "ManW: " << Parameters("ManW")->asBool() << "\n"; myfile << "IrrW: " << Parameters("IrrW")->asBool() << "\n\n"; myfile << "FlaechennutzungsAuswahl - WaterWithdrawl [=0] oder WaterConsumption[=1]:" << m_pFvA << "\n\n"; myfile << "SpeicherDateipfad: " << sSaveFile.b_str() << "\n\n"; myfile.close(); return true; } saga-2.3.1/src/modules/simulation/sim_rivflow/Makefile.in0000664000175000017500000005627612737447617024660 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/simulation/sim_rivflow ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_rivflow_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_rivflow_la_OBJECTS = DataTrans.lo GridComb.lo LandFlow.lo \ MLB_Interface.lo RivBasin.lo RivCourseImpr.lo RivGridPrep.lo libsim_rivflow_la_OBJECTS = $(am_libsim_rivflow_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_rivflow_la_SOURCES) DIST_SOURCES = $(libsim_rivflow_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1537 2012-11-19 20:05:19Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_rivflow.la libsim_rivflow_la_SOURCES = \ DataTrans.cpp\ GridComb.cpp\ LandFlow.cpp\ MLB_Interface.cpp\ RivBasin.cpp\ RivCourseImpr.cpp\ RivGridPrep.cpp\ DataTrans.h\ GridComb.h\ LandFlow.h\ MLB_Interface.h\ RivBasin.h\ RivCourseImpr.h\ RivGridPrep.h libsim_rivflow_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/simulation/sim_rivflow/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_rivflow/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_rivflow.la: $(libsim_rivflow_la_OBJECTS) $(libsim_rivflow_la_DEPENDENCIES) $(EXTRA_libsim_rivflow_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_rivflow_la_OBJECTS) $(libsim_rivflow_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DataTrans.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GridComb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LandFlow.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RivBasin.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RivCourseImpr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RivGridPrep.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/simulation/sim_rivflow/Makefile.am0000744000175000017500000000131412737416210024606 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1537 2012-11-19 20:05:19Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_rivflow.la libsim_rivflow_la_SOURCES =\ DataTrans.cpp\ GridComb.cpp\ LandFlow.cpp\ MLB_Interface.cpp\ RivBasin.cpp\ RivCourseImpr.cpp\ RivGridPrep.cpp\ DataTrans.h\ GridComb.h\ LandFlow.h\ MLB_Interface.h\ RivBasin.h\ RivCourseImpr.h\ RivGridPrep.h libsim_rivflow_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/simulation/sim_rivflow/RivGridPrep.h0000744000175000017500000001036612737416210025127 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivGridPrep.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__RivGridPrep_H #define HEADER_INCLUDED__RivGridPrep_H //--------------------------------------------------------- #include //--------------------------------------------------------- //######################################################### class CRivGridPrep : public CSG_Module_Grid { public: ////// public members and functions: ////////////// CRivGridPrep(void); // constructor protected: /// protected members and functions: /////////// virtual bool On_Execute (void); // always overwrite this function private: ///// private members and functions: ///////////// CSG_Grid *m_pDTM, *m_pRivGridCells; int m_pSX, m_pSY, m_pMX, m_pMY; bool Set_RivGridCells(int sx, int sy, int mx, int my ); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__RivGrids_H saga-2.3.1/src/modules/simulation/sim_rivflow/RivGridPrep.cpp0000744000175000017500000001754312737416210025466 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // RivGridPrep.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// #include "RivGridPrep.h" //--------------------------------------------------------- //######################################################### CRivGridPrep::CRivGridPrep(void) { //----------------------------------------------------- // Modul information Set_Name ("RiverGridGeneration"); Set_Author ("Christian Alwardt"); Set_Description ("Generation of RiverCourse-GridCells"); //----------------------------------------------------- // Define your parameters list... Parameters.Add_Grid( NULL, "INPUT" , "Geländemodell (DTM)", "Digitales Geländemodell des Flusseinzugsgebietes", PARAMETER_INPUT ); Parameters.Add_Grid( NULL, "OUTPUT" , "HG Raster", "Schrittweise Ausgabe der gewünschten Abflusspfade des Hauprgerinnerasters", PARAMETER_OUTPUT ); // Flussgrids [!=0] , keine Flussgrid [0] Parameters.Add_Value( NULL, "SX" , "Abflusspfad-Quelle, x-Wert", "X-Wert der Quellen-Rasterzelle", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( NULL, "SY" , "Abflusspfad-Quelle, y-Wert", "Y-Wert der Quellen-Rastertzelle", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( NULL, "MX" , "Abflusspfad-Mündung, x-Wert", "X-Wert des Mündungs-Rasterzelle", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( NULL, "MY" , "Abflusspfad-Mündung, y-Wert", "Y-Wert des MündungsRasterzelle", PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( NULL, "Owrite", "Overwrite RiverGridCells", "Bereits existierende RiverGridCells werden überschrieben (Wenn nicht gesetzt: Abflusspfadende, wenn eine existierende RiverGridCell erreicht wird -> zB bei Fluss mit zwei Quellen sinnvoll).", PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // Hauptfunktion // // // /////////////////////////////////////////////////////////// bool CRivGridPrep::On_Execute(void) { //----------------------------------------------------- // Get the parameter settings... m_pDTM = Parameters("INPUT")->asGrid(); m_pRivGridCells = Parameters("OUTPUT")->asGrid(); m_pSX = Parameters("SX")->asInt(); m_pSY = Parameters("SY")->asInt(); m_pMX = Parameters("MX")->asInt(); m_pMY = Parameters("MY")->asInt(); //----------------------------------------------------- // Do something... if(!Set_RivGridCells(m_pSX, m_pSY, m_pMX, m_pMY)) Message_Dlg("Achtung, Fehler beim Erzeugen des Flussgrids"); //----------------------------------------------------- // Return 'true' if everything is okay... return( true ); } //######################################################### //--------------------------------------------------------- //######################################################### /////////////////////////////////////////////////////////// // // // Funktionen // // // /////////////////////////////////////////////////////////// //###################################################### // bool CRivGridPrep::Set_RivGridCells(int sx, int sy, int mx, int my ) { //Identifizierung der Flussgrids und setzen des Flusskilometerwertes - immer von Gitterboxmittelpunkt zu Mittelpunkt // if( Parameters("Owrite")->asBool() ) // m_pRivGrids->Assign(0.0); int x = sx; int y = sy; int i = -1; double dist = m_pDTM->Get_Cellsize() / 2; // Wert Flusskilomter der ersten Flussgitterboxmitte m_pRivGridCells->Set_Value(x, y, dist); // setzen der Kilometer bis zur Mitte der ersten Flussgitterbox while( !m_pDTM->is_NoData(x,y)) { i = m_pDTM->Get_Gradient_NeighborDir(x, y); if(i >= 0) { dist = dist + Get_Length(i); //bisheriger FlusskilometerWert + Weg zur nächsten Gitterboxmitte (abhängig ob Wasser diagonal oder rechtwinklig in nächste Gitterbox fließt) am Ende der Gridbox wird in FlussGitterbox geschrieben (!=0) x = Get_xTo(i, x); y = Get_yTo(i, y); if(!Parameters("Owrite")->asBool() && m_pRivGridCells->asDouble(x,y) != 0) //falls "überschreiben" nicht gesetzt, bricht Funktion ab sobald ein Grid != 0 erreicht wird. return(true); if(x == mx && y == my) { m_pRivGridCells->Set_Value(x, y, dist); // setzen der Kilometer bis zur Mitte der letzten Flussgitterbox DataObject_Update(m_pRivGridCells); return (true); } else m_pRivGridCells->Set_Value(x, y, dist); //FlusskilometerWert der nächsten Gridbox(mitte) wird in nächste FlussGitterbox i (ix,iy) geschrieben (!=0) DataObject_Update(m_pRivGridCells); } else return(false); } return (false); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_rivflow/MLB_Interface.h0000744000175000017500000000775012737416210025327 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Template_MLB_Interface_H #define HEADER_INCLUDED__Template_MLB_Interface_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef Template_EXPORTS #define Template_EXPORT _SAGA_DLL_EXPORT #else #define Template_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Template_MLB_Interface_H saga-2.3.1/src/modules/simulation/sim_rivflow/MLB_Interface.cpp0000744000175000017500000001214112737416210025650 0ustar00oconradoconrad00000000000000 /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // RivFlow // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2014 by // // Christian Alwardt // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 59 Temple Place - Suite 330, Boston, MA 02111-1307, // // USA. // // // //-------------------------------------------------------// // // // e-mail: alwardt@ifsh.de // // // // contact: Christian Alwardt // // Institute for Peace Research // // and Security Policy (IFSH) // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //######################################################### /////////////////////////////////////////////////////////// // // // RivTool 0.1 // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { default: case MLB_INFO_Name: return( _TL("RivFlow") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( "Christian Alwardt" ); case MLB_INFO_Description: return( _TL("RivFlow.") ); case MLB_INFO_Version: return( "3.1" ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Hydrology|RivFlow") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "RivBasin.h" #include "LandFlow.h" #include "RivCourseImpr.h" #include "RivGridPrep.h" #include "GridComb.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { // Don't forget to continuously enumerate the case switches // when adding new modules! Also bear in mind that the // enumeration always has to start with [case 0:] and // that [default:] must return NULL!... switch( i ) { case 0: return( new CRivBasin ); case 1: return( new CLandFlow ); case 2: return( new CRivCourseImpr ); case 3: return( new CRivGridPrep ); case 4: return( new CGridComb ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/simulation/sim_ecosystems_hugget/0000775000175000017500000000000012737740007024631 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/simulation/sim_ecosystems_hugget/Hugget_03.h0000744000175000017500000001071312737416206026531 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hugget_03.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // Hugget_03.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Hugget_03_H #define HEADER_INCLUDED__Hugget_03_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CHugget_03 : public CSG_Module_Grid { public: CHugget_03(void); virtual ~CHugget_03(void); protected: virtual bool On_Execute (void); private: bool Init_Slopes (CSG_Grid *pDEM, CSG_Grid S[8]); bool Step (CSG_Grid S[8], CSG_Grid *pN, CSG_Grid *pN_1, double N_Rain, double dTime); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Hugget_03_H saga-2.3.1/src/modules/simulation/sim_ecosystems_hugget/Hugget_02.cpp0000744000175000017500000002475212737416206027073 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hugget_02.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // Hugget_02.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Hugget_02.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CHugget_02::CHugget_02(void) { CSG_Parameter *pNode; Set_Name (_TL("02: Carbon Cycle Simulation for Terrestrial Biomass")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Simulation of the Carbon Cycle in Terrestrial Biomass. " "\nReference:" "\nHugget, R.J. (1993): 'Modelling the Human Impact on Nature', Oxford University Press.\n") ); //----------------------------------------------------- Parameters.Add_Table( NULL , "TABLE" , _TL("Results"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "TIME_SPAN" , _TL("Time Span"), _TL(""), PARAMETER_TYPE_Double , 100.0, 0.0, true ); Parameters.Add_Value( NULL , "TIME_STEP" , _TL("Time Interval [a]"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); //----------------------------------------------------- Parameters.Add_Value( NULL , "PRIMPROD" , _TL("Net Primary Production [Gt Carbon / a]"), _TL(""), PARAMETER_TYPE_Double , 27.8, 0.0, true ); Parameters.Add_Value( NULL , "CHUMIFY" , _TL("Humification Factor"), _TL(""), PARAMETER_TYPE_Double , 0.4, 0.0, true ); Parameters.Add_Value( NULL , "CCARBON" , _TL("Carbonization Factor"), _TL(""), PARAMETER_TYPE_Double , 0.05, 0.0, true ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_1", _TL("Partition Coefficients"), _TL("")); Parameters.Add_Value( pNode , "P_LEAV" , _TL("Leaves"), _TL(""), PARAMETER_TYPE_Double , 0.3, 0.0, true ); Parameters.Add_Value( pNode , "P_BRAN" , _TL("Branches"), _TL(""), PARAMETER_TYPE_Double , 0.2, 0.0, true ); Parameters.Add_Value( pNode , "P_STEM" , _TL("Stems"), _TL(""), PARAMETER_TYPE_Double , 0.3, 0.0, true ); Parameters.Add_Value( pNode , "P_ROOT" , _TL("Roots"), _TL(""), PARAMETER_TYPE_Double , 0.2, 0.0, true ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_2", _TL("Transfer Coefficients"), _TL("")); Parameters.Add_Value( pNode , "K_LEAV_LITT" , _TL("Leaves to Litter"), _TL(""), PARAMETER_TYPE_Double , 1.0, 0.0, true ); Parameters.Add_Value( pNode , "K_BRAN_LITT" , _TL("Branches to Litter"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( pNode , "K_STEM_LITT" , _TL("Stems to Litter"), _TL(""), PARAMETER_TYPE_Double , 0.033, 0.0, true ); Parameters.Add_Value( pNode , "K_ROOT_HUMU" , _TL("Roots to Humus"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( pNode , "K_LITT_HUMU" , _TL("Litter to Humus"), _TL(""), PARAMETER_TYPE_Double , 1.0, 0.0, true ); Parameters.Add_Value( pNode , "K_HUMU_COAL" , _TL("Humus to Charcoal"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( pNode , "K_COAL_ENVI" , _TL("Charcoal to Environment"), _TL(""), PARAMETER_TYPE_Double , 0.002, 0.0, true ); } //--------------------------------------------------------- CHugget_02::~CHugget_02(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define WRITE_RECORD pRecord = pTable->Add_Record();\ pRecord->Set_Value(0, iStep);\ pRecord->Set_Value(1, iStep * dTime);\ pRecord->Set_Value(2, C_Leav);\ pRecord->Set_Value(3, C_Bran);\ pRecord->Set_Value(4, C_Stem);\ pRecord->Set_Value(5, C_Root);\ pRecord->Set_Value(6, C_Litt);\ pRecord->Set_Value(7, C_Humu);\ pRecord->Set_Value(8, C_Coal); //--------------------------------------------------------- bool CHugget_02::On_Execute(void) { int iStep, nSteps; double sTime, dTime, PrimProd, cHumify, cCarbon, C_Leav, C_Bran, C_Stem, C_Root, C_Litt, C_Humu, C_Coal, P_Leav, P_Bran, P_Stem, P_Root, K_Leav_Litt, K_Bran_Litt, K_Stem_Litt, K_Root_Humu, K_Litt_Humu, K_Humu_Coal, K_Coal_Envi, d_Leav_Litt, d_Bran_Litt, d_Stem_Litt, d_Root_Humu, d_Litt_Humu, d_Humu_Coal, d_Coal_Envi; CSG_Table_Record *pRecord; CSG_Table *pTable; //----------------------------------------------------- sTime = Parameters("TIME_SPAN") ->asDouble(); dTime = Parameters("TIME_STEP") ->asDouble(); nSteps = (int)(sTime / dTime); PrimProd = Parameters("PRIMPROD") ->asDouble(); cHumify = Parameters("CHUMIFY") ->asDouble(); cCarbon = Parameters("CCARBON") ->asDouble(); P_Leav = Parameters("P_LEAV") ->asDouble(); P_Bran = Parameters("P_BRAN") ->asDouble(); P_Stem = Parameters("P_STEM") ->asDouble(); P_Root = Parameters("P_ROOT") ->asDouble(); K_Leav_Litt = Parameters("K_LEAV_LITT") ->asDouble(); K_Bran_Litt = Parameters("K_BRAN_LITT") ->asDouble(); K_Stem_Litt = Parameters("K_STEM_LITT") ->asDouble(); K_Root_Humu = Parameters("K_ROOT_HUMU") ->asDouble(); K_Litt_Humu = Parameters("K_LITT_HUMU") ->asDouble(); K_Humu_Coal = Parameters("K_HUMU_COAL") ->asDouble(); K_Coal_Envi = Parameters("K_COAL_ENVI") ->asDouble(); pTable = Parameters("TABLE") ->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("Carbon Cycle Simulation")); pTable->Add_Field("STEP" , SG_DATATYPE_Int); pTable->Add_Field("TIME" , SG_DATATYPE_Double); pTable->Add_Field("LEAVES" , SG_DATATYPE_Double); pTable->Add_Field("BRANCHES", SG_DATATYPE_Double); pTable->Add_Field("STEMS" , SG_DATATYPE_Double); pTable->Add_Field("ROOTS" , SG_DATATYPE_Double); pTable->Add_Field("LITTER" , SG_DATATYPE_Double); pTable->Add_Field("HUMUS" , SG_DATATYPE_Double); pTable->Add_Field("CHARCOAL", SG_DATATYPE_Double); //----------------------------------------------------- C_Leav = 0.0; C_Bran = 0.0; C_Stem = 0.0; C_Root = 0.0; C_Litt = 0.0; C_Humu = 0.0; C_Coal = 0.0; //----------------------------------------------------- for(iStep=0; iStep&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/simulation/sim_ecosystems_hugget ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libsim_ecosystems_hugget_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libsim_ecosystems_hugget_la_OBJECTS = Hugget_01.lo Hugget_02.lo \ Hugget_03.lo MLB_Interface.lo libsim_ecosystems_hugget_la_OBJECTS = \ $(am_libsim_ecosystems_hugget_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libsim_ecosystems_hugget_la_SOURCES) DIST_SOURCES = $(libsim_ecosystems_hugget_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_ecosystems_hugget.la libsim_ecosystems_hugget_la_SOURCES = \ Hugget_01.cpp\ Hugget_02.cpp\ Hugget_03.cpp\ MLB_Interface.cpp\ Hugget_01.h\ Hugget_02.h\ Hugget_03.h\ MLB_Interface.h libsim_ecosystems_hugget_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/simulation/sim_ecosystems_hugget/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/simulation/sim_ecosystems_hugget/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libsim_ecosystems_hugget.la: $(libsim_ecosystems_hugget_la_OBJECTS) $(libsim_ecosystems_hugget_la_DEPENDENCIES) $(EXTRA_libsim_ecosystems_hugget_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libsim_ecosystems_hugget_la_OBJECTS) $(libsim_ecosystems_hugget_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Hugget_01.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Hugget_02.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Hugget_03.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/simulation/sim_ecosystems_hugget/Hugget_03.cpp0000744000175000017500000002070212737416206027063 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hugget_03.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // Hugget_03.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Hugget_03.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CHugget_03::CHugget_03(void) { Set_Name (_TL("03: Spatially Distributed Simulation of Soil Nitrogen Dynamics")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Spatially Distributed Simulation of Soil Nitrogen Dynamics. " "\nReference:" "\nHugget, R.J. (1993): 'Modelling the Human Impact on Nature', Oxford University Press.\n") ); //----------------------------------------------------- Parameters.Add_Grid( NULL , "DEM" , _TL("Elevation"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( NULL , "NSTORE" , _TL("Soil Nitrogen"), _TL(""), PARAMETER_OUTPUT ); //----------------------------------------------------- Parameters.Add_Value( NULL , "TIME_SPAN" , _TL("Time Span [a]"), _TL(""), PARAMETER_TYPE_Double , 100.0, 0.0, true ); Parameters.Add_Value( NULL , "TIME_STEP" , _TL("Time Interval [a]"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( NULL , "UPDATE" , _TL("Update View"), _TL(""), PARAMETER_TYPE_Bool , true ); //----------------------------------------------------- Parameters.Add_Value( NULL , "NINIT" , _TL("Initial Nitrogen Content [kg/ha]"), _TL(""), PARAMETER_TYPE_Double , 5000.0, 0.0, true ); Parameters.Add_Value( NULL , "NRAIN" , _TL("Nitrogen in Rainfall [kg/ha/a]"), _TL(""), PARAMETER_TYPE_Double , 16.0, 0.0, true ); } //--------------------------------------------------------- CHugget_03::~CHugget_03(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CHugget_03::On_Execute(void) { bool bUpdate; int iStep, nSteps; double sTime, dTime, N_Init, N_Rain; CSG_Grid *pDEM, *pN, N_1, S[8]; CSG_String s; //----------------------------------------------------- sTime = Parameters("TIME_SPAN") ->asDouble(); dTime = Parameters("TIME_STEP") ->asDouble(); nSteps = (int)(sTime / dTime); bUpdate = Parameters("UPDATE") ->asBool(); N_Init = Parameters("NINIT") ->asDouble(); N_Rain = Parameters("NRAIN") ->asDouble(); pDEM = Parameters("DEM") ->asGrid(); pN = Parameters("NSTORE") ->asGrid(); pN->Assign(N_Init); DataObject_Set_Colors(pN, 100, SG_COLORS_YELLOW_GREEN); N_1.Create(pN, SG_DATATYPE_Float); Init_Slopes(pDEM, S); //----------------------------------------------------- for(iStep=0; iStep<=nSteps && Set_Progress(iStep, nSteps); iStep++) { s.Printf(SG_T("%s: %f (%f)"), _TL("Time [a]"), dTime * iStep, sTime); Process_Set_Text(s); if( bUpdate ) { DataObject_Update(pN, pN->Get_ZMin(), pN->Get_ZMax(), true); } //------------------------------------------------- Step(S, pN, &N_1, N_Rain, dTime); //------------------------------------------------- pN->Assign(&N_1); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CHugget_03::Init_Slopes(CSG_Grid *pDEM, CSG_Grid S[8]) { int x, y, i, ix, iy; double z; //----------------------------------------------------- for(i=0; i<8; i++) { S[i].Create(pDEM, SG_DATATYPE_Float); } //----------------------------------------------------- for(y=0; yis_NoData(x, y) ) { for(i=0; i<8; i++) { S[i].Set_NoData(x, y); } } else { z = pDEM->asDouble(x, y); for(i=0; i<8; i++) { ix = Get_xTo(i, x); iy = Get_yTo(i, y); if( pDEM->is_InGrid(ix, iy) ) { S[i].Set_Value(x, y, (pDEM->asDouble(ix, iy) - z) / Get_Length(i)); } else { S[i].Set_Value(x, y, 0.0); } } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CHugget_03::Step(CSG_Grid S[8], CSG_Grid *pN, CSG_Grid *pN_1, double N_Rain, double dTime) { int x, y, i; double s, dN; //----------------------------------------------------- for(y=0; yasDouble(x, y); } else { dN += s * pN->asDouble(Get_xTo(i, x), Get_yTo(i, y)); } } } s = pN->asDouble(x, y) + (dN + N_Rain) * dTime; if( s < 0.0 ) { s = N_Rain * dTime; } pN_1->Set_Value(x, y, s); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/simulation/sim_ecosystems_hugget/Hugget_01.h0000744000175000017500000001045012737416206026525 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hugget_01.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // Hugget_01.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Hugget_01_H #define HEADER_INCLUDED__Hugget_01_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CHugget_01 : public CSG_Module { public: CHugget_01(void); virtual ~CHugget_01(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Hugget_01_H saga-2.3.1/src/modules/simulation/sim_ecosystems_hugget/Makefile.am0000744000175000017500000000122012737416206026660 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libsim_ecosystems_hugget.la libsim_ecosystems_hugget_la_SOURCES =\ Hugget_01.cpp\ Hugget_02.cpp\ Hugget_03.cpp\ MLB_Interface.cpp\ Hugget_01.h\ Hugget_02.h\ Hugget_03.h\ MLB_Interface.h libsim_ecosystems_hugget_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/simulation/sim_ecosystems_hugget/Hugget_01.cpp0000744000175000017500000001640712737416206027070 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hugget_01.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // Hugget_01.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "Hugget_01.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CHugget_01::CHugget_01(void) { Set_Name (_TL("01: A Simple Litter System")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "A simple litter system model using the euler method. " "Carbon storage C is calculated in dependency of litter fall rate (Cinput) " "and rate constant for litter loss (Closs) as:\n" "C(t + 1) = C(t) + (Cinput - Closs * C(t)) * dt\n" "\nTypical values:\n" "\n- Tropical Rainforest:\n" "-- Litter fall rate: 500 [g/m2/a]\n" "-- Litter loss rate: 2.0 [1/a]\n" "\n- Temperate forest:\n" "-- Litter fall rate: 240 [g/m2/a]\n" "-- Litter loss rate: 0.4 [1/a]\n" "\n- Boreal forest:\n" "-- Litter fall rate: 50 [g/m2/a]\n" "-- Litter loss rate: 0.05 [1/a]\n" "\nReference:" "\nHugget, R.J. (1993): 'Modelling the Human Impact on Nature', Oxford University Press.\n") ); //----------------------------------------------------- Parameters.Add_Table( NULL , "TABLE" , _TL("Results"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "TIME_SPAN" , _TL("Time Span"), _TL(""), PARAMETER_TYPE_Double , 100.0, 0.0, true ); Parameters.Add_Value( NULL , "TIME_STEP" , _TL("Time Interval [a]"), _TL(""), PARAMETER_TYPE_Double , 0.1, 0.0, true ); Parameters.Add_Value( NULL , "C_INIT" , _TL("Initial Litter Storage [g/m\xb2]"), _TL(""), PARAMETER_TYPE_Double , 0.0, 0.0, true ); Parameters.Add_Value( NULL , "C_INPUT" , _TL("Litterfall Rate [g/m\xb2/a]"), _TL(""), PARAMETER_TYPE_Double , 240.0, 0.0, true ); Parameters.Add_Value( NULL , "C_OUTPUT" , _TL("Rate Constant for Litter Loss [1/a]"), _TL(""), PARAMETER_TYPE_Double , 0.4, 0.0, true ); } //--------------------------------------------------------- CHugget_01::~CHugget_01(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define WRITE_RECORD pRecord = pTable->Add_Record();\ pRecord->Set_Value(0, iStep);\ pRecord->Set_Value(1, iStep * dTime);\ pRecord->Set_Value(2, C); //--------------------------------------------------------- bool CHugget_01::On_Execute(void) { int iStep, nSteps; double sTime, dTime, C, C_Input, C_Loss; CSG_Table_Record *pRecord; CSG_Table *pTable; //----------------------------------------------------- sTime = Parameters("TIME_SPAN") ->asDouble(); dTime = Parameters("TIME_STEP") ->asDouble(); nSteps = (int)(sTime / dTime); C = Parameters("C_INIT") ->asDouble(); C_Input = Parameters("C_INPUT") ->asDouble(); C_Loss = Parameters("C_OUTPUT") ->asDouble(); pTable = Parameters("TABLE") ->asTable(); pTable->Destroy(); pTable->Set_Name(_TL("A Simple Litter System")); pTable->Add_Field("STEP" , SG_DATATYPE_Int); pTable->Add_Field("TIME" , SG_DATATYPE_Double); pTable->Add_Field("CARBON" , SG_DATATYPE_Double); //----------------------------------------------------- if( C_Loss <= 0.0 ) { C_Loss = M_ALMOST_ZERO; } if( dTime >= 1.0 / C_Loss ) { if( !Error_Set(_TL("Time interval is to large for a stable solution.")) ) { return( false ); } } //----------------------------------------------------- for(iStep=0; iStep //--------------------------------------------------------- #ifdef sim_ecosystems_hugget_EXPORTS #define sim_ecosystems_hugget_EXPORT _SAGA_DLL_EXPORT #else #define sim_ecosystems_hugget_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__sim_lectures_hugget_H saga-2.3.1/src/modules/simulation/sim_ecosystems_hugget/MLB_Interface.cpp0000744000175000017500000001175112737416206027734 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Modelling the Human Impact on Nature") ); case MLB_INFO_Category: return( _TL("Simulation") ); case MLB_INFO_Author: return( SG_T("Olaf Conrad (c) 2003") ); case MLB_INFO_Description: return( _TW( "Numerical models for ecological processes. " "Examples have been taken from:\n" "Hugget, R.J. (1993): 'Modelling the Human Impact on Nature', Oxford University Press." )); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Simulation|Ecology|Modelling the Human Impact on Nature") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "Hugget_01.h" #include "Hugget_02.h" #include "Hugget_03.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { CSG_Module *pModule; switch( i ) { case 0: pModule = new CHugget_01; break; case 1: pModule = new CHugget_02; break; case 2: pModule = new CHugget_03; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/simulation/sim_ecosystems_hugget/Hugget_02.h0000744000175000017500000001045012737416206026526 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Hugget_02.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // sim_ecosystems_hugget // // // //-------------------------------------------------------// // // // Hugget_02.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Hugget_02_H #define HEADER_INCLUDED__Hugget_02_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CHugget_02 : public CSG_Module { public: CHugget_02(void); virtual ~CHugget_02(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Hugget_02_H saga-2.3.1/src/modules/climate/0000775000175000017500000000000012737740003017446 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/climate/climate_tools/0000775000175000017500000000000012737740003022304 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/climate/climate_tools/daily_sun.cpp0000744000175000017500000002066612737416154025017 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: daily_sun.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // daily_sun.cpp // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "daily_sun.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDaily_Sun::CDaily_Sun(void) { //----------------------------------------------------- Set_Name (_TL("Sunrise and Sunset")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Grid(NULL, "TARGET" , _TL("Target System"), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "SUNRISE", _TL("Sunrise" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "SUNSET" , _TL("Sunset" ), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Grid(NULL, "LENGTH" , _TL("Day Length" ), _TL(""), PARAMETER_OUTPUT); //----------------------------------------------------- Parameters.Add_Date( NULL , "DAY" , _TL("Day of Month"), _TL(""), CSG_DateTime::Now().Get_JDN() ); Parameters.Add_Choice( NULL , "TIME" , _TL("Time"), _TL(""), CSG_String::Format("%s|%s|", _TL("local"), _TL("world") ) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CDaily_Sun::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double SG_Range_Set_0_to_24(double Value) { Value = fmod(Value, 24.0); return( Value < 0.0 ? Value + 24.0 : Value ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDaily_Sun::On_Execute(void) { //----------------------------------------------------- CSG_Grid *pTarget = Parameters("TARGET")->asGrid(); if( !pTarget->Get_Projection().is_Okay() ) { Error_Set(_TL("target's spatial reference system is undefined")); return( false ); } CSG_Grid Lon(*Get_System()), Lat(*Get_System()); SG_RUN_MODULE_ExitOnError("pj_proj4", 17, // geographic coordinate grids SG_MODULE_PARAMETER_SET("GRID", pTarget) && SG_MODULE_PARAMETER_SET("LON" , &Lon) && SG_MODULE_PARAMETER_SET("LAT" , &Lat) ) Lon *= M_DEG_TO_RAD; Lat *= M_DEG_TO_RAD; //----------------------------------------------------- CSG_Grid *pSunset = Parameters("SUNSET" )->asGrid(); CSG_Grid *pSunrise = Parameters("SUNRISE")->asGrid(); CSG_Grid *pDuration = Parameters("LENGTH" )->asGrid(); bool bWorld = Parameters("TIME")->asInt() == 1; //----------------------------------------------------- CSG_DateTime Time(Parameters("DAY")->asDate()->Get_Date()); Time.Reset_Time(); Message_Add(Time.Format("\n%A, %d. %B %Y"), false); //----------------------------------------------------- double Dec, RA, RAm, T; SG_Get_Sun_Position(Time, RA, Dec); T = ((int)Time.Get_JDN() - 2451545.0 ) / 36525.0; // Number of Julian centuries since 2000/01/01 at 12 UT (JDN = 2451545.0) RAm = fmod(18.71506921 + 2400.0513369 * T + (2.5862e-5 - 1.72e-9 * T) * T*T, 24.0); RA = fmod(RA * 12.0 / M_PI, 24.0); if( RA < 0.0 ) RA += 24.0; T = 1.0027379 * (RAm - RA); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) ) { pSunrise ->Set_NoData(x, y); pSunset ->Set_NoData(x, y); pDuration->Set_NoData(x, y); } else { double dT = (sin(-Lat.asDouble(x, y) / 60.0) - sin(Lat.asDouble(x, y)) * sin(Dec)) / (cos(Lat.asDouble(x, y)) * cos(Dec)); if( dT > 1.0 ) { pSunrise ->Set_NoData(x, y); pSunset ->Set_NoData(x, y); pDuration->Set_Value (x, y, 0.0); } else if( dT < -1.0 ) { pSunrise ->Set_NoData(x, y); pSunset ->Set_NoData(x, y); pDuration->Set_Value (x, y, 24.0); } else { dT = acos(dT) * 12.0 / M_PI; double Sunrise = SG_Range_Set_0_to_24(12.0 - dT - T); double Sunset = SG_Range_Set_0_to_24(12.0 + dT - T); pDuration->Set_Value(x, y, Sunset - Sunrise); if( bWorld ) { Sunrise = SG_Range_Set_0_to_24(Sunrise - M_RAD_TO_DEG * Lon.asDouble(x, y) / 15.0); Sunset = SG_Range_Set_0_to_24(Sunset - M_RAD_TO_DEG * Lon.asDouble(x, y) / 15.0); } pSunrise ->Set_Value(x, y, Sunrise); pSunset ->Set_Value(x, y, Sunset ); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/climate/climate_tools/bioclimatic_vars.h0000744000175000017500000001146112737416154026000 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: bioclimatic_vars.h 1380 2012-04-26 12:02:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // bioclimatic_vars.h // // // // Copyright (C) 2016 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__bioclimatic_vars_H #define HEADER_INCLUDED__bioclimatic_vars_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define NVARS 19 /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CBioclimatic_Vars : public CSG_Module_Grid { public: CBioclimatic_Vars(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: int m_Seasonality; CSG_Parameter_Grid_List *m_pT, *m_pTmin, *m_pTmax, *m_pP; CSG_Grid *m_pVars[NVARS]; void Set_NoData (int x, int y); bool Set_Variables (int x, int y); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__bioclimatic_vars_H saga-2.3.1/src/modules/climate/climate_tools/grid_levels_interpolation.h0000744000175000017500000001426012737416154027734 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_Levels_interpolation.h 1380 2012-04-26 12:02:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // grid_Levels_interpolation.h // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__grid_Levels_interpolation_H #define HEADER_INCLUDED__grid_Levels_interpolation_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Levels_Interpolation : public CSG_Module_Grid { public: CGrid_Levels_Interpolation(void); // virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); bool Initialize (const CSG_Rect &Extent); bool Finalize (void); bool Get_Value (double x, double y, double z, double &Value); bool Get_Value (const TSG_Point &p, double z, double &Value); private: bool m_Linear_bSorted, m_Spline_bAll; int m_xSource, m_vMethod, m_Trend_Order; TSG_Grid_Resampling m_hMethod; CSG_Table *m_pXTable; CSG_Grid *m_Coeff; CSG_Parameter_Grid_List *m_pXGrids, *m_pVariables; double Get_Variable (double x, double y, int iLevel); bool Get_Variable (double x, double y, int iLevel, double &Variable); double Get_Height (double x, double y, int iLevel); bool Get_Height (double x, double y, int iLevel, double &Height); bool Get_Values (double x, double y, double z, int &iLevel, CSG_Table &Values); bool Get_Linear_Sorted (double x, double y, double z, double &Value); bool Get_Linear (double x, double y, double z, double &Value); bool Get_Spline_All (double x, double y, double z, double &Value); bool Get_Spline (double x, double y, double z, double &Value); bool Get_Trend (double x, double y, double z, double &Value); bool Get_Trend_Coeff (double x, double y, double z, double &Value); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Levels_to_Surface : public CGrid_Levels_Interpolation { public: CGrid_Levels_to_Surface(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Levels_to_Points : public CGrid_Levels_Interpolation { public: CGrid_Levels_to_Points(void); protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__grid_Levels_interpolation_H saga-2.3.1/src/modules/climate/climate_tools/etp_hargreave.h0000744000175000017500000001254112737416154025302 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: etp_hargreave.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // etp_hargreave.h // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__etp_hargreave_H #define HEADER_INCLUDED__etp_hargreave_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPET_Hargreave_Grid : public CSG_Module_Grid { public: CPET_Hargreave_Grid(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Evapotranspiration") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPET_Hargreave_Table : public CSG_Module { public: CPET_Hargreave_Table(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Evapotranspiration") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPET_Day_To_Hour : public CSG_Module { public: CPET_Day_To_Hour(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Evapotranspiration") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__etp_hargreave_H saga-2.3.1/src/modules/climate/climate_tools/milankovic.h0000744000175000017500000001341512737416154024623 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: milankovic.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // milankovic.h // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__milankovic_H #define HEADER_INCLUDED__milankovic_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMilankovic : public CSG_Module { public: CMilankovic(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Earth's Orbital Parameters") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMilankovic_SR_Location : public CSG_Module { public: CMilankovic_SR_Location(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Earth's Orbital Parameters") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMilankovic_SR_Day_Location : public CSG_Module { public: CMilankovic_SR_Day_Location(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Earth's Orbital Parameters") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CMilankovic_SR_Monthly_Global : public CSG_Module { public: CMilankovic_SR_Monthly_Global(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Earth's Orbital Parameters") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__milankovic_H saga-2.3.1/src/modules/climate/climate_tools/grid_levels_interpolation.cpp0000744000175000017500000005544112737416154030275 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: Grid_Level_Interpolation.cpp 1380 2012-04-26 12:02:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // Grid_Level_Interpolation.cpp // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_levels_interpolation.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Levels_Interpolation::CGrid_Levels_Interpolation(void) { //----------------------------------------------------- Set_Author (SG_T("O.Conrad (c) 2012")); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "VARIABLE" , _TL("Variable"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Choice( NULL , "X_SOURCE" , _TL("Get Heights from ..."), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("table"), _TL("grid list") ), 1 ); Parameters.Add_Grid_List( NULL , "X_GRIDS" , _TL("Level Heights"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Grid( NULL , "X_GRIDS_CHECK" , _TL("Minimum Height"), _TL("if set, only values with level heights above DEM will be used"), PARAMETER_INPUT_OPTIONAL, true ); Parameters.Add_FixedTable( NULL , "X_TABLE" , _TL("Level Heights"), _TL("") )->asTable()->Add_Field(_TL("Height"), SG_DATATYPE_Double); Parameters.Add_Choice( NULL , "H_METHOD" , _TL("Horizontal Interpolation Method"), _TL(""), CSG_String::Format("%s|%s|%s|%s|", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 3 ); Parameters.Add_Choice( NULL , "V_METHOD" , _TL("Vertical Interpolation Method"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("linear"), _TL("spline"), _TL("polynomial trend"), _TL("polynomial trend (coefficient interpolation)") ), 0 ); Parameters.Add_Value( NULL , "LINEAR_SORTED" , _TL("Sorted Levels"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "SPLINE_ALL" , _TL("Pre-analyze"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "TREND_ORDER" , _TL("Polynomial Order"), _TL(""), PARAMETER_TYPE_Int, 3, 1, true ); //----------------------------------------------------- for(int i=0; i<10; i++) { Parameters("X_TABLE")->asTable()->Add_Record()->Set_Value(0, i + 1); } Add_Parameters("INTERNAL", "", ""); m_Coeff = NULL; } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGrid_Levels_Interpolation::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("V_METHOD")) ) { pParameters->Get_Parameter("LINEAR_SORTED")->Set_Enabled(pParameter->asInt() == 0); pParameters->Get_Parameter("SPLINE_ALL" )->Set_Enabled(pParameter->asInt() == 1); pParameters->Get_Parameter("TREND_ORDER" )->Set_Enabled(pParameter->asInt() >= 2); } if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("X_SOURCE")) ) { pParameters->Get_Parameter("X_TABLE" )->Set_Enabled(pParameter->asInt() == 0); pParameters->Get_Parameter("X_GRIDS" )->Set_Enabled(pParameter->asInt() == 1); pParameters->Get_Parameter("X_GRIDS_CHECK")->Set_Enabled(pParameter->asInt() == 1); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Initialize(const CSG_Rect &Extent) { //----------------------------------------------------- m_pVariables = Parameters("VARIABLE" )->asGridList(); m_pXGrids = Parameters("X_GRIDS" )->asGridList(); m_pXTable = Parameters("X_TABLE" )->asTable(); m_xSource = Parameters("X_SOURCE" )->asInt(); m_vMethod = Parameters("V_METHOD" )->asInt(); m_Linear_bSorted = Parameters("LINEAR_SORTED")->asBool(); m_Spline_bAll = Parameters("SPLINE_ALL" )->asBool() == false; m_Trend_Order = Parameters("TREND_ORDER" )->asInt(); switch( Parameters("H_METHOD")->asInt() ) { default: m_hMethod = GRID_RESAMPLING_NearestNeighbour; break; case 1: m_hMethod = GRID_RESAMPLING_Bilinear; break; case 2: m_hMethod = GRID_RESAMPLING_BicubicSpline; break; case 3: m_hMethod = GRID_RESAMPLING_BSpline; break; } //----------------------------------------------------- if( m_pVariables->Get_Count() != (m_xSource == 0 ? m_pXTable->Get_Count() : m_pXGrids->Get_Count()) ) { Error_Set(_TL("variable and height levels have to be of same number")); return( false ); } if( m_vMethod == 1 && m_pVariables->Get_Count() <= m_Trend_Order ) { Error_Set(_TL("fitting a polynom of ith order needs at least i + 1 samples")); return( false ); } if( !Extent.Intersects(Get_System()->Get_Extent(true)) ) { Error_Set(_TL("target area is distinct from levels area ")); return( false ); } //----------------------------------------------------- CSG_Grid *pHeight_Min = m_xSource == 1 && Parameters("X_GRIDS_CHECK") ? Parameters("X_GRIDS_CHECK")->asGrid() : NULL; if( pHeight_Min ) { if( !Get_Parameters("INTERNAL")->Get_Parameter("X_GRIDS") ) { Get_Parameters("INTERNAL")->Add_Grid_List(NULL, "X_GRIDS", "", "", PARAMETER_INPUT_OPTIONAL); } CSG_Parameter_Grid_List *pXGrids = Get_Parameters("INTERNAL")->Get_Parameter("X_GRIDS")->asGridList(); for(int i=0; iGet_Count(); i++) { CSG_Grid *pHeight = SG_Create_Grid(*m_pXGrids->asGrid(i)); #pragma omp parallel for for(int y=0; yasDouble(x, y) < pHeight_Min->asDouble(x, y) ) { pHeight->Set_NoData(x, y); } } } pXGrids->Add_Item(pHeight); } m_pXGrids = pXGrids; } //----------------------------------------------------- if( m_vMethod == 3 ) // polynom coefficient interpolation { int i; m_Coeff = new CSG_Grid[1 + m_Trend_Order]; for(i=0; i<=m_Trend_Order; i++) { m_Coeff[i].Create(*Get_System()); } #pragma omp parallel for private(i) for(int y=0; yGet_Count(); i++) { double Height, Variable; if( Get_Height(p_x, p_y, i, Height) && Get_Variable(p_x, p_y, i, Variable) ) { Trend.Add_Data(Height, Variable); } } if( Trend.Get_Trend() ) { for(i=0; i<=m_Trend_Order; i++) { m_Coeff[i].Set_Value(x, y, Trend.Get_Coefficient(i)); } } else { for(i=0; i<=m_Trend_Order; i++) { m_Coeff[i].Set_NoData(x, y); } } } } } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Finalize(void) { if( Get_Parameters("INTERNAL")->Get_Parameter("X_GRIDS") && Get_Parameters("INTERNAL")->Get_Parameter("X_GRIDS")->asGridList() == m_pXGrids ) { for(int i=0; iGet_Count(); i++) { delete(m_pXGrids->asGrid(i)); } m_pXGrids->Del_Items(); } if( m_Coeff ) { delete[](m_Coeff); m_Coeff = NULL; } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline double CGrid_Levels_Interpolation::Get_Variable(double x, double y, int iLevel) { return( m_pVariables->asGrid(iLevel)->Get_Value(x, y, m_hMethod) ); } //--------------------------------------------------------- inline bool CGrid_Levels_Interpolation::Get_Variable(double x, double y, int iLevel, double &Variable) { return( m_pVariables->asGrid(iLevel)->Get_Value(x, y, Variable, m_hMethod) ); } //--------------------------------------------------------- inline double CGrid_Levels_Interpolation::Get_Height(double x, double y, int iLevel) { if( m_xSource == 0 ) { return( m_pXTable->Get_Record(iLevel)->asDouble(0) ); } return( m_pXGrids->asGrid(iLevel)->Get_Value(x, y, m_hMethod) ); } //--------------------------------------------------------- inline bool CGrid_Levels_Interpolation::Get_Height(double x, double y, int iLevel, double &Height) { if( m_xSource == 0 ) { Height = m_pXTable->Get_Record(iLevel)->asDouble(0); return( true ); } return( m_pXGrids->asGrid(iLevel)->Get_Value(x, y, Height, m_hMethod) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Values(double x, double y, double z, int &iLevel, CSG_Table &Values) { Values.Destroy(); Values.Add_Field("h", SG_DATATYPE_Double); Values.Add_Field("v", SG_DATATYPE_Double); for(int i=0; iGet_Count(); i++) { double Height, Variable; if( Get_Height(x, y, i, Height) && Get_Variable(x, y, i, Variable) ) { CSG_Table_Record *pRecord = Values.Add_Record(); pRecord->Set_Value(0, Height); pRecord->Set_Value(1, Variable); } } if( Values.Get_Count() < 2 || !Values.Set_Index(0, TABLE_INDEX_Ascending) ) { return( false ); } for(iLevel=1; iLevel z ) { return( true ); } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CGrid_Levels_Interpolation::Get_Value(double x, double y, double z, double &Value) { switch( m_vMethod ) { default: case 0: // linear if( m_Linear_bSorted ) { return( Get_Linear_Sorted(x, y, z, Value) ); } return( Get_Linear(x, y, z, Value) ); case 1: // spline if( m_Spline_bAll ) { return( Get_Spline_All(x, y, z, Value) ); } return( Get_Spline(x, y, z, Value) ); case 2: // polynomial trend return( Get_Trend(x, y, z, Value) ); case 3: // polynomial trend (coefficient interpolation) return( Get_Trend_Coeff(x, y, z, Value) ); } } //--------------------------------------------------------- inline bool CGrid_Levels_Interpolation::Get_Value(const TSG_Point &p, double z, double &Value) { return( Get_Value(p.x, p.y, z, Value) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Linear_Sorted(double x, double y, double z, double &Value) { int iLevel; for(iLevel=1; iLevelGet_Count()-1; iLevel++) { if( Get_Height(x, y, iLevel) > z ) { break; } } //----------------------------------------------------- double z0 = Get_Height(x, y, iLevel - 1); double z1 = Get_Height(x, y, iLevel ); if( z0 < z1 ) { double v0 = Get_Variable(x, y, iLevel - 1); double v1 = Get_Variable(x, y, iLevel ); Value = v0 + (z - z0) * (v1 - v0) / (z1 - z0); return( true ); } return( false ); } //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Linear(double x, double y, double z, double &Value) { int iLevel; CSG_Table Values; if( !Get_Values(x, y, z, iLevel, Values) ) { return( false ); } //----------------------------------------------------- double z0 = Values[iLevel - 1][0]; double z1 = Values[iLevel ][0]; if( z0 < z1 ) { double v0 = Values[iLevel - 1][1]; double v1 = Values[iLevel ][1]; Value = v0 + (z - z0) * (v1 - v0) / (z1 - z0); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Spline_All(double x, double y, double z, double &Value) { CSG_Spline Spline; for(int i=0; iGet_Count(); i++) { double Height, Variable; if( Get_Height(x, y, i, Height) && Get_Variable(x, y, i, Variable) ) { Spline.Add(Height, Variable); } } if( Spline.Get_Value(z, Value) ) { return( true ); } return( false ); } //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Spline(double x, double y, double z, double &Value) { int iLevel; CSG_Table Values; if( !Get_Values(x, y, z, iLevel, Values) ) { return( false ); } if( Values.Get_Count() < 3 ) { return( Get_Linear(x, y, z, Value) ); } if( iLevel >= Values.Get_Count() - 1 ) { iLevel--; } CSG_Spline Spline; if( iLevel > 1 ) { Spline.Add(Values[iLevel - 2][0], Values[iLevel - 2][1]); } Spline.Add(Values[iLevel - 1][0], Values[iLevel - 1][1]); Spline.Add(Values[iLevel ][0], Values[iLevel ][1]); Spline.Add(Values[iLevel + 1][0], Values[iLevel + 1][1]); return( Spline.Get_Value(z, Value) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Trend(double x, double y, double z, double &Value) { CSG_Trend_Polynom Trend; Trend.Set_Order(m_Trend_Order); for(int i=0; iGet_Count(); i++) { double Height, Variable; if( Get_Height(x, y, i, Height) && Get_Variable(x, y, i, Variable) ) { Trend.Add_Data(Height, Variable); } } if( Trend.Get_Trend() ) { Value = Trend.Get_Value(z); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Levels_Interpolation::Get_Trend_Coeff(double x, double y, double z, double &Value) { double Coeff, zPower = 1.0; Value = 0.0; for(int i=0; i<=m_Trend_Order; i++) { if( !m_Coeff[i].Get_Value(x, y, Coeff, m_hMethod) ) { return( false ); } Value += Coeff * zPower; zPower *= z; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Levels_to_Surface::CGrid_Levels_to_Surface(void) { //----------------------------------------------------- Set_Name (_TL("Multi Level to Surface Interpolation")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Grid_System( NULL , "SYSTEM" , _TL("Grid system"), _TL("") ); Parameters.Add_Grid( pNode , "SURFACE" , _TL("Surface"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid( pNode , "RESULT" , _TL("Interpolation"), _TL(""), PARAMETER_OUTPUT ); } //--------------------------------------------------------- bool CGrid_Levels_to_Surface::On_Execute(void) { //----------------------------------------------------- CSG_Grid *pSurface = Parameters("SURFACE")->asGrid(); CSG_Grid *pResult = Parameters("RESULT" )->asGrid(); if( !(pSurface->Get_System() == pResult->Get_System()) ) { Error_Set(_TL("surface and result grids have to share the same grid system")); return( false ); } if( !Initialize(pSurface->Get_Extent()) ) { Finalize(); return( false ); } //----------------------------------------------------- for(int y=0; yGet_NY() && Set_Progress(y, pSurface->Get_NY()); y++) { double p_y = pSurface->Get_YMin() + y * pSurface->Get_Cellsize(); #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double Value, p_x = pSurface->Get_XMin() + x * pSurface->Get_Cellsize(); if( !pSurface->is_NoData(x, y) && Get_Value(p_x, p_y, pSurface->asDouble(x, y), Value) ) { pResult->Set_Value(x, y, Value); } else { pResult->Set_NoData(x, y); } } } //----------------------------------------------------- Finalize(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Levels_to_Points::CGrid_Levels_to_Points(void) { //----------------------------------------------------- Set_Name (_TL("Multi Level to Points Interpolation")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "" )); //----------------------------------------------------- CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_INPUT, SHAPE_TYPE_Point ); Parameters.Add_Table_Field( pNode , "ZFIELD" , _TL("Height"), _TL("") ); Parameters.Add_Shapes( pNode , "RESULT" , _TL("Result"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Point ); Parameters.Add_String( NULL , "NAME" , _TL("Field Name"), _TL(""), _TL("Variable") ); } //--------------------------------------------------------- bool CGrid_Levels_to_Points::On_Execute(void) { //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS")->asShapes(); if( !Initialize(pPoints->Get_Extent()) ) { Finalize(); return( false ); } //----------------------------------------------------- if( Parameters("RESULT")->asShapes() && Parameters("RESULT")->asShapes() != pPoints ) { Parameters("RESULT")->asShapes()->Create(*pPoints); pPoints = Parameters("RESULT")->asShapes(); } //----------------------------------------------------- int zField = Parameters("ZFIELD")->asInt(); int vField = pPoints->Get_Field_Count(); CSG_String Name = Parameters("NAME")->asString(); if( Name.is_Empty() ) Name = _TL("Variable"); pPoints->Add_Field(Name, SG_DATATYPE_Double); //----------------------------------------------------- // #pragma omp parallel for for(int iPoint=0; iPointGet_Count() && Set_Progress(iPoint, pPoints->Get_Count()); iPoint++) { CSG_Shape *pPoint = pPoints->Get_Shape(iPoint); double Value; if( !pPoint->is_NoData(zField) && Get_Value(pPoint->Get_Point(0), pPoint->asDouble(zField), Value) ) { pPoint->Set_Value(vField, Value); } else { pPoint->Set_NoData(vField); } } //----------------------------------------------------- if( Parameters("RESULT")->asShapes() == NULL ) { DataObject_Update(pPoints); } Finalize(); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/climate/climate_tools/etp_hargreave.cpp0000744000175000017500000004365312737416154025645 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: etp_hargreave.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // etp_hargreave.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "etp_hargreave.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double Get_Radiation_TopOfAtmosphere (int DayOfYear, double Latitude_Rad) { double sinLat = sin(Latitude_Rad); double cosLat = cos(Latitude_Rad); double tanLat = tan(Latitude_Rad); // relative distance between sun and earth on any Julian day double dR = 0.033 * cos(DayOfYear * 2.0 * M_PI / 365.0) + 1.0; // solar declination in radians and sunset hour angle double SunHgt = 0.4093 * sin(DayOfYear * 2.0 * M_PI / 365.0 - 1.405); double SunDir = acos(-tanLat * tan(SunHgt)); // water equivalent of extraterrestrial radiation (mm/day) double R0 = 15.392 * dR * (SunDir * sinLat * sin(SunHgt) + cosLat * cos(SunHgt) * sin(SunDir)); return( R0 ); } //--------------------------------------------------------- double Get_PET_Hargreave (double R0, double Tmean, double Tmin, double Tmax) { return( 0.0023 * R0 * (Tmean + 17.8) * sqrt(Tmax - Tmin) ); // potential evapotranspiration per day } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPET_Hargreave_Grid::CPET_Hargreave_Grid(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("PET (after Hargreaves, Grid)")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "Estimation of daily potential evapotranspiration from daily average, minimum and maximum temperatures " "using Hargreave's empirical equation. In order to estimate extraterrestrial net radiation " "geographic latitude of observation and Julian day have to be supplied too. " "\nReferences:\n" "- Ambikadevi, K.M. (2004): Simulation of Evapotranspiration and Rainfall-runoff for the Stillwater River Watershed in Central Massachusetts. " "Environmental & Water Resources Engineering Masters Projects, University of Massachusetts, Amherst " "online\n" "- Hargraeves, G.H., Samani, Z.A. (1985): Reference crop evapotranspiration from ambient air temperatures. " "Paper presented in ASAE Regional Meeting, Grand Junction, Colorado. " "online\n" "Allen, R.G., Pereira, L.S., Raes, D., Smith, M. (1998): Crop evapotranspiration - Guidelines for computing crop water requirements. " "FAO Irrigation and drainage paper 56. " "online\n" )); //----------------------------------------------------- Parameters.Add_Grid(NULL, "T" , _TL("Mean Temperature" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "T_MIN", _TL("Minimum Temperature" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "T_MAX", _TL("Maximum Temperature" ), _TL(""), PARAMETER_INPUT); Parameters.Add_Grid(NULL, "PET" , _TL("Potential Evapotranspiration"), _TL(""), PARAMETER_OUTPUT); Parameters.Add_Value( NULL , "LAT" , _TL("Latitude [Degree]"), _TL(""), PARAMETER_TYPE_Double, 53.0, -90.0, true, 90.0, true ); pNode = Parameters.Add_Choice( NULL , "TIME" , _TL("Time"), _TL(""), CSG_String::Format("%s|%s|", _TL("day"), _TL("month") ), 0 ); Parameters.Add_Choice( pNode , "MONTH" , _TL("Month"), _TL(""), CSG_DateTime::Get_Month_Choices(), CSG_DateTime::Get_Current_Month() ); Parameters.Add_Value( pNode , "DAY" , _TL("Day of Month"), _TL(""), PARAMETER_TYPE_Int, CSG_DateTime::Get_Current_Day(), 1, true, 31, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CPET_Hargreave_Grid::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "T") ) { pParameters->Set_Enabled("LAT", pParameter->asGrid() && pParameter->asGrid()->Get_Projection().is_Okay() == false); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "TIME") ) { pParameters->Set_Enabled("DAY", pParameter->asInt() == 0); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPET_Hargreave_Grid::On_Execute(void) { //----------------------------------------------------- const int DaysBefore[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; const int DaysCount [12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; //----------------------------------------------------- CSG_Grid *pTavg = Parameters("T" )->asGrid(); CSG_Grid *pTmin = Parameters("T_MIN")->asGrid(); CSG_Grid *pTmax = Parameters("T_MAX")->asGrid(); CSG_Grid *pPET = Parameters("PET" )->asGrid(); //----------------------------------------------------- CSG_Grid Lat, *pLat = NULL; if( pTavg->Get_Projection().is_Okay() ) { bool bResult; CSG_Grid Lon; SG_RUN_MODULE(bResult, "pj_proj4", 17, // geographic coordinate grids SG_MODULE_PARAMETER_SET("GRID", pTavg) && SG_MODULE_PARAMETER_SET("LON" , &Lon) && SG_MODULE_PARAMETER_SET("LAT" , &Lat) ) if( bResult ) { pLat = &Lat; } } //----------------------------------------------------- int bDaily = Parameters("TIME")->asInt() == 0; CSG_DateTime Date( (CSG_DateTime::TSG_DateTime)(bDaily ? Parameters("DAY")->asInt() : 15), (CSG_DateTime::Month)Parameters("MONTH")->asInt() ); int Day = Date.Get_DayOfYear(); int nDays = Date.Get_NumberOfDays(Parameters("MONTH")->asInt()); double R0_const = Get_Radiation_TopOfAtmosphere(Day, Parameters("LAT")->asDouble() * M_DEG_TO_RAD); //----------------------------------------------------- for(int y=0; yis_NoData(x, y) || pTmin->is_NoData(x, y) || pTmax->is_NoData(x, y) || (pLat && pLat->is_NoData(x, y)) ) { pPET->Set_NoData(x, y); } else { double PET = Get_PET_Hargreave(pLat ? Get_Radiation_TopOfAtmosphere(Day, pLat->asDouble(x, y) * M_DEG_TO_RAD) : R0_const, pTavg->asDouble(x, y), pTmin->asDouble(x, y), pTmax->asDouble(x, y) ); pPET->Set_Value(x, y, bDaily ? PET : PET * nDays); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPET_Hargreave_Table::CPET_Hargreave_Table(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("PET (after Hargreaves, Table)")); Set_Author ("O.Conrad (c) 2011"); Set_Description (_TW( "Estimation of daily potential evapotranspiration from daily average, minimum and maximum temperatures " "using Hargreave's empirical equation. In order to estimate extraterrestrial net radiation " "geographic latitude of observation and Julian day have to be supplied too. " "\nReferences:\n" "- Ambikadevi, K.M. (2004): Simulation of Evapotranspiration and Rainfall-runoff for the Stillwater River Watershed in Central Massachusetts. " "Environmental & Water Resources Engineering Masters Projects, University of Massachusetts, Amherst " "online\n" "- Hargraeves, G.H., Samani, Z.A. (1985): Reference crop evapotranspiration from ambient air temperatures. " "Paper presented in ASAE Regional Meeting, Grand Junction, Colorado. " "online\n" "FAO Irrigation and drainage paper 56. " "online\n" )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "TABLE" , _TL("Data"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "JD" , _TL("Julian Day"), _TL("") ); Parameters.Add_Table_Field( pNode , "T" , _TL("Mean Temperature"), _TL("") ); Parameters.Add_Table_Field( pNode , "T_MIN" , _TL("Minimum Temperature"), _TL("") ); Parameters.Add_Table_Field( pNode , "T_MAX" , _TL("Maximum Temperature"), _TL("") ); Parameters.Add_Value( pNode , "LAT" , _TL("Latitude"), _TL(""), PARAMETER_TYPE_Double, 53.0, -90.0, true, 90.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPET_Hargreave_Table::On_Execute(void) { //----------------------------------------------------- int fDay, fT, fTmin, fTmax, fET; double Lat; CSG_Table *pTable; pTable = Parameters("TABLE")->asTable (); Lat = Parameters("LAT" )->asDouble() * M_DEG_TO_RAD; fDay = Parameters("JD" )->asInt (); fT = Parameters("T" )->asInt (); fTmin = Parameters("T_MIN")->asInt (); fTmax = Parameters("T_MAX")->asInt (); fET = pTable->Get_Field_Count(); pTable->Add_Field("ET", SG_DATATYPE_Double); //----------------------------------------------------- for(int iRecord=0; iRecordGet_Count() && Set_Progress(iRecord, pTable->Get_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); if( pRecord->is_NoData(fDay) || pRecord->is_NoData(fTmin) || pRecord->is_NoData(fTmax) ) { pRecord->Set_NoData(fET); } else { pRecord->Set_Value(fET, Get_PET_Hargreave(Get_Radiation_TopOfAtmosphere( pRecord->asInt (fDay ), Lat), pRecord->asDouble(fT ), pRecord->asDouble(fTmin), pRecord->asDouble(fTmax)) ); } } //----------------------------------------------------- DataObject_Update(pTable); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPET_Day_To_Hour::CPET_Day_To_Hour(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Daily to Hourly PET")); Set_Author ("O.Conrad (c) 2011"); Set_Description (_TW( "Derive hourly from daily evapotranspiration using sinusoidal distribution. " "\nReferences:\n" "- Ambikadevi, K.M. (2004): Simulation of Evapotranspiration and Rainfall-runoff for the Stillwater River Watershed in Central Massachusetts. " "Environmental & Water Resources Engineering Masters Projects, University of Massachusetts, Amherst " "online\n" )); //----------------------------------------------------- pNode = Parameters.Add_Table( NULL , "DAYS" , _TL("Daily Data"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "JD" , _TL("Julian Day"), _TL("") ); Parameters.Add_Table_Field( pNode , "ET" , _TL("Evapotranspiration"), _TL("") ); Parameters.Add_Table_Field( pNode , "P" , _TL("Precipitation"), _TL(""), true ); Parameters.Add_Table( NULL , "HOURS" , _TL("Hourly Data"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( pNode , "LAT" , _TL("Latitude"), _TL(""), PARAMETER_TYPE_Double, 53.0, -90.0, true, 90.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPET_Day_To_Hour::On_Execute(void) { int fJD, fET, fP; double sinLat, cosLat, sinHgt; CSG_Table *pDays, *pHours; //----------------------------------------------------- pDays = Parameters("DAYS" )->asTable(); pHours = Parameters("HOURS")->asTable(); fJD = Parameters("JD" )->asInt(); fET = Parameters("ET" )->asInt(); fP = Parameters("P" )->asInt(); sinLat = sin(Parameters("LAT") ->asDouble() * M_DEG_TO_RAD); cosLat = cos(Parameters("LAT") ->asDouble() * M_DEG_TO_RAD); sinHgt = 0.0; // -0.0145; // >> -50'' desired height of horizon pHours->Destroy(); pHours->Set_Name(CSG_String::Format("%s [%s]", pDays->Get_Name(), _TL("h"))); pHours->Add_Field("JULIAN_DAY", SG_DATATYPE_Int); pHours->Add_Field("HOUR" , SG_DATATYPE_Int); pHours->Add_Field("ET" , SG_DATATYPE_Double); if( fP >= 0 ) { pHours->Add_Field("P", SG_DATATYPE_Double); } //----------------------------------------------------- for(int iDay=0; iDayGet_Count() && Set_Progress(iDay, pDays->Get_Count()); iDay++) { CSG_Table_Record *pDay = pDays->Get_Record(iDay); int JD; double P, ET, D, dT, fT, sRise, sSet; JD = pDay->asInt (fJD); ET = pDay->asDouble(fET); if( fP >= 0 ) { P = pDay->asDouble(fP ); } D = 0.40954 * sin(0.0172 * (JD - 79.349740)); // sun's declination dT = 12.0 * acos((sinHgt - sinLat * sin(D)) / (cosLat * cos(D))) / M_PI; fT = -0.1752 * sin(0.033430 * JD + 0.5474) - 0.1340 * sin(0.018234 * JD - 0.1939); sRise = 12.0 - dT - fT; sSet = 12.0 + dT - fT; for(int iHour=0; iHour<24; iHour++) { CSG_Table_Record *pHour = pHours->Add_Record(); pHour->Set_Value(0, JD); pHour->Set_Value(1, iHour); if( fP >= 0 ) { pHour->Set_Value(3, P / 24.0); } if( sRise <= iHour && iHour <= sSet ) { pHour->Set_Value(2, ET * (1.0 - cos(2.0 * M_PI * (iHour - sRise) / (sSet - sRise))) / 2.0); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/climate/climate_tools/bioclimatic_vars.cpp0000744000175000017500000004156612737416154026344 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: bioclimatic_vars.cpp 1380 2012-04-26 12:02:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // bioclimatic_vars.cpp // // // // Copyright (C) 2016 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "bioclimatic_vars.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const CSG_String Vars[NVARS][2] = { { _TL("Annual Mean Temperature" ), _TL("") }, { _TL("Mean Diurnal Range" ), _TL("") }, { _TL("Isothermality" ), _TL("") }, { _TL("Temperature Seasonality" ), _TL("") }, { _TL("Maximum Temperature of Warmest Month"), _TL("") }, { _TL("Minimum Temperature of Coldest Month"), _TL("") }, { _TL("Temperature Annual Range" ), _TL("") }, { _TL("Mean Temperature of Wettest Quarter" ), _TL("") }, { _TL("Mean Temperature of Driest Quarter" ), _TL("") }, { _TL("Mean Temperature of Warmest Quarter" ), _TL("") }, { _TL("Mean Temperature of Coldest Quarter" ), _TL("") }, { _TL("Annual Precipitation" ), _TL("") }, { _TL("Precipitation of Wettest Month" ), _TL("") }, { _TL("Precipitation of Driest Month" ), _TL("") }, { _TL("Precipitation Seasonality" ), _TL("") }, { _TL("Precipitation of Wettest Quarter" ), _TL("") }, { _TL("Precipitation of Driest Quarter" ), _TL("") }, { _TL("Precipitation of Warmest Quarter" ), _TL("") }, { _TL("Precipitation of Coldest Quarter" ), _TL("") } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CBioclimatic_Vars::CBioclimatic_Vars(void) { //----------------------------------------------------- Set_Name (_TL("Bioclimatic Variables")); Set_Author ("O.Conrad (c) 2016"); Set_Description (_TW( "This tool calculates biogically meaningful variables from " "monthly climate data (mean, minimum and maximum temperature " "and precipitation), as provided e.g. by the " "WorldClim - Global Climate Data project.\n" "

    " "The implementation follows the definitions given by Jeremy van der Wal at " "BioClim - Bioclimatic Variables:

      " "
    1. Annual Mean Temperature:" " The mean of all the monthly mean temperatures." " Each monthly mean temperature is the mean of that month's maximum and minimum temperature.
    2. " "
    3. Mean Diurnal Range:" " The annual mean of all the monthly diurnal temperature ranges." " Each monthly diurnal range is the difference between that month's maximum and minimum temperature.
    4. " "
    5. Isothermality:" " The mean diurnal range (parameter 2) divided by the annual temperature range (parameter 7).
    6. " "
    7. Temperature Seasonality:" " returns either
      • " " the temperature coefficient of variation as the standard deviation of the monthly mean temperatures" " expressed as a percentage of the mean of those temperatures (i.e. the annual mean). For this calculation," " the mean in degrees Kelvin is used. This avoids the possibility of having to divide by zero," " but does mean that the values are usually quite small.
      • " " the standard deviation of the monthly mean temperatures.
      " "
    8. Maximum Temperature of Warmest Period:" " The highest temperature of any monthly maximum temperature.
    9. " "
    10. Minimum Temperature of Coldest Period:" " The lowest temperature of any monthly minimum temperature.
    11. " "
    12. Temperature Annual Range:" " The difference between the Maximum Temperature of Warmest Period" " and the Minimum Temperature of Coldest Period.
    13. " "
    14. Mean Temperature of Wettest Quarter:" " The wettest quarter of the year is determined (to the nearest month)," " and the mean temperature of this period is calculated.
    15. " "
    16. Mean Temperature of Driest Quarter:" " The driest quarter of the year is determined (to the nearest month)," " and the mean temperature of this period is calculated.
    17. " "
    18. Mean Temperature of Warmest Quarter:" " The warmest quarter of the year is determined (to the nearest month)," " and the mean temperature of this period is calculated.
    19. " "
    20. Mean Temperature of Coldest Quarter:" " The coldest quarter of the year is determined (to the nearest month)," " and the mean temperature of this period is calculated.
    21. " "
    22. Annual Precipitation:" " The sum of all the monthly precipitation estimates.
    23. " "
    24. Precipitation of Wettest Period:" " The precipitation of the wettest month.
    25. " "
    26. Precipitation of Driest Period:" " The precipitation of the driest month.
    27. " "
    28. Precipitation Seasonality:" " The Coefficient of Variation is the standard deviation of" " the monthly precipitation estimates expressed as a percentage of the" " mean of those estimates (i.e. the annual mean).
    29. " "
    30. Precipitation of Wettest Quarter:" " The wettest quarter of the year is determined (to the nearest month)," " and the total precipitation over this period is calculated.
    31. " "
    32. Precipitation of Driest Quarter:" " The driest quarter of the year is determined (to the nearest month)," " and the total precipitation over this period is calculated.
    33. " "
    34. Precipitation of Warmest Quarter:" " The warmest quarter of the year is determined (to the nearest month)," " and the total precipitation over this period is calculated.
    35. " "
    36. Precipitation of Coldest Quarter:" " The coldest quarter of the year is determined (to the nearest month)," " and the total precipitation over this period is calculated.
    37. " "

    " "The quarterly parameters are not aligned to any calendar quarters. " "BioClim's definition of a quarter is any consecutive 3 months. " "For example, the driest quarter will be the 3 consecutive months that " "are drier than any other set of 3 consecutive months." "

    " )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "TMEAN" , _TL("Mean Temperature"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "TMIN" , _TL("Minimum Temperature"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "TMAX" , _TL("Maximum Temperature"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "P" , _TL("Precipitation"), _TL(""), PARAMETER_INPUT ); //----------------------------------------------------- for(int i=0; iasGridList(); m_pTmin = Parameters("TMIN" )->asGridList(); m_pTmax = Parameters("TMAX" )->asGridList(); m_pP = Parameters("P" )->asGridList(); if( m_pT ->Get_Count() != 12 || m_pTmin->Get_Count() != 12 || m_pTmax->Get_Count() != 12 || m_pP ->Get_Count() != 12 ) { Error_Set(_TL("there has to be one input grid for each month")); return( false ); } //----------------------------------------------------- CSG_Colors Colors(10); Colors.Set_Color(0, 254, 135, 000); Colors.Set_Color(1, 254, 194, 063); Colors.Set_Color(2, 254, 254, 126); Colors.Set_Color(3, 231, 231, 227); Colors.Set_Color(4, 132, 222, 254); Colors.Set_Color(5, 042, 163, 239); Colors.Set_Color(6, 000, 105, 224); Colors.Set_Color(7, 000, 047, 210); Colors.Set_Color(8, 000, 001, 156); Colors.Set_Color(9, 000, 000, 103); for(int i=0; iasGrid(); if( i > 10 ) // Precipitation { DataObject_Set_Colors(m_pVars[i], Colors); } } m_Seasonality = Parameters("SEASONALITY")->asInt(); //----------------------------------------------------- for(int y=0; yasGrid(i)->is_NoData(x, y) || m_pTmin->asGrid(i)->is_NoData(x, y) || m_pTmax->asGrid(i)->is_NoData(x, y) || m_pP ->asGrid(i)->is_NoData(x, y) ) { return( false ); } T [i] = m_pT ->asGrid(i)->asDouble(x, y); Tmin[i] = m_pTmin->asGrid(i)->asDouble(x, y); Tmax[i] = m_pTmax->asGrid(i)->asDouble(x, y); P [i] = m_pP ->asGrid(i)->asDouble(x, y); dTD [i] = Tmax[i] - Tmin[i]; } //----------------------------------------------------- int T4min = 0, T4max = 0, P4min = 0, P4max = 0; for(i=0; i<12; i++) { T4[i] = (T[i] + T[(i + 1) % 12] + T[(i + 13) % 12]) / 3; if( T4[i] < T4[T4min] ) { T4min = i; } if( T4[i] > T4[T4max] ) { T4max = i; } P4[i] = (P[i] + P[(i + 1) % 12] + P[(i + 13) % 12]); if( P4[i] < P4[P4min] ) { P4min = i; } if( P4[i] > P4[P4max] ) { P4max = i; } } //----------------------------------------------------- CSG_Simple_Statistics sT(T), sTmin(Tmin), sTmax(Tmax), sP(P), sdTD(dTD); // Annual Mean Temperature SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 0], x, y, sT.Get_Mean()); // Mean Diurnal Range (Mean of monthly (max temp - min temp)) SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 1], x, y, sdTD.Get_Mean()); // Isothermality (BIO2/BIO7) (* 100) if( sTmax.Get_Maximum() - sTmin.Get_Minimum() > 0.0 ) { SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 2], x, y, 100.0 * sdTD.Get_Mean() / (sTmax.Get_Maximum() - sTmin.Get_Minimum())); } else { SG_GRID_PTR_SAFE_SET_NODATA(m_pVars[ 2], x, y); } // Temperature Seasonality if( m_Seasonality == 0 ) { // standard deviation of the mean temperatures expressed as a percentage of the mean of those temperatures (i.e. the annual mean) SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 3], x, y, 100.0 * sT.Get_StdDev() / (sT.Get_Mean() + 273.15)); } else { // standard deviation * 100 SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 3], x, y, 100.0 * sT.Get_StdDev()); } // Max Temperature of Warmest Month SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 4], x, y, sTmax.Get_Maximum()); // Min Temperature of Coldest Month SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 5], x, y, sTmin.Get_Minimum()); // Temperature Annual Range (BIO5-BIO6) SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 6], x, y, sTmax.Get_Maximum() - sTmin.Get_Minimum()); // Mean Temperature of Wettest Quarter SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 7], x, y, T4[P4max]); // Mean Temperature of Driest Quarter SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 8], x, y, T4[P4min]); // Mean Temperature of Warmest Quarter SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[ 9], x, y, T4[T4max]); // Mean Temperature of Coldest Quarter SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[10], x, y, T4[T4min]); // Annual Precipitation SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[11], x, y, sP.Get_Mean()); // Precipitation of Wettest Month SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[12], x, y, sP.Get_Maximum()); // Precipitation of Driest Month SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[13], x, y, sP.Get_Minimum()); // Precipitation Seasonality (Coefficient of Variation) SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[14], x, y, sP.Get_StdDev() * 100.0 /sP.Get_Mean()); // Precipitation of Wettest Quarter SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[15], x, y, P4[P4max]); // Precipitation of Driest Quarter SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[16], x, y, P4[P4min]); // Precipitation of Warmest Quarter SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[17], x, y, P4[T4max]); // Precipitation of Coldest Quarter SG_GRID_PTR_SAFE_SET_VALUE(m_pVars[18], x, y, P4[T4min]); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/climate/climate_tools/Makefile.in0000664000175000017500000005631612737447615024401 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/climate/climate_tools ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libclimate_tools_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libclimate_tools_la_OBJECTS = bioclimatic_vars.lo daily_sun.lo \ etp_hargreave.lo grid_levels_interpolation.lo milankovic.lo \ MLB_Interface.lo libclimate_tools_la_OBJECTS = $(am_libclimate_tools_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libclimate_tools_la_SOURCES) DIST_SOURCES = $(libclimate_tools_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libclimate_tools.la libclimate_tools_la_SOURCES = \ bioclimatic_vars.cpp\ daily_sun.cpp\ etp_hargreave.cpp\ grid_levels_interpolation.cpp\ milankovic.cpp\ MLB_Interface.cpp\ bioclimatic_vars.h\ daily_sun.h\ etp_hargreave.h\ grid_levels_interpolation.h\ milankovic.h\ MLB_Interface.h libclimate_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/climate/climate_tools/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/climate/climate_tools/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libclimate_tools.la: $(libclimate_tools_la_OBJECTS) $(libclimate_tools_la_DEPENDENCIES) $(EXTRA_libclimate_tools_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libclimate_tools_la_OBJECTS) $(libclimate_tools_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bioclimatic_vars.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/daily_sun.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/etp_hargreave.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_levels_interpolation.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/milankovic.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/climate/climate_tools/Makefile.am0000744000175000017500000000135112737416154024346 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libclimate_tools.la libclimate_tools_la_SOURCES =\ bioclimatic_vars.cpp\ daily_sun.cpp\ etp_hargreave.cpp\ grid_levels_interpolation.cpp\ milankovic.cpp\ MLB_Interface.cpp\ bioclimatic_vars.h\ daily_sun.h\ etp_hargreave.h\ grid_levels_interpolation.h\ milankovic.h\ MLB_Interface.h libclimate_tools_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/climate/climate_tools/milankovic.cpp0000744000175000017500000011470412737416154025161 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: milankovic.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Lectures // // // //-------------------------------------------------------// // // // milankovic.cpp // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "milankovic.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SG_NINT(x) ((int)(x < 0.0 ? x - 0.5 : x + 0.5)) /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSG_Solar_Position { public: CSG_Solar_Position(void); CSG_Solar_Position(long Year); static bool Get_Orbital_Parameters (int Year, double &Eccentricity, double &Obliquity, double &Perihelion); bool Get_Orbital_Position (double Day, double &SIND, double &COSD, double &SUNDIS, double &SUNLON, double &SUNLAT, double &EQTIME); bool Set_Solar_Constant (double SolarConst); double Get_Solar_Constant (void) { return( m_SolarConst ); } bool Set_Year (int Year); int Get_Year (void) { return( m_Year ); } bool Set_Day (double Day); double Get_Day (void) { return( m_Day ); } double Get_Sun_Distance (void) { return( m_SunDist ); } double Get_Sun_Lon (void) { return( m_SunLon ); } double Get_Sun_Lat (void) { return( m_SunLat ); } double Get_Zenith (void) { return( asin(m_sinDec) ); } double Get_Daily_Radiation (double Latitude); bool Get_CosZenith (double RLAT, double SIND, double COSD, double &COSZT, double &COSZS); private: int m_Year; double m_Day; double m_Eccentricity, m_Obliquity, m_Perihelion, m_SolarConst, m_sinDec, m_cosDec, m_SunDist, m_SunLon, m_SunLat, m_EqTime; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Solar_Position::CSG_Solar_Position(void) { m_SolarConst = 1367.0; m_Year = 2000; m_Day = 0.0; Get_Orbital_Parameters(m_Year, m_Eccentricity, m_Obliquity, m_Perihelion); Get_Orbital_Position (m_Day, m_sinDec, m_cosDec, m_SunDist, m_SunLon, m_SunLat, m_EqTime); } //--------------------------------------------------------- CSG_Solar_Position::CSG_Solar_Position(long Year) { m_SolarConst = 1367.0; m_Year = Year; m_Day = 0.0; Get_Orbital_Parameters(m_Year, m_Eccentricity, m_Obliquity, m_Perihelion); Get_Orbital_Position (m_Day, m_sinDec, m_cosDec, m_SunDist, m_SunLon, m_SunLat, m_EqTime); } //--------------------------------------------------------- bool CSG_Solar_Position::Set_Year(int Year) { if( m_Year != Year ) { m_Year = Year; return( Get_Orbital_Parameters(m_Year, m_Eccentricity, m_Obliquity, m_Perihelion) ); } return( true ); } //--------------------------------------------------------- bool CSG_Solar_Position::Set_Day(double Day) { if( m_Day != Day ) { m_Day = Day; return( Get_Orbital_Position(m_Day, m_sinDec, m_cosDec, m_SunDist, m_SunLon, m_SunLat, m_EqTime) ); } return( true ); } //--------------------------------------------------------- double CSG_Solar_Position::Get_Daily_Radiation(double Latitude) { double cosZT, cosZS; Get_CosZenith(Latitude, m_sinDec, m_cosDec, cosZT, cosZS); return( Get_Solar_Constant() * cosZT / (m_SunDist*m_SunDist) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // ORBPAR calculates the three orbital parameters as a function of // YEAR. The source of these calculations is: Andre L. Berger, // 1978, "Long-Term Variations of Daily Insolation and Quaternary // Climatic Changes", JAS, v.35, p.2362. Also useful is: Andre L. // Berger, May 1978, "A Simple Algorithm to Compute Long Term // Variations of Daily Insolation", published by Institut // D'Astronomie de Geophysique, Universite Catholique de Louvain, // Louvain-la Neuve, No. 18. // // Tables and equations refer to the first reference (JAS). The // corresponding table or equation in the second reference is // enclosed in parentheses. The coefficients used in this // subroutine are slightly more precise than those used in either // of the references. The generated orbital parameters are precise // within plus or minus 1000000 years from present. // // Input: YEAR = years A.D. are positive, B.C. are negative // Output: ECCEN = eccentricity of orbital ellipse // OBLIQ = latitude of Tropic of Cancer in radians // OMEGVP = longitude of perihelion = // = spatial angle from vernal equinox to perihelion // in radians with sun as angle vertex // //--------------------------------------------------------- bool CSG_Solar_Position::Get_Orbital_Parameters(int YEAR, double &ECCEN, double &OBLIQ, double &OMEGVP) { // Table 1 (2). Obliquity relative to mean ecliptic of date: OBLIQD const double TABLE1[47][3] = { { -2462.2214466, 31.609974, 251.9025 }, { -857.3232075, 32.620504, 280.8325 }, { -629.3231835, 24.172203, 128.3057 }, { -414.2804924, 31.983787, 292.7252 }, { -311.7632587, 44.828336, 15.3747 }, { 308.9408604, 30.973257, 263.7951 }, { -162.5533601, 43.668246, 308.4258 }, { -116.1077911, 32.246691, 240.0099 }, { 101.1189923, 30.599444, 222.9725 }, { -67.6856209, 42.681324, 268.7809 }, { 24.9079067, 43.836462, 316.7998 }, { 22.5811241, 47.439436, 319.6024 }, { -21.1648355, 63.219948, 143.8050 }, { -15.6549876, 64.230478, 172.7351 }, { 15.3936813, 1.010530, 28.9300 }, { 14.6660938, 7.437771, 123.5968 }, { -11.7273029, 55.782177, 20.2082 }, { 10.2742696, .373813, 40.8226 }, { 6.4914588, 13.218362, 123.4722 }, { 5.8539148, 62.583231, 155.6977 }, { -5.4872205, 63.593761, 184.6277 }, { -5.4290191, 76.438310, 267.2772 }, { 5.1609570, 45.815258, 55.0196 }, { 5.0786314, 8.448301, 152.5268 }, { -4.0735782, 56.792707, 49.1382 }, { 3.7227167, 49.747842, 204.6609 }, { 3.3971932, 12.058272, 56.5233 }, { -2.8347004, 75.278220, 200.3284 }, { -2.6550721, 65.241008, 201.6651 }, { -2.5717867, 64.604291, 213.5577 }, { -2.4712188, 1.647247, 17.0374 }, { 2.4625410, 7.811584, 164.4194 }, { 2.2464112, 12.207832, 94.5422 }, { -2.0755511, 63.856665, 131.9124 }, { -1.9713669, 56.155990, 61.0309 }, { -1.8813061, 77.448840, 296.2073 }, { -1.8468785, 6.801054, 135.4894 }, { 1.8186742, 62.209418, 114.8750 }, { 1.7601888, 20.656133, 247.0691 }, { -1.5428851, 48.344406, 256.6114 }, { 1.4738838, 55.145460, 32.1008 }, { -1.4593669, 69.000539, 143.6804 }, { 1.4192259, 11.071350, 16.8784 }, { -1.1818980, 74.291298, 160.6835 }, { 1.1756474, 11.047742, 27.5932 }, { -1.1316126, 0.636717, 348.1074 }, { 1.0896928, 12.844549, 82.6496 } }; // Table 4 (1). Fundamental elements of the ecliptic: ECCEN sin(pi) const double TABLE4[19][3] = { { .01860798, 4.207205, 28.620089 }, { .01627522, 7.346091, 193.788772 }, { -.01300660, 17.857263, 308.307024 }, { .00988829, 17.220546, 320.199637 }, { -.00336700, 16.846733, 279.376984 }, { .00333077, 5.199079, 87.195000 }, { -.00235400, 18.231076, 349.129677 }, { .00140015, 26.216758, 128.443387 }, { .00100700, 6.359169, 154.143880 }, { .00085700, 16.210016, 291.269597 }, { .00064990, 3.065181, 114.860583 }, { .00059900, 16.583829, 332.092251 }, { .00037800, 18.493980, 296.414411 }, { -.00033700, 6.190953, 145.769910 }, { .00027600, 18.867793, 337.237063 }, { .00018200, 17.425567, 152.092288 }, { -.00017400, 6.186001, 126.839891 }, { -.00012400, 18.417441, 210.667199 }, { .00001250, 0.667863, 72.108838 } }; // Table 5 (3). General precession in longitude: psi const double TABLE5[78][3] = { { 7391.0225890, 31.609974, 251.9025 }, { 2555.1526947, 32.620504, 280.8325 }, { 2022.7629188, 24.172203, 128.3057 }, { -1973.6517951, 0.636717, 348.1074 }, { 1240.2321818, 31.983787, 292.7252 }, { 953.8679112, 3.138886, 165.1686 }, { -931.7537108, 30.973257, 263.7951 }, { 872.3795383, 44.828336, 15.3747 }, { 606.3544732, 0.991874, 58.5749 }, { -496.0274038, 0.373813, 40.8226 }, { 456.9608039, 43.668246, 308.4258 }, { 346.9462320, 32.246691, 240.0099 }, { -305.8412902, 30.599444, 222.9725 }, { 249.6173246, 2.147012, 106.5937 }, { -199.1027200, 10.511172, 114.5182 }, { 191.0560889, 42.681324, 268.7809 }, { -175.2936572, 13.650058, 279.6869 }, { 165.9068833, 0.986922, 39.6448 }, { 161.1285917, 9.874455, 126.4108 }, { 139.7878093, 13.013341, 291.5795 }, { -133.5228399, 0.262904, 307.2848 }, { 117.0673811, 0.004952, 18.9300 }, { 104.6907281, 1.142024, 273.7596 }, { 95.3227476, 63.219948, 143.8050 }, { 86.7824524, 0.205021, 191.8927 }, { 86.0857729, 2.151964, 125.5237 }, { 70.5893698, 64.230478, 172.7351 }, { -69.9719343, 43.836462, 316.7998 }, { -62.5817473, 47.439436, 319.6024 }, { 61.5450059, 1.384343, 69.7526 }, { -57.9364011, 7.437771, 123.5968 }, { 57.1899832, 18.829299, 217.6432 }, { -57.0236109, 9.500642, 85.5882 }, { -54.2119253, 0.431696, 156.2147 }, { 53.2834147, 1.160090, 66.9489 }, { 52.1223575, 55.782177, 20.2082 }, { -49.0059908, 12.639528, 250.7568 }, { -48.3118757, 1.155138, 48.0188 }, { -45.4191685, 0.168216, 8.3739 }, { -42.2357920, 1.647247, 17.0374 }, { -34.7971099, 10.884985, 155.3409 }, { 34.4623613, 5.610937, 94.1709 }, { -33.8356643, 12.658184, 221.1120 }, { 33.6689362, 1.010530, 28.9300 }, { -31.2521586, 1.983748, 117.1498 }, { -30.8798701, 14.023871, 320.5095 }, { 28.4640769, 0.560178, 262.3602 }, { -27.1960802, 1.273434, 336.2148 }, { 27.0860736, 12.021467, 233.0046 }, { -26.3437456, 62.583231, 155.6977 }, { 24.7253740, 63.593761, 184.6277 }, { 24.6732126, 76.438310, 267.2772 }, { 24.4272733, 4.280910, 78.9281 }, { 24.0127327, 13.218362, 123.4722 }, { 21.7150294, 17.818769, 188.7132 }, { -21.5375347, 8.359495, 180.1364 }, { 18.1148363, 56.792707, 49.1382 }, { -16.9603104, 8.448301, 152.5268 }, { -16.1765215, 1.978796, 98.2198 }, { 15.5567653, 8.863925, 97.4808 }, { 15.4846529, 0.186365, 221.5376 }, { 15.2150632, 8.996212, 168.2438 }, { 14.5047426, 6.771027, 161.1199 }, { -14.3873316, 45.815258, 55.0196 }, { 13.1351419, 12.002811, 262.6495 }, { 12.8776311, 75.278220, 200.3284 }, { 11.9867234, 65.241008, 201.6651 }, { 11.9385578, 18.870667, 294.6547 }, { 11.7030822, 22.009553, 99.8233 }, { 11.6018181, 64.604291, 213.5577 }, { -11.2617293, 11.498094, 154.1631 }, { -10.4664199, 0.578834, 232.7153 }, { 10.4333970, 9.237738, 138.3034 }, { -10.2377466, 49.747842, 204.6609 }, { 10.1934446, 2.147012, 106.5938 }, { -10.1280191, 1.196895, 250.4676 }, { 10.0289441, 2.133898, 332.3345 }, { -10.0034259, 0.173168, 27.3039 } }; int YM1950 = YEAR - 1950; int i; double ARG; //----------------------------------------------------- // Obliquity from Table 1 (2): // OBLIQ# = 23.320556 (degrees) Equation 5.5 (15) // OBLIQD = OBLIQ# + sum[A cos(ft+delta)] Equation 1 (5) double SUMC = 0; for(i=0; i<47; i++) // Do 110 I=1,47 { ARG = M_DEG_TO_RAD * (YM1950 * TABLE1[i][1] / 3600 + TABLE1[i][2]); SUMC = SUMC + TABLE1[i][0] * cos(ARG); } // OBLIQD = 23.320556 + SUMC / 3600; OBLIQ = M_DEG_TO_RAD * (23.320556 + SUMC / 3600); //----------------------------------------------------- // Eccentricity from Table 4 (1): // ECCEN sin(pi) = sum[M sin(gt+beta)] Equation 4 (1) // ECCEN cos(pi) = sum[M cos(gt+beta)] Equation 4 (1) // ECCEN = ECCEN sqrt[sin(pi)^2 + cos(pi)^2] double ESINPI = 0; double ECOSPI = 0; for(i=0; i<19; i++) // Do 210 I=1,19 { ARG = M_DEG_TO_RAD * (YM1950 * TABLE4[i][1] / 3600 + TABLE4[i][2]); ESINPI = ESINPI + TABLE4[i][0] * sin(ARG); ECOSPI = ECOSPI + TABLE4[i][0] * cos(ARG); } ECCEN = sqrt(ESINPI*ESINPI + ECOSPI*ECOSPI); //----------------------------------------------------- // Perihelion from Equation 4,6,7 (9) and Table 4,5 (1,3): // PSI# = 50.439273 (seconds of degree) Equation 7.5 (16) // ZETA = 3.392506 (degrees) Equation 7.5 (17) // PSI = PSI# t + ZETA + sum[F sin(ft+delta)] Equation 7 (9) // PIE = atan[ECCEN sin(pi) / ECCEN cos(pi)] // OMEGVP = PIE + PSI + 3.14159 Equation 6 (4.5) double PIE = atan2(ESINPI, ECOSPI); double FSINFD = 0; for(i=0; i<78; i++) // Do 310 I=1,78 { ARG = M_DEG_TO_RAD * (YM1950 * TABLE5[i][1] / 3600 + TABLE5[i][2]); FSINFD = FSINFD + TABLE5[i][0] * sin(ARG); } double PSI = M_DEG_TO_RAD*(3.392506 + (YM1950 * 50.439273 + FSINFD) / 3600); OMEGVP = fmod(PIE + PSI + .5 * M_PI_360, M_PI_360); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // ORBIT receives orbital parameters and time of year, and returns // distance from Sun, declination angle, and Sun's overhead position. // Reference for following calculations is: V.M.Blanco and // S.W.McCuskey, 1961, "Basic Physics of the Solar System", pages // 135 - 151. Existence of Moon and heavenly bodies other than // Earth and Sun are ignored. Earth is assumed to be spherical. // // Program author: Gary L. Russell 2008/09/22 // Angles, longitude and latitude are measured in radians. // // Input: ECCEN = eccentricity of the orbital ellipse // OBLIQ = latitude of Tropic of Cancer // OMEGVP = longitude of perihelion (sometimes Pi is added) = // = spatial angle from vernal equinox to perihelion // with Sun as angle vertex // DAY = days measured since 2000 January 1, hour 0 // // Constants: EDAYzY = tropical year = Earth days per year = 365.2425 // VE2000 = days from 2000 January 1, hour 0 until vernal // equinox of year 2000 = 31 + 29 + 19 + 7.5/24 // // Intermediate quantities: // BSEMI = semi minor axis in units of semi major axis // PERIHE = perihelion in days since 2000 January 1, hour 0 // in its annual revolution about Sun // TA = true anomaly = spatial angle from perihelion to // current location with Sun as angle vertex // EA = eccentric anomaly = spatial angle measured along // eccentric circle (that circumscribes Earth's orbit) // from perihelion to point above (or below) Earth's // absisca (where absisca is directed from center of // eccentric circle to perihelion) // MA = mean anomaly = temporal angle from perihelion to // current time in units of 2*Pi per tropical year // TAofVE = TA(VE) = true anomaly of vernal equinox = - OMEGVP // EAofVE = EA(VE) = eccentric anomaly of vernal equinox // MAofVE = MA(VE) = mean anomaly of vernal equinox // SLNORO = longitude of Sun in Earth's nonrotating reference frame // VEQLON = longitude of Greenwich Meridion in Earth's nonrotating // reference frame at vernal equinox // ROTATE = change in longitude in Earth's nonrotating reference // frame from point's location on vernal equinox to its // current location where point is fixed on rotating Earth // SLMEAN = longitude of fictitious mean Sun in Earth's rotating // reference frame (normal longitude and latitude) // // Output: SIND = sin(SUNLAT) = sine of declination angle // COSD = cos(SUNLAT) = cosine of the declination angle // SUNDIS = distance to Sun in units of semi major axis // SUNLON = longitude of point on Earth directly beneath Sun // SUNLAT = latitude of point on Earth directly beneath Sun // EQTIME = Equation of Time = // = longitude of fictitious mean Sun minus SUNLON // // From the above reference: // (4-54): [1 - ECCEN*cos(EA)]*[1 + ECCEN*cos(TA)] = (1 - ECCEN^2) // (4-55): tan(TA/2) = sqrt[(1+ECCEN)/(1-ECCEN)]*tan(EA/2) // Yield: tan(EA) = sin(TA)*sqrt(1-ECCEN^2) / [cos(TA) + ECCEN] // or: tan(TA) = sin(EA)*sqrt(1-ECCEN^2) / [cos(EA) - ECCEN] // //--------------------------------------------------------- bool CSG_Solar_Position::Get_Orbital_Position(double DAY, double &SIND, double &COSD, double &SUNDIS, double &SUNLON, double &SUNLAT, double &EQTIME) { const double EDAYzY = 365.2425; const double VE2000 = 79.3125; double ECCEN = m_Eccentricity; double OBLIQ = m_Obliquity; double OMEGVP = m_Perihelion; //----------------------------------------------------- // Determine EAofVE from geometry: tan(EA) = b*sin(TA) / [e+cos(TA)] // Determine MAofVE from Kepler's equation: MA = EA - e*sin(EA) // Determine MA knowing time from vernal equinox to current day double BSEMI, TAofVE, EAofVE, MAofVE, MA; BSEMI = sqrt(1.0 - ECCEN*ECCEN); TAofVE = -OMEGVP; EAofVE = atan2(BSEMI*sin(TAofVE), ECCEN+cos(TAofVE)); MAofVE = EAofVE - ECCEN*sin(EAofVE); // PERIHE = VE2000 - MAofVE*EDAYzY/M_PI_360 MA = fmod(M_PI_360*(DAY-VE2000)/EDAYzY + MAofVE, M_PI_360); //----------------------------------------------------- // Numerically invert Kepler's equation: MA = EA - e*sin(EA) double dEA, EA = MA + ECCEN*(sin(MA) + ECCEN*sin(2*MA)/2); do { EA += (dEA = (MA - EA + ECCEN * sin(EA)) / (1.0 - ECCEN * cos(EA))); } while( fabs(dEA) > 0.1 ); // 1.0e-10 ); // 1d-10 ); //----------------------------------------------------- // Calculate distance to Sun and true anomaly SUNDIS = 1.0 - ECCEN * cos(EA); double TA = atan2(BSEMI * sin(EA), cos(EA) - ECCEN); //----------------------------------------------------- // Change reference frame to be nonrotating reference frame, angles // fixed according to stars, with Earth at center and positive x // axis be ray from Earth to Sun were Earth at vernal equinox, and // x-y plane be Earth's equatorial plane. Distance from current Sun // to this x axis is SUNDIS sin(TA-TAofVE). At vernal equinox, Sun // is located at (SUNDIS,0,0). At other times, Sun is located at: // // SUN = (SUNDIS cos(TA-TAofVE), // SUNDIS sin(TA-TAofVE) cos(OBLIQ), // SUNDIS sin(TA-TAofVE) sin(OBLIQ)) double SUNX, SUNY, SLNORO; SIND = sin(TA - TAofVE) * sin(OBLIQ); COSD = sqrt(1 - SIND*SIND); SUNX = cos(TA - TAofVE); SUNY = sin(TA - TAofVE) * cos(OBLIQ); SLNORO = atan2(SUNY, SUNX); //----------------------------------------------------- // Determine Sun location in Earth's rotating reference frame // (normal longitude and latitude) double VEQLON, ROTATE; VEQLON = M_PI_360 * VE2000 - M_PI_180 + MAofVE - TAofVE; // ! modulo 2*Pi; ROTATE = M_PI_360 * (DAY-VE2000)*(EDAYzY+1)/EDAYzY; SUNLON = fmod(SLNORO - ROTATE - VEQLON, M_PI_360); if( SUNLON > M_PI_180 ) SUNLON = SUNLON - M_PI_360; SUNLAT = asin(sin(TA - TAofVE) * sin(OBLIQ)); //----------------------------------------------------- // Determine longitude of fictitious mean Sun // Calculate Equation of Time double SLMEAN; SLMEAN = M_PI_180 - M_PI_360*(DAY - floor(DAY)); EQTIME = fmod(SLMEAN - SUNLON, M_PI_360); if( EQTIME > M_PI_180 ) EQTIME = EQTIME - M_PI_360; //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // COSZIJ calculates the daily average cosine of the zenith angle // weighted by time and weighted by sunlight. // // Input: RLAT = latitude (degrees) // SIND,COSD = sine and cosine of the declination angle // // Output: COSZT = sum(cosZ*dT) / sum(dT) // COSZS = sum(cosZ*cosZ*dT) / sum(cosZ*dT) // // Intern: DAWN = time of DAWN (temporal radians) at mean local time // DUSK = time of DUSK (temporal radians) at mean local time // //--------------------------------------------------------- bool CSG_Solar_Position::Get_CosZenith(double RLAT, double SIND, double COSD, double &COSZT, double &COSZS) { if( 0 ) // bDegree { RLAT *= M_DEG_TO_RAD; } double SINJ = sin(RLAT); double COSJ = cos(RLAT); double SJSD = SINJ*SIND; double CJCD = COSJ*COSD; if( SJSD+CJCD <= 0.0 ) { // Constant nighttime at this latitude // DAWN = 999999; // DUSK = 999999; COSZT = 0.0; COSZS = 0.0; } else if( SJSD-CJCD >= 0.0 ) { // Constant daylight at this latitude double ECOSZ, QCOSZ; // DAWN = -999999; // DUSK = -999999; ECOSZ = SJSD*M_PI_360; QCOSZ = SJSD*ECOSZ + .5*CJCD*CJCD*M_PI_360; COSZT = SJSD; // ! = ECOSZ/M_PI_360 COSZS = QCOSZ/ECOSZ; } else { // Compute DAWN and DUSK (at local time) and their sines double CDUSK, DUSK, SDUSK, S2DUSK; CDUSK = -SJSD/CJCD; DUSK = acos(CDUSK); SDUSK = sqrt(CJCD*CJCD-SJSD*SJSD) / CJCD; S2DUSK = 2*SDUSK*CDUSK; // DAWN = -DUSK; // SDAWN = -SDUSK; // S2DAWN = -S2DUSK; // Nighttime at initial and final times with daylight in between double ECOSZ, QCOSZ; ECOSZ = SJSD*(2*DUSK) + CJCD*(2*SDUSK); QCOSZ = SJSD*ECOSZ + CJCD*(SJSD*(2*SDUSK) + .5*CJCD*(2*DUSK + .5*(2*S2DUSK))); COSZT = ECOSZ/M_PI_360; COSZS = QCOSZ/ECOSZ; } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// #define DESC_SOURCE "Orbital parameters used here are based on the work of Andre L. Berger "\ "and its implementation from the NASA Goddard Institute for Space Studies (GISS). "\ "Berger's orbital parameters are considered to be valid for approximately 1 million years.\n"\ "References:\n"\ "- Berger, A.L. (1978): Long Term Variations of Daily Insolation and Quaternary Climatic Changes. Journal of the Atmospheric Sciences, volume 35(12), 2362-2367.\n"\ "- Berger, A.L. (1978): A Simple Algorithm to Compute Long Term Variations of Daily or Monthly Insolation. Institut d'Astronomie et de Geophysique, Universite Catholique de Louvain, Louvain-la-Neuve, No. 18.\n"\ "- NASA/GISS' implementation can be found as part of an Atmosphere-Ocean Model at "\ "Determination of the Earth's Orbital Parameters" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMilankovic::CMilankovic(void) { //----------------------------------------------------- Set_Name (_TL("Earth's Orbital Parameters")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( DESC_SOURCE )); //----------------------------------------------------- Parameters.Add_Table( NULL, "ORBPAR" , _TL("Earth's Orbital Parameters"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL, "START" , _TL("Start [ka]"), _TL(""), PARAMETER_TYPE_Double, -200 ); Parameters.Add_Value( NULL, "STOP" , _TL("Stop [ka]"), _TL(""), PARAMETER_TYPE_Double, 2 ); Parameters.Add_Value( NULL, "STEP" , _TL("Step [ka]"), _TL(""), PARAMETER_TYPE_Double, 1, 0.001, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMilankovic::On_Execute(void) { //----------------------------------------------------- int Start = (int)(Parameters("START")->asDouble() * 1000.0); int Stop = (int)(Parameters("STOP" )->asDouble() * 1000.0); int Step = (int)(Parameters("STEP" )->asDouble() * 1000.0); CSG_Table *pOrbit = Parameters("ORBPAR")->asTable(); pOrbit->Destroy(); pOrbit->Set_Name(_TL("Earth's Orbital Parameters")); pOrbit->Set_NoData_Value(-9999999); pOrbit->Add_Field(_TL("Year") , SG_DATATYPE_Int); pOrbit->Add_Field(_TL("Eccentricity") , SG_DATATYPE_Double); pOrbit->Add_Field(_TL("Obliquity") , SG_DATATYPE_Double); pOrbit->Add_Field(_TL("Perihelion") , SG_DATATYPE_Double); pOrbit->Add_Field(_TL("Climatic Precession"), SG_DATATYPE_Double); //----------------------------------------------------- for(int year=Start; year<=Stop && Set_Progress(year - Start, Stop - Start); year+=Step) { double eccentricity, obliquity, perihelion; if( CSG_Solar_Position::Get_Orbital_Parameters(year, eccentricity, obliquity, perihelion) ) { CSG_Table_Record *pRecord = pOrbit->Add_Record(); pRecord->Set_Value(0, year); pRecord->Set_Value(1, eccentricity); pRecord->Set_Value(2, obliquity); pRecord->Set_Value(3, perihelion); pRecord->Set_Value(4, -eccentricity * sin(perihelion)); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMilankovic_SR_Location::CMilankovic_SR_Location(void) { //----------------------------------------------------- Set_Name (_TL("Annual Course of Daily Insolation")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( DESC_SOURCE )); //----------------------------------------------------- Parameters.Add_Table( NULL , "SOLARRAD" , _TL("Solar Radiation"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "START" , _TL("Start [ka]"), _TL(""), PARAMETER_TYPE_Double, -200 ); Parameters.Add_Value( NULL , "STOP" , _TL("Stop [ka]"), _TL(""), PARAMETER_TYPE_Double, 2 ); Parameters.Add_Value( NULL , "STEP" , _TL("Step [ka]"), _TL(""), PARAMETER_TYPE_Double, 1, 0.001, true ); Parameters.Add_Value( NULL , "LAT" , _TL("Latitude [Degree]"), _TL(""), PARAMETER_TYPE_Double, 53.0, -90.0, true, 90.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMilankovic_SR_Location::On_Execute(void) { //----------------------------------------------------- int Start = (int)(Parameters("START")->asDouble() * 1000.0); int Stop = (int)(Parameters("STOP" )->asDouble() * 1000.0); int Step = (int)(Parameters("STEP" )->asDouble() * 1000.0); double Lat = Parameters("LAT")->asDouble() * M_DEG_TO_RAD; CSG_Table *pRadiation = Parameters("SOLARRAD")->asTable(); pRadiation->Destroy(); pRadiation->Set_Name(_TL("Annual Course of Daily Insolation")); pRadiation->Set_NoData_Value(-9999999); pRadiation->Add_Field(_TL("Day") , SG_DATATYPE_Int); pRadiation->Add_Field(_TL("Zenith") , SG_DATATYPE_Double); pRadiation->Add_Field(_TL("Culmination"), SG_DATATYPE_Double); pRadiation->Add_Field(_TL("Radiation") , SG_DATATYPE_Double); //----------------------------------------------------- for(int year=Start; year<=Stop && Set_Progress(year - Start, Stop - Start); year+=Step) { Process_Set_Text(CSG_String::Format(SG_T("%s: %d"), _TL("Year"), year)); CSG_Solar_Position Position(year); pRadiation->Del_Records(); for(int day=1; day<=365 && Process_Get_Okay(); day++) { if( Position.Set_Day(day) ) { CSG_Table_Record *pRecord = pRadiation->Add_Record(); pRecord->Set_Value(0, day); pRecord->Set_Value(1, Position.Get_Zenith() * M_RAD_TO_DEG); pRecord->Set_Value(2, 90 - fabs(Lat - Position.Get_Zenith()) * M_RAD_TO_DEG); pRecord->Set_Value(3, Position.Get_Daily_Radiation(Lat)); } } DataObject_Update(pRadiation); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMilankovic_SR_Day_Location::CMilankovic_SR_Day_Location(void) { //----------------------------------------------------- Set_Name (_TL("Daily Insolation over Latitude")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( DESC_SOURCE )); //----------------------------------------------------- Parameters.Add_Table( NULL , "SOLARRAD" , _TL("Solar Radiation"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "START" , _TL("Start [ka]"), _TL(""), PARAMETER_TYPE_Double, -200 ); Parameters.Add_Value( NULL , "STOP" , _TL("Stop [ka]"), _TL(""), PARAMETER_TYPE_Double, 2 ); Parameters.Add_Value( NULL , "STEP" , _TL("Step [ka]"), _TL(""), PARAMETER_TYPE_Double, 1, 0.001, true ); Parameters.Add_Value( NULL , "DLAT" , _TL("Latitude Increment [Degree]"), _TL(""), PARAMETER_TYPE_Int, 5, 1, true, 90, true ); Parameters.Add_Value( NULL , "DAY" , _TL("Day of Year"), _TL(""), PARAMETER_TYPE_Int, 181, 0, true, 366, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMilankovic_SR_Day_Location::On_Execute(void) { int iLat, nLat; //----------------------------------------------------- int Start = (int)(Parameters("START")->asDouble() * 1000.0); int Stop = (int)(Parameters("STOP" )->asDouble() * 1000.0); int Step = (int)(Parameters("STEP" )->asDouble() * 1000.0); int Day = Parameters("DAY")->asInt(); double dLat = Parameters("DLAT")->asDouble() * M_DEG_TO_RAD; CSG_Table *pRadiation = Parameters("SOLARRAD")->asTable(); pRadiation->Destroy(); pRadiation->Set_NoData_Value(-9999999); pRadiation->Add_Field(_TL("Year") , SG_DATATYPE_Int); nLat = (int)(M_PI_180 / dLat); for(iLat=0; iLat<=nLat; iLat++) { pRadiation->Add_Field(CSG_String::Format(SG_T("LAT_%.1f"), -90.0 + iLat * M_RAD_TO_DEG * dLat), SG_DATATYPE_Double); } //----------------------------------------------------- for(int year=Start; year<=Stop && Set_Progress(year - Start, Stop - Start); year+=Step) { Process_Set_Text(CSG_String::Format(SG_T("%s: %d"), _TL("Year"), year)); CSG_Solar_Position Position(year); double sinDec, cosDec, Distance, SunLon, SunLat, EqTime, cosZT, cosZS; if( Position.Get_Orbital_Position(Day, sinDec, cosDec, Distance, SunLon, SunLat, EqTime) ) { CSG_Table_Record *pRecord = pRadiation->Add_Record(); pRecord->Set_Value(0, year); for(iLat=0; iLat<=nLat; iLat++) { Position.Get_CosZenith(-M_PI_090 + iLat * dLat, sinDec, cosDec, cosZT, cosZS); pRecord->Set_Value(1 + iLat, 1367 * cosZT / (Distance*Distance)); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMilankovic_SR_Monthly_Global::CMilankovic_SR_Monthly_Global(void) { //----------------------------------------------------- Set_Name (_TL("Monthly Global by Latitude")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( DESC_SOURCE )); //----------------------------------------------------- Parameters.Add_Table( NULL , "SOLARRAD" , _TL("Solar Radiation"), _TL(""), PARAMETER_OUTPUT ); CSG_Parameter *pNode = Parameters.Add_Table( NULL , "ALBEDO" , _TL("Albedo"), _TL(""), PARAMETER_INPUT_OPTIONAL ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Field"), _TL("") ); Parameters.Add_Value( NULL , "YEAR" , _TL("Year [ka]"), _TL(""), PARAMETER_TYPE_Double, 2 ); Parameters.Add_Value( NULL , "DLAT" , _TL("Latitude Increment [Degree]"), _TL(""), PARAMETER_TYPE_Int, 5, 1, true, 90, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CMilankovic_SR_Monthly_Global::On_Execute(void) { const int nDays[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; const char *Month[12] = { "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" }; int iMonth, iDay, aDay, bDay, iLat, Lat; //----------------------------------------------------- int Year = (int)(Parameters("YEAR")->asDouble() * 1000.0); int dLat = Parameters("DLAT")->asInt(); CSG_Matrix SR(12, 181); CSG_Vector SRYear(181), SRGlobal(12), Area(181); // , Albedo(181); //----------------------------------------------------- CSG_Table *pAlbedo = Parameters("ALBEDO")->asTable(); int fAlbedo = Parameters("FIELD") ->asInt(); if( pAlbedo && pAlbedo->Get_Record_Count() != 181 ) { Message_Add(_TL("warning: albedo is ignored")); pAlbedo = NULL; } //----------------------------------------------------- for(iLat=0, Lat=-90; iLat<=180; iLat++, Lat++) { double LATN = iLat == 180 ? M_PI / 2.0 : (Lat + 0.5) * M_DEG_TO_RAD; double LATS = iLat == 0 ? -M_PI / 2.0 : (Lat - 0.5) * M_DEG_TO_RAD; Area[iLat] = 0.5 * (sin(LATN) - sin(LATS)); } //----------------------------------------------------- CSG_Solar_Position Position(Year); for(iMonth=0, bDay=1; iMonth<12; iMonth++) { aDay = bDay; bDay += nDays[iMonth]; for(iDay=aDay; iDayGet_Record(iLat)->asDouble(fAlbedo)); } SR[iLat][iMonth] += s; } } for(iLat=0; iLat<=180; iLat++) { SR[iLat][iMonth] /= nDays[iMonth]; SRGlobal[iMonth] += SR[iLat][iMonth] * Area[iLat]; SRYear[iLat] += SR[iLat][iMonth]; } } //----------------------------------------------------- CSG_Table *pRadiation = Parameters("SOLARRAD")->asTable(); CSG_Table_Record *pRecord; pRadiation->Destroy(); pRadiation->Set_Name(CSG_String::Format(SG_T("%s [%d]"), _TL("Global Irradiation"), Year)); pRadiation->Set_NoData_Value(-9999999); pRadiation->Add_Field(_TL("Lat"), SG_DATATYPE_String); for(iMonth=0; iMonth<12; iMonth++) { pRadiation->Add_Field(Month[iMonth], SG_DATATYPE_Double); } pRadiation->Add_Field(_TL("Annual"), SG_DATATYPE_Double); for(iLat=0, Lat=-90; iLat<=180; iLat+=dLat, Lat+=dLat) { pRecord = pRadiation->Add_Record(); pRecord->Set_Value(0, Lat); for(iMonth=0; iMonth<12; iMonth++) { pRecord->Set_Value(1 + iMonth, SR[iLat][iMonth]); } pRecord->Set_Value(1 + 12, SRYear[iLat] / 12.0); } pRecord = pRadiation->Add_Record(); pRecord->Set_Value(0, SG_T("global")); double SRGLAN = 0.0; for(iMonth=0; iMonth<12; iMonth++) { pRecord->Set_Value(1 + iMonth, SRGlobal[iMonth]); SRGLAN += SRGlobal[iMonth]; } pRecord->Set_Value(1 + 12, SRGLAN / 12.0); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/climate/climate_tools/MLB_Interface.h0000744000175000017500000000754112737416154025064 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__climate_tools_H #define HEADER_INCLUDED__climate_tools_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef climate_tools_EXPORTS #define climate_tools_EXPORT _SAGA_DLL_EXPORT #else #define climate_tools_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__climate_tools_H saga-2.3.1/src/modules/climate/climate_tools/daily_sun.h0000744000175000017500000001074212737416154024456 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: daily_sun.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // daily_sun.h // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__daily_sun_H #define HEADER_INCLUDED__daily_sun_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDaily_Sun : public CSG_Module_Grid { public: CDaily_Sun(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Tools") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__daily_sun_H saga-2.3.1/src/modules/climate/climate_tools/MLB_Interface.cpp0000744000175000017500000001217412737416154025415 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1383 2012-04-26 15:44:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Tools") ); case MLB_INFO_Category: return( _TL("Climate") ); case MLB_INFO_Author: return( SG_T("O.Conrad (c) 2012") ); case MLB_INFO_Description: return( _TL("Tools for weather and climate data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("Climate") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "grid_levels_interpolation.h" #include "milankovic.h" #include "etp_hargreave.h" #include "daily_sun.h" #include "bioclimatic_vars.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CGrid_Levels_to_Surface ); case 1: return( new CGrid_Levels_to_Points ); case 2: return( new CMilankovic ); case 3: return( new CMilankovic_SR_Location ); case 4: return( new CMilankovic_SR_Day_Location ); case 5: return( new CMilankovic_SR_Monthly_Global ); case 8: return( new CPET_Hargreave_Grid ); case 6: return( new CPET_Hargreave_Table ); case 7: return( new CPET_Day_To_Hour ); case 9: return( new CDaily_Sun ); case 10: return( new CBioclimatic_Vars ); //----------------------------------------------------- case 11: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/climate/Makefile.in0000664000175000017500000004653212737447614021541 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/climate ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ SUBDIRS = climate_tools all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/climate/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/climate/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/climate/Makefile.am0000744000175000017500000000003112737416154021502 0ustar00oconradoconrad00000000000000SUBDIRS = climate_tools saga-2.3.1/src/modules/io/0000775000175000017500000000000012737740006016442 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/io/io_esri_e00/0000775000175000017500000000000012737740005020536 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/io/io_esri_e00/e00compr/0000775000175000017500000000000012737740005022163 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/io/io_esri_e00/e00compr/cpl_vsisimple.c0000744000175000017500000002170212737416172025206 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_vsisimple.c 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_vsisimple.cpp * * This is a simple implementation (direct to Posix) of the Virtual System * Interface (VSI). See gdal_vsi.h. * * TODO: * - add some assertions to ensure that arguments are widely legal. For * instance validation of access strings to fopen(). * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.3 1998/12/14 04:50:33 warmerda * Avoid C++ comments so it will be C compilable as well. * * Revision 1.2 1998/12/04 21:42:57 danmo * Added #ifndef WIN32 arounf #include * * Revision 1.1 1998/12/03 18:26:03 warmerda * New * */ #include "cpl_vsi.h" /* for stat() */ #ifndef WIN32 # include #endif #include /************************************************************************/ /* VSIFOpen() */ /************************************************************************/ FILE *VSIFOpen( const char * pszFilename, const char * pszAccess ) { return( fopen( (char *) pszFilename, (char *) pszAccess ) ); } /************************************************************************/ /* VSIFClose() */ /************************************************************************/ int VSIFClose( FILE * fp ) { return( fclose(fp) ); } /************************************************************************/ /* VSIFSeek() */ /************************************************************************/ int VSIFSeek( FILE * fp, long nOffset, int nWhence ) { return( fseek( fp, nOffset, nWhence ) ); } /************************************************************************/ /* VSIFTell() */ /************************************************************************/ long VSIFTell( FILE * fp ) { return( ftell( fp ) ); } /************************************************************************/ /* VSIRewind() */ /************************************************************************/ void VSIRewind( FILE * fp ) { rewind( fp ); } /************************************************************************/ /* VSIFRead() */ /************************************************************************/ size_t VSIFRead( void * pBuffer, size_t nSize, size_t nCount, FILE * fp ) { return( fread( pBuffer, nSize, nCount, fp ) ); } /************************************************************************/ /* VSIFWrite() */ /************************************************************************/ size_t VSIFWrite( void * pBuffer, size_t nSize, size_t nCount, FILE * fp ) { return( fwrite( pBuffer, nSize, nCount, fp ) ); } /************************************************************************/ /* VSIFGets() */ /************************************************************************/ char *VSIFGets( char *pszBuffer, int nBufferSize, FILE * fp ) { return( fgets( pszBuffer, nBufferSize, fp ) ); } /************************************************************************/ /* VSIFGetc() */ /************************************************************************/ int VSIFGetc( FILE * fp ) { return( fgetc( fp ) ); } /************************************************************************/ /* VSIUngetc() */ /************************************************************************/ int VSIUngetc( int c, FILE * fp ) { return( ungetc( c, fp ) ); } /************************************************************************/ /* VSIFPrintf() */ /* */ /* This is a little more complicated than just calling */ /* fprintf() because of the variable arguments. Instead we */ /* have to use vfprintf(). */ /************************************************************************/ int VSIFPrintf( FILE * fp, const char * pszFormat, ... ) { va_list args; int nReturn; va_start( args, pszFormat ); nReturn = vfprintf( fp, pszFormat, args ); va_end( args ); return( nReturn ); } /************************************************************************/ /* VSIFEof() */ /************************************************************************/ int VSIFEof( FILE * fp ) { return( feof( fp ) ); } /************************************************************************/ /* VSIFPuts() */ /************************************************************************/ int VSIFPuts( const char * pszString, FILE * fp ) { return fputs( pszString, fp ); } /************************************************************************/ /* VSIFPutc() */ /************************************************************************/ int VSIFPutc( int nChar, FILE * fp ) { return( fputc( nChar, fp ) ); } /************************************************************************/ /* VSICalloc() */ /************************************************************************/ void *VSICalloc( size_t nCount, size_t nSize ) { return( calloc( nCount, nSize ) ); } /************************************************************************/ /* VSIMalloc() */ /************************************************************************/ void *VSIMalloc( size_t nSize ) { return( malloc( nSize ) ); } /************************************************************************/ /* VSIRealloc() */ /************************************************************************/ void * VSIRealloc( void * pData, size_t nNewSize ) { return( realloc( pData, nNewSize ) ); } /************************************************************************/ /* VSIFree() */ /************************************************************************/ void VSIFree( void * pData ) { if( pData != NULL ) free( pData ); } /************************************************************************/ /* VSIStrdup() */ /************************************************************************/ char *VSIStrdup( const char * pszString ) { return( strdup( pszString ) ); } /************************************************************************/ /* VSIStat() */ /************************************************************************/ int VSIStat( const char * pszFilename, VSIStatBuf * pStatBuf ) { return( stat( pszFilename, pStatBuf ) ); } saga-2.3.1/src/modules/io/io_esri_e00/e00compr/e00compr.h0000744000175000017500000001506512737416172023774 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: e00compr.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /********************************************************************** * $Id: e00compr.h 911 2011-02-14 16:38:15Z reklov_w $ * * Name: e00compr.h * Project: Compressed E00 Read/Write library * Language: ANSI C * Purpose: Header file containing all definitions for the library. * Author: Daniel Morissette, danmo@videotron.ca * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.7 1999/02/25 18:47:40 daniel * Now use CPL for Error handling, Memory allocation, and File access. * * Revision 1.6 1999/01/08 17:40:33 daniel * Added E00Read/WriteCallbakcOpen() * * Revision 1.5 1998/11/13 15:39:45 daniel * Added functions for write support. * * Revision 1.4 1998/11/02 18:37:03 daniel * New file header, and added E00ErrorReset() * * Revision 1.1 1998/10/29 13:26:00 daniel * Initial revision * ********************************************************************** * Copyright (c) 1998, 1999, Daniel Morissette * * All rights reserved. This software may be copied or reproduced, in * all or in part, without the prior written consent of its author, * Daniel Morissette (danmo@videotron.ca). However, any material copied * or reproduced must bear the original copyright notice (above), this * original paragraph, and the original disclaimer (below). * * The entire risk as to the results and performance of the software, * supporting text and other information contained in this file * (collectively called the "Software") is with the user. Although * considerable efforts have been used in preparing the Software, the * author does not warrant the accuracy or completeness of the Software. * In no event will the author be liable for damages, including loss of * profits or consequential damages, arising out of the use of the * Software. * **********************************************************************/ #ifndef _E00COMPR_H_INCLUDED_ #define _E00COMPR_H_INCLUDED_ #ifdef __cplusplus extern "C" { #endif #include #include "cpl_port.h" #include "cpl_conv.h" #include "cpl_error.h" /*===================================================================== Data types and constants =====================================================================*/ #define E00_READ_BUF_SIZE 256 /* E00 lines are always 80 chars or less */ /* for both compressed and uncompressed */ /* files, except the first line (the EXP)*/ /* for which there is no known limit */ /* We'll assume that it can't be longer */ /* than 256 chars */ #define E00_WRITE_BUF_SIZE 256 /* This buffer must be big enough to hold*/ /* at least 2 lines of compressed output */ /* (i.e. 160 chars)... but just in case */ /* compressing a line would ever result */ /* in it becoming bigger than its source */ /* we'll set the size to 256 chars! */ #define E00_COMPR_NONE 0 /* Compression levels to use when writing*/ #define E00_COMPR_PARTIAL 1 #define E00_COMPR_FULL 2 /*--------------------------------------------------------------------- * E00ReadPtr * * A E00ReadPtr handle is used to hold information about the compressed * file currently being read. *--------------------------------------------------------------------*/ struct _E00ReadInfo { FILE *fp; /* Input file handle */ int bEOF; /* Reached EOF? */ int bIsCompressed; /* 1 if file is compressed, 0 if not */ int nInputLineNo; int iInBufPtr; /* Last character processed in szInBuf */ char szInBuf[E00_READ_BUF_SIZE]; /* compressed input buffer */ char szOutBuf[E00_READ_BUF_SIZE];/* uncompressed output buffer */ /* pRefData, pfnReadNextLine() and pfnReadRewind() are used only * when the file is opened with E00ReadCallbackOpen() * (and in this case the FILE *fp defined above is not used) */ void * pRefData; const char * (*pfnReadNextLine)(void *); void (*pfnReadRewind)(void *); }; typedef struct _E00ReadInfo *E00ReadPtr; /*--------------------------------------------------------------------- * E00WritePtr * * A E00WritePtr handle is used to hold information about the * file currently being written. *--------------------------------------------------------------------*/ struct _E00WriteInfo { FILE *fp; /* Output file handle */ int nComprLevel; int nSrcLineNo; int iOutBufPtr; /* Current position in szOutBuf */ char szOutBuf[E00_WRITE_BUF_SIZE]; /* compressed output buffer */ /* pRefData and pfnWriteNextLine() are used only * when the file is opened with E00WriteCallbackOpen() * (and in this case the FILE *fp defined above is not used) */ void *pRefData; int (*pfnWriteNextLine)(void *, const char *); }; typedef struct _E00WriteInfo *E00WritePtr; /*===================================================================== Function prototypes =====================================================================*/ E00ReadPtr E00ReadOpen(const char *pszFname); E00ReadPtr E00ReadCallbackOpen(void *pRefData, const char * (*pfnReadNextLine)(void *), void (*pfnReadRewind)(void *)); void E00ReadClose(E00ReadPtr psInfo); const char *E00ReadNextLine(E00ReadPtr psInfo); void E00ReadRewind(E00ReadPtr psInfo); E00WritePtr E00WriteOpen(const char *pszFname, int nComprLevel); E00WritePtr E00WriteCallbackOpen(void *pRefData, int (*pfnWriteNextLine)(void *, const char *), int nComprLevel); void E00WriteClose(E00WritePtr psInfo); int E00WriteNextLine(E00WritePtr psInfo, const char *pszLine); #ifdef __cplusplus } #endif #endif /* _E00COMPR_H_INCLUDED_ */ saga-2.3.1/src/modules/io/io_esri_e00/e00compr/cpl_conv.h0000744000175000017500000000614712737416172024153 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_conv.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_conv.h * * Prototypes, and stuff for various convenience functions. This is intended * to remain light weight. * * $Log: * Revision 1.1 1998/10/18 06:15:11 warmerda * Initial implementation. * */ #ifndef CPL_CONV_H_INCLUDED #define CPL_CONV_H_INCLUDED #include "cpl_port.h" #include "cpl_vsi.h" #include "cpl_error.h" /* -------------------------------------------------------------------- */ /* Safe malloc() API. Thin cover over VSI functions with fatal */ /* error reporting if memory allocation fails. */ /* -------------------------------------------------------------------- */ CPL_C_START void CPL_DLL *CPLMalloc( size_t ); void CPL_DLL *CPLCalloc( size_t, size_t ); void CPL_DLL *CPLRealloc( void *, size_t ); char CPL_DLL *CPLStrdup( const char * ); #define CPLFree VSIFree /* -------------------------------------------------------------------- */ /* Read a line from a text file, and strip of CR/LF. */ /* -------------------------------------------------------------------- */ const char *CPLReadLine( FILE * ); /* -------------------------------------------------------------------- */ /* Fetch a function from DLL / so. */ /* -------------------------------------------------------------------- */ void CPL_DLL *CPLGetSymbol( const char *, const char * ); /* -------------------------------------------------------------------- */ /* Read a directory (cpl_dir.c) */ /* -------------------------------------------------------------------- */ char CPL_DLL **CPLReadDir( const char *pszPath ); CPL_C_END #endif /* ndef CPL_CONV_H_INCLUDED */ saga-2.3.1/src/modules/io/io_esri_e00/e00compr/cpl_vsi.h0000744000175000017500000001200412737416172023774 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_vsi.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_vsi.h * * Include file defining the Virtual System Interface (VSI) functions. This * should normally be included by all translators using VSI functions for * accessing system services. It is also used by the GDAL core, and can be * used by higher level applications which adhere to VSI use. * * Most VSI functions are direct analogs of Posix C library functions. * VSI exists to allow ``hooking'' these functions to provide application * specific checking, io redirection and so on. * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.4 1999/02/25 04:48:11 danmo * Added VSIStat() macros specific to _WIN32 (for MSVC++) * * Revision 1.3 1999/01/28 18:31:25 warmerda * Test on _WIN32 rather than WIN32. It seems to be more reliably defined. * * Revision 1.2 1998/12/04 21:42:57 danmo * Added #ifndef WIN32 arounf #include * * Revision 1.1 1998/12/03 18:26:02 warmerda * New * */ #ifndef CPL_VSI_H_INCLUDED #define CPL_VSI_H_INCLUDED #include "cpl_port.h" /* -------------------------------------------------------------------- */ /* We need access to ``struct stat''. */ /* -------------------------------------------------------------------- */ #ifndef _WIN32 # include #endif #include CPL_C_START /* ==================================================================== */ /* stdio file access functions. */ /* ==================================================================== */ FILE CPL_DLL * VSIFOpen( const char *, const char * ); int CPL_DLL VSIFClose( FILE * ); int CPL_DLL VSIFSeek( FILE *, long, int ); long CPL_DLL VSIFTell( FILE * ); void CPL_DLL VSIRewind( FILE * ); size_t CPL_DLL VSIFRead( void *, size_t, size_t, FILE * ); size_t CPL_DLL VSIFWrite( void *, size_t, size_t, FILE * ); char CPL_DLL *VSIFGets( char *, int, FILE * ); int CPL_DLL VSIFPuts( const char *, FILE * ); int CPL_DLL VSIFPrintf( FILE *, const char *, ... ); int CPL_DLL VSIFGetc( FILE * ); int CPL_DLL VSIFPutc( int, FILE * ); int CPL_DLL VSIUngetc( int, FILE * ); int CPL_DLL VSIFEof( FILE * ); /* ==================================================================== */ /* VSIStat() related. */ /* ==================================================================== */ typedef struct stat VSIStatBuf; int CPL_DLL VSIStat( const char *, VSIStatBuf * ); #ifdef _WIN32 # define VSI_ISLNK(x) ( 0 ) /* N/A on Windows */ # define VSI_ISREG(x) ((x) & S_IFREG) # define VSI_ISDIR(x) ((x) & S_IFDIR) # define VSI_ISCHR(x) ((x) & S_IFCHR) # define VSI_ISBLK(x) ( 0 ) /* N/A on Windows */ #else # define VSI_ISLNK(x) S_ISLNK(x) # define VSI_ISREG(x) S_ISREG(x) # define VSI_ISDIR(x) S_ISDIR(x) # define VSI_ISCHR(x) S_ISCHR(x) # define VSI_ISBLK(x) S_ISBLK(x) #endif /* ==================================================================== */ /* Memory allocation */ /* ==================================================================== */ void CPL_DLL *VSICalloc( size_t, size_t ); void CPL_DLL *VSIMalloc( size_t ); void CPL_DLL VSIFree( void * ); void CPL_DLL *VSIRealloc( void *, size_t ); char CPL_DLL *VSIStrdup( const char * ); CPL_C_END #endif /* ndef CPL_VSI_H_INCLUDED */ saga-2.3.1/src/modules/io/io_esri_e00/e00compr/e00write.c0000744000175000017500000005206412737416172024001 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: e00write.c 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /********************************************************************** * $Id: e00write.c 911 2011-02-14 16:38:15Z reklov_w $ * * Name: e00write.c * Project: Compressed E00 Read/Write library * Language: ANSI C * Purpose: Functions to write Compressed E00 files from a stream of * uncompressed lines. * Author: Daniel Morissette, danmo@videotron.ca * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.5 1999/02/25 18:46:41 daniel * Now use CPL for Error handling, Memory allocation, and File access. * * Revision 1.4 1999/01/08 17:40:01 daniel * Added E00WriteCallbackOpen() * * Revision 1.3 1998/11/13 16:54:23 daniel * Check for '\r' and '\n' at end of input line while compressing, just * in case... * * Revision 1.2 1998/11/13 15:48:42 daniel * Simplified the generation of the compression codes for numbers * (use a logical rule instead of going case by case) * * Revision 1.1 1998/11/13 14:19:51 daniel * Initial revision * ********************************************************************** * Copyright (c) 1998, 1999, Daniel Morissette * * All rights reserved. This software may be copied or reproduced, in * all or in part, without the prior written consent of its author, * Daniel Morissette (danmo@videotron.ca). However, any material copied * or reproduced must bear the original copyright notice (above), this * original paragraph, and the original disclaimer (below). * * The entire risk as to the results and performance of the software, * supporting text and other information contained in this file * (collectively called the "Software") is with the user. Although * considerable efforts have been used in preparing the Software, the * author does not warrant the accuracy or completeness of the Software. * In no event will the author be liable for damages, including loss of * profits or consequential damages, arising out of the use of the * Software. * **********************************************************************/ #include #include #include #include #include #include "e00compr.h" static int _CompressLine(E00WritePtr psInfo, const char *pszLine); static int _WriteNextCompressedLine(E00WritePtr psInfo, int nMaxChars); static int _PrintfNextLine(E00WritePtr psInfo, const char *pszFmt, ...); /********************************************************************** * E00WriteOpen() * * Try to open output file, and alloc/initialize a new E00WritePtr * handle. * * nComprLevel must be one of: * E00_COMPR_NONE, E00_COMPR_PARTIAL or E00_COMPR_FULL * * Returns the new handle, or NULL if the file could not be opened. * E00WriteClose() will eventually have to be called to release * the resources used by the new handle. **********************************************************************/ E00WritePtr E00WriteOpen(const char *pszFname, int nComprLevel) { E00WritePtr psInfo = NULL; FILE *fp; CPLErrorReset(); /* Open the file */ fp = VSIFOpen(pszFname, "wt"); if (fp == NULL) { CPLError(CE_Failure, CPLE_OpenFailed, "Failed to open %s: %s", pszFname, strerror(errno)); return NULL; } /* Allocate and initialize a E00ReadPtr handle. */ psInfo = (E00WritePtr)CPLCalloc(1, sizeof(struct _E00WriteInfo)); psInfo->fp = fp; psInfo->nComprLevel = nComprLevel; return psInfo; } /********************************************************************** * E00WriteCallbackOpen() * * This is an alternative to E00WriteOpen() for cases where you want to * do all the file management yourself. You open/close the file yourself * and provide a callback functions to write one line at a time to the * file. pRefData is your handle on the physical file and can * be whatever you want... it is not used by the library, it will be * passed directly to your callback function when it is called. * * The callback function must have the following C prototype: * * int myWriteNextLine(void *pRefData, const char *pszLine); * * Like printf() does, myWriteNextLine() should return a positive * value on success (the number of chars written) * or -1 if an error happened. * The value passed by the library in pszLine will not be terminated * by a '\n' character... it is assumed that the myWriteNextLine() * implementation will take care of terminating the line with a * '\n' if necessary. * * nComprLevel must be one of: * E00_COMPR_NONE, E00_COMPR_PARTIAL or E00_COMPR_FULL * * E00WriteCallbackOpen() returns a new E00ReadWritePtr handle. * E00WriteClose() will eventually have to be called to release * the resources used by the new handle. **********************************************************************/ E00WritePtr E00WriteCallbackOpen(void *pRefData, int (*pfnWriteNextLine)(void *, const char *), int nComprLevel) { E00WritePtr psInfo = NULL; CPLErrorReset(); /* Make sure we received a valid function pointer */ if (pfnWriteNextLine == NULL) { CPLError(CE_Failure, CPLE_IllegalArg, "Invalid function pointer!"); return NULL; } /* Allocate and initialize a E00ReadPtr handle. */ psInfo = (E00WritePtr)CPLCalloc(1, sizeof(struct _E00WriteInfo)); psInfo->pRefData = pRefData; psInfo->pfnWriteNextLine = pfnWriteNextLine; psInfo->nComprLevel = nComprLevel; return psInfo; } /********************************************************************** * E00WriteClose() * * Close output file and release any memory used by the E00WritePtr. **********************************************************************/ void E00WriteClose(E00WritePtr psInfo) { CPLErrorReset(); if (psInfo) { /* Flush output buffer before closing file. */ if (psInfo->iOutBufPtr > 0) _WriteNextCompressedLine(psInfo, 1); if (psInfo->fp) fclose(psInfo->fp); CPLFree(psInfo); } } /********************************************************************** * E00WriteNextLine() * * Take a line of what should be headed to a uncompressed E00 file, * convert it to the requested compression level, and write the * compressed result to the output file. * * Returns 0 if the line was processed succesfully, or an error number * (> 0) if an error happened. **********************************************************************/ int E00WriteNextLine(E00WritePtr psInfo, const char *pszLine) { char *pszPtr; int nStatus = 0; CPLErrorReset(); if (psInfo && (psInfo->fp || psInfo->pfnWriteNextLine)) { psInfo->nSrcLineNo++; if (psInfo->nComprLevel == E00_COMPR_NONE) { /* Uncompressed file... write line directly. */ nStatus = _PrintfNextLine(psInfo, "%s", pszLine); } else if (psInfo->nSrcLineNo == 1) { /* Header line in a compressed file... write line * after replacing "EXP 0" with "EXP 1". */ if ((pszPtr = strstr(pszLine, " 0")) != NULL) { nStatus = _PrintfNextLine(psInfo, "EXP 1%s", pszPtr+2); } else { /* Write line directly... assume that it contains a valid * EXP prefix! */ nStatus = _PrintfNextLine(psInfo, "%s", pszLine); } } else { /* FULL or PARTIAL compression... compress the current line, * (output goes in psInfo->szOutBuf) */ nStatus = _CompressLine(psInfo, pszLine); while (nStatus == 0 && psInfo->iOutBufPtr >= 80) { /* Time to write the first 80 chars from the output buffer */ nStatus = _WriteNextCompressedLine(psInfo, 0); } } } else { /* This should never happen unless the lib is not properly used * or if an error happened in previous calls and was ignored by * the caller */ CPLError(CE_Failure, CPLE_IllegalArg, "Invalid E00WritePtr handle!"); nStatus = 203; } return nStatus; } /********************************************************************** * _CompressLine() * * Compress one line of input, and store the compressed copy at the * end of psInfo->pszOutBuf. * * Returns 0 if the line was compressed succesfully, or an error number * (> 0) if an error happened. **********************************************************************/ static int _CompressLine(E00WritePtr psInfo, const char *pszLine) { int nStatus = 0; int nDigits, nExpSign, nDotPosition, iCurPos; int numTotalDigits, numExpDigits; char n, *pszCodePos; int nStartOutBufPtr; const char *pszStartSrcPtr; while(*pszLine != '\0' && *pszLine != '\n' && *pszLine != '\r') { /*------------------------------------------------------------- * By default, apply PARTIAL compression * Note that PARTIAL is a subset of FULL compression. *------------------------------------------------------------*/ if (*pszLine == '~') { /* The '~' char is encoded as "~~" */ strcpy( psInfo->szOutBuf+psInfo->iOutBufPtr, "~~"); psInfo->iOutBufPtr += 2; } else if (strncmp(pszLine, " ", 3) == 0) { /* A stream of at least 3 spaces. * Count number of spaces and replace with a "~ n" code */ n=1; while(*(pszLine+1) == ' ') { n++; pszLine++; } strcpy( psInfo->szOutBuf+psInfo->iOutBufPtr, "~ "); psInfo->iOutBufPtr += 2; psInfo->szOutBuf[psInfo->iOutBufPtr++] = ' ' + n; } /*------------------------------------------------------------- * The cases below are specific to FULL compression. *------------------------------------------------------------*/ else if (psInfo->nComprLevel == E00_COMPR_FULL && isdigit(*pszLine)) { /* Keep track of current input/output buffer positions in case * we would have to revert the encoding. This could happen if * the numeric value is less than 4 characters. */ nStartOutBufPtr = psInfo->iOutBufPtr; pszStartSrcPtr = pszLine; /* Reset flags used for parsing numeric format */ nDigits = 0; nDotPosition = 0; /* 0 means no decimal point */ nExpSign = 0; /* 0 means no exponent */ numExpDigits = 0; numTotalDigits = 0; n = 0; /* Prepare the code sequence in the output buffer. * The code value will be set only after the number * is finished parsing. */ psInfo->szOutBuf[psInfo->iOutBufPtr++] = '~'; pszCodePos = psInfo->szOutBuf+psInfo->iOutBufPtr++; /* Scan the numeric sequence, encoding the digits as we read, * and keeping track of decimal point position and exponent. */ for(iCurPos=0; *pszLine != '\0' && numExpDigits<2; pszLine++, iCurPos++) { if (isdigit(*pszLine)) { /* Accumulate pairs of digits */ numTotalDigits++; if (numTotalDigits % 2 == 1) { n = (*pszLine - '0')*10; } else { n += (*pszLine - '0'); if (n >= 92) { /* Pairs of digits > 92 are encoded on 2 chars */ psInfo->szOutBuf[psInfo->iOutBufPtr++] = 92 + '!'; n -= 92; } psInfo->szOutBuf[psInfo->iOutBufPtr++] = n + '!'; } /* Count number of exponent digits to end the loop * once we've read 2 exponent digits */ if (nExpSign != 0) numExpDigits++; } else if (*pszLine == '.' && nDotPosition == 0 && iCurPos < 15) { /* Decimal point position... make sure that we have only * one decimal point, and that it is not beyond the 14th * position. If these conditions are not met then end the * numeric sequence here. */ nDotPosition = iCurPos; } else if (*pszLine == 'E' && (*(pszLine+1) == '-' || *(pszLine+1)=='+') && isdigit(*(pszLine+2)) && isdigit(*(pszLine+3)) && !isdigit(*(pszLine+4)) ) { /* Exponent ... fetch sign, and read only 2 more digits * A "E+" or "E-" MUST be followed by 2 and only 2 digits. * If it's not the case, then the numeric sequence ends * here. */ pszLine++; nExpSign = (*pszLine=='-') ? -1: 1; } else { /* Numeric sequence finished ... stop parsing. */ break; } }/*for ... parsing numeric value*/ /* If the numeric value contains an even number of digits, * then pad the last pair of digits with a zero and encode it. */ if (numTotalDigits % 2 == 1) { psInfo->szOutBuf[psInfo->iOutBufPtr++] = n + '!'; } /* If the character that ends the number is NOT a '~', a ' ' * or a 'end of line' then add a '~' to mark the end of the * number. This extra '~' will be ignored by the uncompress * algorithm. */ if (*(pszLine) != '~' && *(pszLine) != ' ' && *(pszLine) != '\0') { psInfo->szOutBuf[psInfo->iOutBufPtr++] = '~'; } /* At the end of the loop, the read pointer is located on the char * that follows the numeric value. Move it back 1 char so that * processing can continue later with the outer loop. */ pszLine--; /* Check that the parsed value contains enough characters to * justify encoding it. The encoded value should not be * bigger than the original. If the encoded value is the same * size as the original then it is still encoded (a bit silly!). * All numbers < 4 chars are not encoded, and some, such as * "1092" won't either because it would require 5 chars to * encode them. * * If the value should not be encoded, then overwrite the sutff * we started encoding with a direct copy of the numeric value. * * (At this point, iCurPos is equal to the number of chars in the * source value.) */ if ( iCurPos < psInfo->iOutBufPtr - nStartOutBufPtr ) { strncpy(psInfo->szOutBuf+ nStartOutBufPtr, pszStartSrcPtr, iCurPos); psInfo->iOutBufPtr = nStartOutBufPtr + iCurPos; } else { /* Now that we have parsed the numeric value, set the code * based on the characteristics we found. */ *pszCodePos = '!' + ((numTotalDigits % 2 == 1)? 45:0) + (nExpSign?((nExpSign>0)?15:30):0) + nDotPosition; } } else { /* This char cannot be compressed ... output directly. */ psInfo->szOutBuf[psInfo->iOutBufPtr++] = *pszLine; } /* Check for buffer overflow... just in case!!! */ if (psInfo->iOutBufPtr >= E00_WRITE_BUF_SIZE) { /* The buffer size has been set big enough to prevent this error * from ever happening. So if it ever happens, then it's likely * that the input lines were longer than 80 chars, which is the * maximum length of a uncompressed line in a E00 file. */ CPLError(CE_Failure, CPLE_FileIO, "Output buffer overflow!!!."); nStatus = 205; break; } /* Get ready to proceed with next char from input string */ pszLine++; } /* Terminate this line with a newline code * This code applies to both PARTIAL and FULL compresion. */ strcpy( psInfo->szOutBuf+psInfo->iOutBufPtr, "~}"); psInfo->iOutBufPtr += 2; return nStatus; } /********************************************************************** * _WriteNextCompressedLine() * * If bFlushWholeBuffer == 0, write the first 80 characters from * psInfo->szOutBuf, and remove the written chars from szOutBuf. * A '\n' (not counted in nMaxChars) will be written to terminate the * output line. * * Pass bFlushBuffer == 1 to force writing the whole contents of szOutBuf * at once. * * Returns 0 if the line was written succesfully, or an error number * (> 0) if an error happened. **********************************************************************/ static int _WriteNextCompressedLine(E00WritePtr psInfo, int bFlushWholeBuffer) { int nStatus = 0, nToWrite; char *pszSrc, *pszDst; psInfo->szOutBuf[psInfo->iOutBufPtr] = '\0'; if (!bFlushWholeBuffer && psInfo->iOutBufPtr > 80) { /* Write the first 80 chars * Note that a compressed line cannot end with spaces... spaces should * be reported on the next line. */ nToWrite = 80; while(nToWrite > 1 && psInfo->szOutBuf[nToWrite-1] == ' ') nToWrite--; nStatus = _PrintfNextLine(psInfo, "%-.*s", nToWrite, psInfo->szOutBuf); /* Remove these chars from the output buffer */ pszDst = psInfo->szOutBuf; pszSrc = psInfo->szOutBuf+nToWrite; while(*pszSrc != '\0') { *pszDst = *pszSrc; pszDst++; pszSrc++; } psInfo->iOutBufPtr -= nToWrite; } else { /* Just write the buffer contents directly */ nStatus = _PrintfNextLine(psInfo, "%s", psInfo->szOutBuf); psInfo->iOutBufPtr = 0; } return nStatus; } /********************************************************************** * _PrintfNextLine() * * Cover function for fprintf() that will do error checking and * reporting, and either call fprintf() directly or call the callback * provided by the caller if E00WriteCallbackOpen() was used. * * A \n will be automatically appended to the string when it is * written, so no \n should be included at the end of pszFmt. * * Returns 0 on success, or error 204 if it failed. **********************************************************************/ static int _PrintfNextLine(E00WritePtr psInfo, const char *pszFmt, ...) { va_list args; static char szBuf[E00_WRITE_BUF_SIZE]; int nStatus = 0; /* Expand the string to print */ va_start(args, pszFmt); vsprintf(szBuf, pszFmt, args); va_end(args); /* Write the line using the right method */ if (psInfo->pfnWriteNextLine == NULL) { /* Use fprintf() directly */ if ( VSIFPrintf(psInfo->fp, "%s\n", szBuf) < 0) { CPLError(CE_Failure, CPLE_FileIO, "Error writing to file: %s", strerror(errno)); nStatus = 204; } } else { /* Use pfnWritenextLine() callback */ if ( psInfo->pfnWriteNextLine(psInfo->pRefData, szBuf) < 0) { CPLError(CE_Failure, CPLE_FileIO, "Error writing to file."); nStatus = 204; } } return nStatus; } saga-2.3.1/src/modules/io/io_esri_e00/e00compr/cpl_conv.c0000744000175000017500000001547712737416172024154 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_conv.c 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_conv.c: Various CPL convenience functions (from cpl_conv.h). * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:00:59 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.4 1999/01/02 20:29:53 warmerda * Allow zero length allocations * * Revision 1.3 1998/12/15 19:01:07 warmerda * Added CPLReadLine(). * * Revision 1.2 1998/12/03 18:30:04 warmerda * Use CPLError() instead of GPSError(). * * Revision 1.1 1998/12/02 19:33:23 warmerda * New * */ #include "cpl_conv.h" /************************************************************************/ /* CPLCalloc() */ /************************************************************************/ void *CPLCalloc( size_t nCount, size_t nSize ) { void *pReturn; if( nSize == 0 ) return NULL; pReturn = VSICalloc( nCount, nSize ); if( pReturn == NULL ) { CPLError( CE_Fatal, CPLE_OutOfMemory, "CPLCalloc(): Out of memory allocating %d bytes.\n", nSize * nCount ); } return pReturn; } /************************************************************************/ /* CPLMalloc() */ /************************************************************************/ void *CPLMalloc( size_t nSize ) { void *pReturn; if( nSize == 0 ) return NULL; pReturn = VSIMalloc( nSize ); if( pReturn == NULL ) { CPLError( CE_Fatal, CPLE_OutOfMemory, "CPLMalloc(): Out of memory allocating %d bytes.\n", nSize ); } return pReturn; } /************************************************************************/ /* CPLRealloc() */ /************************************************************************/ void * CPLRealloc( void * pData, size_t nNewSize ) { void *pReturn; if( pData == NULL ) pReturn = VSIMalloc( nNewSize ); else pReturn = VSIRealloc( pData, nNewSize ); if( pReturn == NULL ) { CPLError( CE_Fatal, CPLE_OutOfMemory, "CPLRealloc(): Out of memory allocating %d bytes.\n", nNewSize ); } return pReturn; } /************************************************************************/ /* CPLStrdup() */ /************************************************************************/ char *CPLStrdup( const char * pszString ) { char *pszReturn; if( pszString == NULL ) pszString = ""; pszReturn = VSIStrdup( pszString ); if( pszReturn == NULL ) { CPLError( CE_Fatal, CPLE_OutOfMemory, "CPLStrdup(): Out of memory allocating %d bytes.\n", strlen(pszString) ); } return( pszReturn ); } /************************************************************************/ /* CPLReadLine() */ /* */ /* Read a line of text from the given file handle, taking care */ /* to capture CR and/or LF and strip off ... equivelent of */ /* DKReadLine(). Pointer to an internal buffer is returned. */ /* The application shouldn't free it, or depend on it's value */ /* past the next call to CPLReadLine() */ /* */ /* TODO: Allow arbitrarily long lines ... currently limited to */ /* 512 characters. */ /************************************************************************/ const char *CPLReadLine( FILE * fp ) { static char *pszRLBuffer = NULL; static int nRLBufferSize = 0; int nLength; /* -------------------------------------------------------------------- */ /* Allocate our working buffer. Eventually this should grow as */ /* needed ... we will implement that aspect later. */ /* -------------------------------------------------------------------- */ if( nRLBufferSize < 512 ) { nRLBufferSize = 512; pszRLBuffer = (char *) CPLRealloc(pszRLBuffer, nRLBufferSize); } /* -------------------------------------------------------------------- */ /* Do the actual read. */ /* -------------------------------------------------------------------- */ if( VSIFGets( pszRLBuffer, nRLBufferSize, fp ) == NULL ) return NULL; /* -------------------------------------------------------------------- */ /* Clear CR and LF off the end. */ /* -------------------------------------------------------------------- */ nLength = strlen(pszRLBuffer); if( nLength > 0 && (pszRLBuffer[nLength-1] == 10 || pszRLBuffer[nLength-1] == 13) ) { pszRLBuffer[--nLength] = '\0'; } if( nLength > 0 && (pszRLBuffer[nLength-1] == 10 || pszRLBuffer[nLength-1] == 13) ) { pszRLBuffer[--nLength] = '\0'; } return( pszRLBuffer ); } saga-2.3.1/src/modules/io/io_esri_e00/e00compr/cpl_error.c0000744000175000017500000001320312737416172024321 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_error.c 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /********************************************************************** * $Id: cpl_error.c 911 2011-02-14 16:38:15Z reklov_w $ * * Name: cpl_error.cpp * Project: CPL - Common Portability Library * Purpose: Error handling functions. * Author: Daniel Morissette, danmo@videotron.ca * ********************************************************************** * Copyright (c) 1998, Daniel Morissette * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ********************************************************************** * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:00:59 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.3 1998/12/15 19:02:27 warmerda * Avoid use of errno as a variable * * Revision 1.2 1998/12/06 02:52:52 warmerda * Implement assert support * * Revision 1.1 1998/12/03 18:26:02 warmerda * New * **********************************************************************/ #include "cpl_error.h" /* static buffer to store the last error message. We'll assume that error * messages cannot be longer than 2000 chars... which is quite reasonable * (that's 25 lines of 80 chars!!!) */ static char gszCPLLastErrMsg[2000] = ""; static int gnCPLLastErrNo = 0; static void (*gpfnCPLErrorHandler)(CPLErr, int, const char *) = NULL; /********************************************************************** * CPLError() * * This function records an error code and displays the error message * to stderr. * * The error code can be accessed later using CPLGetLastErrNo() **********************************************************************/ void CPLError(CPLErr eErrClass, int err_no, const char *fmt, ...) { va_list args; /* Expand the error message */ va_start(args, fmt); vsprintf(gszCPLLastErrMsg, fmt, args); va_end(args); /* If the user provided his own error handling function, then call * it, otherwise print the error to stderr and return. */ gnCPLLastErrNo = err_no; if (gpfnCPLErrorHandler != NULL) { gpfnCPLErrorHandler(eErrClass, err_no, gszCPLLastErrMsg); } else { fprintf(stderr, "ERROR %d: %s\n", gnCPLLastErrNo, gszCPLLastErrMsg); } if( eErrClass == CE_Fatal ) abort(); } /********************************************************************** * CPLErrorReset() * * Erase any traces of previous errors. **********************************************************************/ void CPLErrorReset() { gnCPLLastErrNo = 0; gszCPLLastErrMsg[0] = '\0'; } /********************************************************************** * CPLGetLastErrorNo() * **********************************************************************/ int CPLGetLastErrorNo() { return gnCPLLastErrNo; } /********************************************************************** * CPLGetLastErrorMsg() * **********************************************************************/ const char* CPLGetLastErrorMsg() { return gszCPLLastErrMsg; } /********************************************************************** * CPLSetErrorHandler() * * Allow the library's user to specify his own error handler function. * * A valid error handler is a C function with the following prototype: * * void MyErrorHandler(int errno, const char *msg) * * Pass NULL to come back to the default behavior. **********************************************************************/ void CPLSetErrorHandler(void (*pfnErrorHandler)(CPLErr, int, const char *)) { gpfnCPLErrorHandler = pfnErrorHandler; } /************************************************************************/ /* _CPLAssert() */ /* */ /* This function is called only when an assertion fails. */ /************************************************************************/ void _CPLAssert( const char * pszExpression, const char * pszFile, int iLine ) { CPLError( CE_Fatal, CPLE_AssertionFailed, "Assertion `%s' failed\n" "in file `%s', line %d\n", pszExpression, pszFile, iLine ); } saga-2.3.1/src/modules/io/io_esri_e00/e00compr/e00read.c0000744000175000017500000005366512737416172023572 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: e00read.c 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /********************************************************************** * $Id: e00read.c 911 2011-02-14 16:38:15Z reklov_w $ * * Name: e00read.c * Project: Compressed E00 Read/Write library * Language: ANSI C * Purpose: Functions to read Compressed E00 files and return a stream * of uncompressed lines. * Author: Daniel Morissette, danmo@videotron.ca * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.8 1999/02/25 18:45:56 daniel * Now use CPL for Error handling, Memory allocation, and File access * * Revision 1.7 1999/01/08 17:39:08 daniel * Added E00ReadCallbackOpen() * * Revision 1.6 1998/11/13 16:34:08 daniel * Fixed '\r' problem when reading E00 files from a PC under Unix * * Revision 1.5 1998/11/13 15:48:08 daniel * Simplified the decoding of the compression codes for numbers * (use a logical rule instead of going case by case) * * Revision 1.4 1998/11/02 18:34:29 daniel * Added E00ErrorReset() calls. Replace "EXP 1" by "EXP 0" on read. * * Revision 1.1 1998/10/29 13:26:00 daniel * Initial revision * ********************************************************************** * Copyright (c) 1998, 1999, Daniel Morissette * * All rights reserved. This software may be copied or reproduced, in * all or in part, without the prior written consent of its author, * Daniel Morissette (danmo@videotron.ca). However, any material copied * or reproduced must bear the original copyright notice (above), this * original paragraph, and the original disclaimer (below). * * The entire risk as to the results and performance of the software, * supporting text and other information contained in this file * (collectively called the "Software") is with the user. Although * considerable efforts have been used in preparing the Software, the * author does not warrant the accuracy or completeness of the Software. * In no event will the author be liable for damages, including loss of * profits or consequential damages, arising out of the use of the * Software. * **********************************************************************/ #include #include #include #include #include "e00compr.h" static void _ReadNextSourceLine(E00ReadPtr psInfo); static const char *_UncompressNextLine(E00ReadPtr psInfo); /********************************************************************** * _E00ReadTestOpen() * * Given a pre-initialized E00ReadPtr, this function will make sure * that the file is really a E00 file, and also establish if it is * compressed or not... setting the structure members by the same way. * * Returns NULL (and destroys the E00ReadPtr) if the file does not * appear to be a valid E00 file. **********************************************************************/ static E00ReadPtr _E00ReadTestOpen(E00ReadPtr psInfo) { /* Check that the file is in E00 format. */ _ReadNextSourceLine(psInfo); if (!psInfo->bEOF && strncmp(psInfo->szInBuf, "EXP ", 4) == 0) { /* We should be in presence of a valid E00 file... * Is the file compressed or not? * * Note: we cannot really rely on the number that follows the EXP to * establish if the file is compressed since we sometimes encounter * uncompressed files that start with a "EXP 1" line!!! * * The best test is to read the first non-empty line: if the file is * compressed, the first line of data should be 79 or 80 characters * long and contain several '~' characters. */ do { _ReadNextSourceLine(psInfo); }while(!psInfo->bEOF && (psInfo->szInBuf[0] == '\0' || isspace(psInfo->szInBuf[0])) ); if (!psInfo->bEOF && (strlen(psInfo->szInBuf)==79 || strlen(psInfo->szInBuf)==80) && strchr(psInfo->szInBuf, '~') != NULL ) psInfo->bIsCompressed = 1; /* Move the Read ptr ready to read at the beginning of the file */ E00ReadRewind(psInfo); } else { CPLFree(psInfo); psInfo = NULL; } return psInfo; } /********************************************************************** * E00ReadOpen() * * Try to open a E00 file given its filename and return a E00ReadPtr handle. * * Returns NULL if the file could not be opened or if it does not * appear to be a valid E00 file. **********************************************************************/ E00ReadPtr E00ReadOpen(const char *pszFname) { E00ReadPtr psInfo = NULL; FILE *fp; CPLErrorReset(); /* Open the file */ fp = VSIFOpen(pszFname, "rt"); if (fp == NULL) { CPLError(CE_Failure, CPLE_OpenFailed, "Failed to open %s: %s", pszFname, strerror(errno)); return NULL; } /* File was succesfully opened, allocate and initialize a * E00ReadPtr handle and check that the file is valid. */ psInfo = (E00ReadPtr)CPLCalloc(1, sizeof(struct _E00ReadInfo)); psInfo->fp = fp; psInfo = _E00ReadTestOpen(psInfo); if (psInfo == NULL) { CPLError(CE_Failure, CPLE_OpenFailed, "%s is not a valid E00 file.", pszFname); } return psInfo; } /********************************************************************** * E00ReadCallbackOpen() * * This is an alternative to E00ReadOpen() for cases where you want to * do all the file management yourself. You open/close the file yourself * and provide 2 callback functions: to read from the file and rewind the * file pointer. pRefData is your handle on the physical file and can * be whatever you want... it is not used by the library, it will be * passed directly to your 2 callback functions when they are called. * * The callback functions must have the following C prototype: * * const char *myReadNextLine(void *pRefData); * void myReadRewind(void *pRefData); * * myReadNextLine() should return a reference to its own internal * buffer, or NULL if an error happens or EOF is reached. * * E00ReadCallbackOpen() returns a E00ReadPtr handle or NULL if the file * does not appear to be a valid E00 file. **********************************************************************/ E00ReadPtr E00ReadCallbackOpen(void *pRefData, const char * (*pfnReadNextLine)(void *), void (*pfnReadRewind)(void *)) { E00ReadPtr psInfo = NULL; CPLErrorReset(); /* Make sure we received valid function pointers */ if (pfnReadNextLine == NULL || pfnReadRewind == NULL) { CPLError(CE_Failure, CPLE_IllegalArg, "Invalid function pointers!"); return NULL; } /* Allocate and initialize a * E00ReadPtr handle and check that the file is valid. */ psInfo = (E00ReadPtr)CPLCalloc(1, sizeof(struct _E00ReadInfo)); psInfo->pRefData = pRefData; psInfo->pfnReadNextLine = pfnReadNextLine; psInfo->pfnReadRewind = pfnReadRewind; psInfo = _E00ReadTestOpen(psInfo); if (psInfo == NULL) { CPLError(CE_Failure, CPLE_OpenFailed, "This is not a valid E00 file."); } return psInfo; } /********************************************************************** * E00ReadClose() * * Close input file and release any memory used by the E00ReadPtr. **********************************************************************/ void E00ReadClose(E00ReadPtr psInfo) { CPLErrorReset(); if (psInfo) { if (psInfo->fp) VSIFClose(psInfo->fp); CPLFree(psInfo); } } /********************************************************************** * E00ReadRewind() * * Rewind the E00ReadPtr. Allows starting another read pass on the * input file. **********************************************************************/ void E00ReadRewind(E00ReadPtr psInfo) { CPLErrorReset(); psInfo->szInBuf[0] = psInfo->szOutBuf[0] = '\0'; psInfo->iInBufPtr = 0; psInfo->nInputLineNo = 0; if (psInfo->pfnReadRewind == NULL) VSIRewind(psInfo->fp); else psInfo->pfnReadRewind(psInfo->pRefData); psInfo->bEOF = 0; } /********************************************************************** * E00ReadNextLine() * * Return the next line of input from the E00 file or NULL if we reached EOF. * * Returns a reference to an internal buffer whose contents will be valid * only until the next call to this function. **********************************************************************/ const char *E00ReadNextLine(E00ReadPtr psInfo) { const char *pszLine = NULL; char *pszPtr; CPLErrorReset(); if (psInfo && !psInfo->bEOF) { if (!psInfo->bIsCompressed) { /* Uncompressed file... return line directly. */ _ReadNextSourceLine(psInfo); pszLine = psInfo->szInBuf; } else if (psInfo->bIsCompressed && psInfo->nInputLineNo == 0) { /* Header line in a compressed file... return line * after replacing "EXP 1" with "EXP 0". E00ReadOpen() * has already verified that this line starts with "EXP " */ _ReadNextSourceLine(psInfo); if ( (pszPtr = strstr(psInfo->szInBuf, " 1")) != NULL) pszPtr[1] = '0'; pszLine = psInfo->szInBuf; } else { if (psInfo->nInputLineNo == 1) { /* We just read the header line... reload the input buffer */ _ReadNextSourceLine(psInfo); } /* Uncompress the next line of input and return it */ pszLine = _UncompressNextLine(psInfo); } /* If we just reached EOF then make sure we don't add an extra * empty line at the end of the uncompressed oputput. */ if (psInfo->bEOF && strlen(pszLine) == 0) pszLine = NULL; } return pszLine; } /********************************************************************** * _ReadNextSourceLine() * * Loads the next line from the source file in psInfo. * * psInfo->bEOF should be checked after this call. **********************************************************************/ static void _ReadNextSourceLine(E00ReadPtr psInfo) { if (!psInfo->bEOF) { psInfo->iInBufPtr = 0; psInfo->szInBuf[0] = '\0'; /* Read either using fgets() or psInfo->pfnReadNextLine() * depending on the way the file was opened... */ if (psInfo->pfnReadNextLine == NULL) { if (VSIFGets(psInfo->szInBuf,E00_READ_BUF_SIZE,psInfo->fp) == NULL) { /* We reached EOF */ psInfo->bEOF = 1; } } else { const char *pszLine; pszLine = psInfo->pfnReadNextLine(psInfo->pRefData); if (pszLine) { strncpy(psInfo->szInBuf, pszLine, E00_READ_BUF_SIZE); } else { /* We reached EOF */ psInfo->bEOF = 1; } } if (!psInfo->bEOF) { /* A new line was succesfully read. Remove trailing '\n' if any. * (Note: For Unix systems, we also have to check for '\r') */ int nLen; nLen = strlen(psInfo->szInBuf); while(nLen > 0 && (psInfo->szInBuf[nLen-1] == '\n' || psInfo->szInBuf[nLen-1] == '\r' ) ) { nLen--; psInfo->szInBuf[nLen] = '\0'; } psInfo->nInputLineNo++; } } } /********************************************************************** * _GetNextSourceChar() * * Returns the next char from the source file input buffer... and * reload the input buffer when necessary... this function makes the * whole input file appear as one huge null-terminated string with * no line delimiters. * * Will return '\0' when EOF is reached. **********************************************************************/ static char _GetNextSourceChar(E00ReadPtr psInfo) { char c = '\0'; if (!psInfo->bEOF) { if (psInfo->szInBuf[psInfo->iInBufPtr] == '\0') { _ReadNextSourceLine(psInfo); c = _GetNextSourceChar(psInfo); } else { c = psInfo->szInBuf[psInfo->iInBufPtr++]; } } return c; } /********************************************************************** * _UngetSourceChar() * * Reverse the effect of the previous call to _GetNextSourceChar() by * moving the input buffer pointer back 1 character. * * This function can be called only once per call to _GetNextSourceChar() * (i.e. you cannot unget more than one character) otherwise the pointer * could move before the beginning of the input buffer. **********************************************************************/ static void _UngetSourceChar(E00ReadPtr psInfo) { if (psInfo->iInBufPtr > 0) psInfo->iInBufPtr--; else { /* This error can happen only if _UngetSourceChar() is called * twice in a row (which should never happen!). */ CPLError(CE_Failure, CPLE_AssertionFailed, "UNEXPECTED INTERNAL ERROR: _UngetSourceChar() " "failed while reading line %d.", psInfo->nInputLineNo); } } /********************************************************************** * _UncompressNextLine() * * Uncompress one line of input and return a reference to an internal * buffer containing the uncompressed output. **********************************************************************/ static const char *_UncompressNextLine(E00ReadPtr psInfo) { char c; int bEOL = 0; /* Set to 1 when End of Line reached */ int iOutBufPtr = 0, i, n; int iDecimalPoint, bOddNumDigits, iCurDigit; char *pszExp; int bPreviousCodeWasNumeric = 0; while(!bEOL && (c=_GetNextSourceChar(psInfo)) != '\0') { if (c != '~') { /* Normal character... just copy it */ psInfo->szOutBuf[iOutBufPtr++] = c; bPreviousCodeWasNumeric = 0; } else /* c == '~' */ { /* ======================================================== * Found an encoded sequence. * =======================================================*/ c = _GetNextSourceChar(psInfo); /* -------------------------------------------------------- * Compression level 1: only spaces, '~' and '\n' are encoded * -------------------------------------------------------*/ if (c == ' ') { /* "~ " followed by number of spaces */ c = _GetNextSourceChar(psInfo); n = c - ' '; for(i=0; iszOutBuf[iOutBufPtr++] = ' '; bPreviousCodeWasNumeric = 0; } else if (c == '}') { /* "~}" == '\n' */ bEOL = 1; bPreviousCodeWasNumeric = 0; } else if (bPreviousCodeWasNumeric) { /* If the previous code was numeric, then the only valid code * sequences are the ones above: "~ " and "~}". If we end up * here, it is because the number was followed by a '~' but * this '~' was not a code, it only marked the end of a * number that was not followed by any space. * * We should simply ignore the '~' and return the character * that follows it directly. */ psInfo->szOutBuf[iOutBufPtr++] = c; bPreviousCodeWasNumeric = 0; } else if (c == '~' || c == '-') { /* "~~" and "~-" are simple escape sequences for '~' and '-' */ psInfo->szOutBuf[iOutBufPtr++] = c; } /* -------------------------------------------------------- * Compression level 2: numeric values are encoded. * * All codes for this level are in the form "~ c0 c1 c2 ... cn" * where: * * ~ marks the beginning of a new code sequence * * c0 is a single character code defining the format * of the number (decimal position, exponent, * and even or odd number of digits) * * c1 c2 ... cn each of these characters represent a pair of * digits of the encoded value with '!' == 00 * values 92..99 are encoded on 2 chars that * must be added to each other * (i.e. 92 == }!, 93 == }", ...) * * The sequence ends with a ' ' or a '~' character * -------------------------------------------------------*/ else if (c >= '!' && c <= 'z') { /* The format code defines 3 characteristics of the final number: * - Presence of a decimal point and its position * - Presence of an exponent, and its sign * - Odd or even number of digits */ n = c - '!'; iDecimalPoint = n % 15; /* 0 = no decimal point */ bOddNumDigits = n / 45; /* 0 = even num.digits, 1 = odd */ n = n / 15; if ( n % 3 == 1 ) pszExp = "E+"; else if (n % 3 == 2 ) pszExp = "E-"; else pszExp = NULL; /* Decode the c1 c2 ... cn value and apply the format. * Read characters until we encounter a ' ' or a '~' */ iCurDigit = 0; while((c=_GetNextSourceChar(psInfo)) != '\0' && c != ' ' && c != '~') { n = c - '!'; if (n == 92 && (c=_GetNextSourceChar(psInfo)) != '\0') n += c - '!'; psInfo->szOutBuf[iOutBufPtr++] = '0' + n/10; if (++iCurDigit == iDecimalPoint) psInfo->szOutBuf[iOutBufPtr++] = '.'; psInfo->szOutBuf[iOutBufPtr++] = '0' + n%10; if (++iCurDigit == iDecimalPoint) psInfo->szOutBuf[iOutBufPtr++] = '.'; } if (c == '~' || c == ' ') { bPreviousCodeWasNumeric = 1; _UngetSourceChar(psInfo); } /* If odd number of digits, then flush the last one */ if (bOddNumDigits) iOutBufPtr--; /* Insert the exponent string before the 2 last digits * (we assume the exponent string is 2 chars. long) */ if (pszExp) { for(i=0; i<2;i++) { psInfo->szOutBuf[iOutBufPtr] = psInfo->szOutBuf[iOutBufPtr-2]; psInfo->szOutBuf[iOutBufPtr-2] = pszExp[i]; iOutBufPtr++; } } } else { /* Unsupported code sequence... this is a possibility * given the fact that this library was written by * reverse-engineering the format! * * Send an error to the user and abort. * * If this error ever happens, and you are convinced that * the input file is not corrupted, then please report it to * me at danmo@videotron.ca, quoting the section of the input * file that produced it, and I'll do my best to add support * for this code sequence. */ CPLError(CE_Failure, CPLE_NotSupported, "Unexpected code \"~%c\" encountered in line %d.", c, psInfo->nInputLineNo); /* Force the program to abort by simulating a EOF */ psInfo->bEOF = 1; bEOL = 1; } }/* if c == '~' */ /* E00 lines should NEVER be longer than 80 chars. if we passed * that limit, then the input file is likely corrupt. */ if (iOutBufPtr > 80) { CPLError(CE_Failure, CPLE_FileIO, "Uncompressed line longer than 80 chars. " "Input file possibly corrupt around line %d.", psInfo->nInputLineNo); /* Force the program to abort by simulating a EOF */ psInfo->bEOF = 1; bEOL = 1; } }/* while !EOL */ psInfo->szOutBuf[iOutBufPtr++] = '\0'; return psInfo->szOutBuf; } saga-2.3.1/src/modules/io/io_esri_e00/e00compr/cpl_error.h0000744000175000017500000000773012737416172024336 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_error.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /********************************************************************** * $Id: cpl_error.h 911 2011-02-14 16:38:15Z reklov_w $ * * Name: cpl_error.h * Project: CPL - Common Portability Library * Purpose: CPL Error handling * Author: Daniel Morissette, danmo@videotron.ca * ********************************************************************** * Copyright (c) 1998, Daniel Morissette * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ********************************************************************** * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:00:59 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.6 1999/02/17 05:40:47 danmo * Fixed CPLAssert() macro to work with EGCS. * * Revision 1.5 1999/01/11 15:34:29 warmerda * added reserved range comment * * Revision 1.4 1998/12/15 19:02:27 warmerda * Avoid use of errno as a variable * * Revision 1.3 1998/12/06 22:20:42 warmerda * Added error code. * * Revision 1.2 1998/12/06 02:52:52 warmerda * Implement assert support * * Revision 1.1 1998/12/03 18:26:02 warmerda * New * **********************************************************************/ #ifndef _CPL_ERROR_H_INCLUDED_ #define _CPL_ERROR_H_INCLUDED_ #include "cpl_port.h" /*===================================================================== Error handling functions (cpl_error.c) =====================================================================*/ CPL_C_START typedef enum { CE_None = 0, CE_Log = 1, CE_Warning = 2, CE_Failure = 3, CE_Fatal = 4 } CPLErr; void CPL_DLL CPLError(CPLErr eErrClass, int err_no, const char *fmt, ...); void CPL_DLL CPLErrorReset(); int CPL_DLL CPLGetLastErrorNo(); const char CPL_DLL * CPLGetLastErrorMsg(); void CPL_DLL CPLSetErrorHandler(void(*pfnErrorHandler)(CPLErr,int, const char *)); void CPL_DLL _CPLAssert( const char *, const char *, int ); #ifdef DEBUG # define CPLAssert(expr) ((expr) ? (void)(0) : _CPLAssert(#expr,__FILE__,__LINE__)) #else # define CPLAssert(expr) #endif CPL_C_END /* ==================================================================== */ /* Well known error codes. */ /* ==================================================================== */ #define CPLE_AppDefined 1 #define CPLE_OutOfMemory 2 #define CPLE_FileIO 3 #define CPLE_OpenFailed 4 #define CPLE_IllegalArg 5 #define CPLE_NotSupported 6 #define CPLE_AssertionFailed 7 #define CPLE_NoWriteAccess 8 /* 100 - 299 reserved for GDAL */ #endif /* _CPL_ERROR_H_INCLUDED_ */ saga-2.3.1/src/modules/io/io_esri_e00/e00compr/cpl_port.h0000744000175000017500000002032012737416172024157 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: cpl_port.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /****************************************************************************** * Copyright (c) 1998, Frank Warmerdam * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. ****************************************************************************** * * cpl_port.h * * Include file providing low level portability services for CPL. This * should be the first include file for any CPL based code. It provides the * following: * * o Includes some standard system include files, such as stdio, and stdlib. * * o Defines CPL_C_START, CPL_C_END macros. * * o Ensures that some other standard macros like NULL are defined. * * o Defines some portability stuff like CPL_MSB, or CPL_LSB. * * o Ensures that core types such as GBool, GInt32, GInt16, GUInt32, * GUInt16, and GByte are defined. * * $Log: not supported by cvs2svn $ * Revision 1.1.1.1 2005/08/31 14:01:00 oconrad * no message * * Revision 1.1.1.1 2005/08/17 08:25:16 oconrad * no message * * Revision 1.1.1.1 2005/08/15 13:35:12 oconrad * no message * * Revision 1.1 2004/04/16 13:36:45 oconrad * no message * * Revision 1.9 1999/02/17 01:41:17 warmerda * Added NULL. * * Revision 1.8 1999/02/02 21:32:38 warmerda * Added CPL_{MSB,LSB}WORD{16,32} macros. * * Revision 1.7 1999/02/02 19:02:36 warmerda * Removed duplicates of base types, and CPL_LSB * * Revision 1.6 1999/01/28 18:36:06 warmerda * Ensure WIN32 is defined on Windows. * * Revision 1.5 1999/01/28 05:26:12 danmo * Added byte swapping macros. * * Revision 1.4 1998/12/15 19:05:30 warmerda * added errno.h * * Revision 1.3 1998/12/14 04:50:07 warmerda * Added DBMALLOC support * * Revision 1.2 1998/12/04 21:38:40 danmo * Changed str*casecmp() to str*icmp() for WIN32 * * Revision 1.1 1998/12/03 18:26:02 warmerda * New * */ #ifndef CPL_BASE_H_INCLUDED #define CPL_BASE_H_INCLUDED /* ==================================================================== */ /* We will use WIN32 as a standard windows define. */ /* ==================================================================== */ #if defined(_WIN32) && !defined(WIN32) # define WIN32 #endif /* ==================================================================== */ /* Standard include files. */ /* ==================================================================== */ #include #include #include #include #include #include #ifdef DBMALLOC #include #endif /* ==================================================================== */ /* Base portability stuff ... this stuff may need to be */ /* modified for new platforms. */ /* ==================================================================== */ /*--------------------------------------------------------------------- * types for 16 and 32 bits integers, etc... *--------------------------------------------------------------------*/ #if UINT_MAX == 65535 typedef long GInt32; typedef unsigned long GUInt32; #else typedef int GInt32; typedef unsigned int GUInt32; #endif typedef short GInt16; typedef unsigned short GUInt16; typedef unsigned char GByte; typedef int GBool; /* ==================================================================== */ /* Other standard services. */ /* ==================================================================== */ #ifdef __cplusplus # define CPL_C_START extern "C" { # define CPL_C_END } #else # define CPL_C_START # define CPL_C_END #endif /* # define CPL_DLL __declspec(dllexport) */ #define CPL_DLL #ifndef NULL # define NULL 0 #endif #ifndef FALSE # define FALSE 0 #endif #ifndef TRUE # define TRUE 1 #endif #ifndef MAX # define MIN(a,b) ((ab) ? a : b) #endif #ifndef NULL #define NULL 0 #endif #ifndef ABS # define ABS(x) ((x<0) ? (-1*(x)) : x) #endif #ifndef EQUAL #ifdef WIN32 # define EQUALN(a,b,n) (strnicmp(a,b,n)==0) # define EQUAL(a,b) (stricmp(a,b)==0) #else # define EQUALN(a,b,n) (strncasecmp(a,b,n)==0) # define EQUAL(a,b) (strcasecmp(a,b)==0) #endif #endif /*--------------------------------------------------------------------- * CPL_LSB and CPL_MSB * Only one of these 2 macros should be defined and specifies the byte * ordering for the current platform. * This should be defined in the Makefile, but if it is not then * the default is CPL_LSB (Intel ordering, LSB first). *--------------------------------------------------------------------*/ #if ! ( defined(CPL_LSB) || defined(CPL_MSB) ) #define CPL_LSB #endif /*--------------------------------------------------------------------- * Little endian <==> big endian byte swap macros. *--------------------------------------------------------------------*/ #define CPL_SWAP16(x) \ ((GUInt16)( \ (((GUInt16)(x) & 0x00ffU) << 8) | \ (((GUInt16)(x) & 0xff00U) >> 8) )) #define CPL_SWAP32(x) \ ((GUInt32)( \ (((GUInt32)(x) & (GUInt32)0x000000ffUL) << 24) | \ (((GUInt32)(x) & (GUInt32)0x0000ff00UL) << 8) | \ (((GUInt32)(x) & (GUInt32)0x00ff0000UL) >> 8) | \ (((GUInt32)(x) & (GUInt32)0xff000000UL) >> 24) )) /* Until we have a safe 64 bits integer data type defined, we'll replace m * this version of the CPL_SWAP64() macro with a less efficient one. */ /* #define CPL_SWAP64(x) \ ((uint64)( \ (uint64)(((uint64)(x) & (uint64)0x00000000000000ffULL) << 56) | \ (uint64)(((uint64)(x) & (uint64)0x000000000000ff00ULL) << 40) | \ (uint64)(((uint64)(x) & (uint64)0x0000000000ff0000ULL) << 24) | \ (uint64)(((uint64)(x) & (uint64)0x00000000ff000000ULL) << 8) | \ (uint64)(((uint64)(x) & (uint64)0x000000ff00000000ULL) >> 8) | \ (uint64)(((uint64)(x) & (uint64)0x0000ff0000000000ULL) >> 24) | \ (uint64)(((uint64)(x) & (uint64)0x00ff000000000000ULL) >> 40) | \ (uint64)(((uint64)(x) & (uint64)0xff00000000000000ULL) >> 56) )) */ #define CPL_SWAPDOUBLE(p) { \ double _tmp = *(double *)(p); \ ((GByte *)(p))[0] = ((GByte *)&_tmp)[7]; \ ((GByte *)(p))[1] = ((GByte *)&_tmp)[6]; \ ((GByte *)(p))[2] = ((GByte *)&_tmp)[5]; \ ((GByte *)(p))[3] = ((GByte *)&_tmp)[4]; \ ((GByte *)(p))[4] = ((GByte *)&_tmp)[3]; \ ((GByte *)(p))[5] = ((GByte *)&_tmp)[2]; \ ((GByte *)(p))[6] = ((GByte *)&_tmp)[1]; \ ((GByte *)(p))[7] = ((GByte *)&_tmp)[0]; \ } #ifdef CPL_MSB # define CPL_MSBWORD16(x) (x) # define CPL_LSBWORD16(x) CPL_SWAP16(x) # define CPL_MSBWORD32(x) (x) # define CPL_LSBWORD32(x) CPL_SWAP32(x) #else # define CPL_LSBWORD16(x) (x) # define CPL_MSBWORD16(x) CPL_SWAP16(x) # define CPL_LSBWORD32(x) (x) # define CPL_MSBWORD32(x) CPL_SWAP32(x) #endif #endif /* ndef CPL_BASE_H_INCLUDED */ saga-2.3.1/src/modules/io/io_esri_e00/ESRI_E00_Import.cpp0000744000175000017500000011613412737416172023754 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ESRI_E00_Import.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // ESRI_E00.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ESRI_E00_Import.h" /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CESRI_E00_Import::CESRI_E00_Import(void) { //----------------------------------------------------- // 1. info_Table... Set_Name (_TL("Import ESRI E00 File")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description (_TW( "Import data sets from ESRI's E00 interchange format.\n\n" "This import filter is based on the E00 format analysis of the GRASS GIS module " "\'m.in.e00\' written by Michel J. Wurtz. Go to the " "GRASS GIS Hompage " "for more information.\n" "The \'E00Compr\' library " "written by Daniel Morissette has been used for e00 file access, so that " "compressed e00 files also can be read.\n") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Table_List( NULL , "TABLES" , _TL("Tables"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Table_Output( NULL , "TABLE" , _TL("Table"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("ESRI E00 Files|*.e00|All Files|*.*"), NULL, false, false, true ); Parameters.Add_Value( NULL , "BBND" , _TL("Import Extents"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BTIC" , _TL("Import Tick Points"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Value( NULL , "BTABLES" , _TL("Import Tables"), _TL(""), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CESRI_E00_Import::On_Execute(void) { int nLoaded = 0; m_bBnd = Parameters("BBND") ->asBool(); m_bTic = Parameters("BTIC") ->asBool(); m_bTables = Parameters("BTABLES") ->asBool(); m_pTables = Parameters("TABLES") ->asTableList(); m_pShapes = Parameters("SHAPES") ->asShapesList(); m_pGrids = Parameters("GRIDS") ->asGridList(); m_pTables ->Del_Items(); m_pShapes ->Del_Items(); m_pGrids ->Del_Items(); CSG_Strings fNames; if( Parameters("FILE")->asFilePath()->Get_FilePaths(fNames) && fNames.Get_Count() > 0 ) { for(int i=0; i 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const char * CESRI_E00_Import::E00_Read_Line(void) { const char *line = E00ReadNextLine(m_hReadPtr); if( line == NULL ) { FILE *fp = fopen(SG_File_Make_Path(NULL, m_e00_Name, CSG_String::Format(SG_T("e%02d"), m_iFile + 1)), "rb"); if( fp ) { m_iFile++; int nInputLineNo = m_hReadPtr->nInputLineNo; E00ReadRewind(m_hReadPtr); fclose(m_hReadPtr->fp); m_hReadPtr->fp = fp; m_hReadPtr->nInputLineNo = nInputLineNo - 1; line = E00ReadNextLine(m_hReadPtr); } } return( line ); } //--------------------------------------------------------- bool CESRI_E00_Import::E00_Goto_Line(int iLine) { if( m_hReadPtr ) { if( m_iFile == 0 ) { E00ReadRewind(m_hReadPtr); } else { E00ReadClose(m_hReadPtr); m_hReadPtr = E00ReadOpen(m_e00_Name); m_iFile = 0; } while( E00_Read_Line() && m_hReadPtr->nInputLineNo < iLine ); return( m_hReadPtr->nInputLineNo == iLine ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CESRI_E00_Import::Load(const CSG_String &FileName) { bool bResult = false; const char *Line; m_hReadPtr = NULL; m_e00_Name = FileName; m_iFile = 0; //----------------------------------------------------- if( (m_hReadPtr = E00ReadOpen(m_e00_Name)) == NULL ) { Error_Set(CSG_String::Format(SG_T("%s: %s"), _TL("file not found") , FileName.c_str())); } else if( (Line = E00_Read_Line()) == NULL ) { Error_Set(CSG_String::Format(SG_T("%s: %s"), _TL("invalid E00 file"), FileName.c_str())); } else if( strncmp(Line, "EXP", 3) ) { Error_Set(CSG_String::Format(SG_T("%s: %d"), _TL("invalid E00 file"), FileName.c_str())); } //----------------------------------------------------- else { bResult = Load(); } //----------------------------------------------------- if( m_hReadPtr ) { E00ReadClose(m_hReadPtr); } return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CESRI_E00_Import::Load(void) { const char *line; int prec_grd, prec_arc, prec_lab, prec_pal; long current_line, offset_grd = 0, offset_arc = 0, offset_lab = 0, offset_pal = 0; double scale = 1.0; TSG_Shape_Type shape_type; CSG_Grid *pGrid; CSG_Shapes *pShapes; //----------------------------------------------------- m_pPAT = NULL; m_pAAT = NULL; //----------------------------------------------------- while( (line = E00_Read_Line()) != NULL && strncmp(line, "EOS", 3) ) { current_line = m_hReadPtr->nInputLineNo; // GRID SECTION if( !strncmp(line, "GRD ", 5) ) { offset_grd = current_line; prec_grd = line[5] - '2'; skip("EOG"); continue; } // ARC SECTION if( !strncmp(line, "ARC ", 5) ) { offset_arc = current_line; prec_arc = line[5] - '2'; skip_arc(prec_arc); continue; } // POLYGON TOPOLOGY if( !strncmp(line, "PAL ", 5) || !strncmp(line, "PFF ", 5) ) { offset_pal = current_line; prec_pal = line[5] - '2'; skip_pal(prec_pal); continue; } // CENTROID SECTION if( !strncmp(line, "CNT ", 5) ) { skip_dat(); continue; } // LABEL SECTION if( !strncmp(line, "LAB ", 5)) { offset_lab = current_line; prec_lab = line[5] - '2'; skip_lab(prec_lab); continue; } // INFO SECTION if( !strncmp(line, "IFO ", 5) ) { info_Get_Tables(); continue; } // PROJECTION INFOS if( !strncmp(line, "PRJ ", 5) ) { scale = getproj(); continue; } // Annotations (text). To be imported ? Does anybody have an idea ? if( !strncmp(line, "TXT ", 5) ) { skip_txt(line[5] - '2'); continue; } // Mask description ? Noting to do with it if( !strncmp(line, "MSK ", 5) ) { skip_msk(); continue; } // TOLERANCE SECTION. Should we really use it ? if( !strncmp(line, "TOL ", 5) ) { skip_dat(); continue; } // UNKNOW KEYWORD SECTION. Don't know what to do with. Does anybody have an idea? if( !strncmp(line, "LNK ", 5) ) { skip("END OF LINK DATA"); continue; } // SPATIAL INDEX SECTION. Noting to do with it if( !strncmp(line, "SIN ", 5) ) { skip("EOX"); continue; } // Line pattern and palette. Shade pattern and palette end same as e00 archive ! if( !strncmp(line, "CLN ", 5) || !strncmp(line, "CSH ", 5) ) { skip("EOS"); continue; } // Font description ? Noting to do with it if( !strncmp(line, "FNT ", 5) ) { skip("EOF"); continue; } // PLOT SECTION. Why should we import it ? if( !strncmp(line, "PLT ", 5) ) { skip("EOP"); continue; } // LOG SECTION. Nothing to do with it if( !strncmp(line, "LOG ", 5) ) { skip("EOL"); continue; } if( !strncmp(line, "RPL ", 5) // Specific to regions. Contains PAL formated data for each subclass || !strncmp(line, "RXP ", 5) // Specific to regions. Seems to link regions IDs to PAL polygons IDs || !strncmp(line, "TX6 ", 5) // Other kind of annotations not same termination. Other differences ? || !strncmp(line, "TX7 ", 5) ) // Very close from TX6. So same questions and same rules... { skip("JABBERWOCKY"); continue; } } //----------------------------------------------------- switch( m_pPAT ? (m_pAAT ? 3 : 2) : (m_pAAT ? 1 : 0) ) { case 0: default: shape_type = offset_arc != 0 ? SHAPE_TYPE_Line : SHAPE_TYPE_Point; break; case 1: // m_pAAT shape_type = SHAPE_TYPE_Line; break; case 2: // m_pPAT shape_type = offset_arc != 0 ? SHAPE_TYPE_Polygon : SHAPE_TYPE_Point; break; case 3: // m_pAAT && m_pPAT shape_type = offset_pal != 0 || offset_lab != 0 ? SHAPE_TYPE_Polygon : SHAPE_TYPE_Line; break; } //----------------------------------------------------- // Extracting useful information as noted before... //----------------------------------------------------- if( offset_grd > 0 ) { E00_Goto_Line(offset_grd); if( (pGrid = getraster (prec_grd, scale)) != NULL ) { pGrid->Set_Name(SG_File_Get_Name(m_e00_Name, false)); m_pGrids->Add_Item(pGrid); } } //----------------------------------------------------- if( offset_arc != 0 ) { E00_Goto_Line(offset_arc); if( (pShapes = getarcs (prec_arc, scale, shape_type)) != NULL ) { pShapes->Set_Name(SG_File_Get_Name(m_e00_Name, false)); m_pShapes->Add_Item(pShapes); } } //----------------------------------------------------- if( offset_lab != 0 && shape_type == SHAPE_TYPE_Point ) { E00_Goto_Line(offset_lab); if( (pShapes = getsites (prec_lab, scale)) != NULL ) { pShapes->Set_Name(SG_File_Get_Name(m_e00_Name, false)); m_pShapes->Add_Item(pShapes); } } //----------------------------------------------------- if( offset_lab != 0 && shape_type != SHAPE_TYPE_Point ) { E00_Goto_Line(offset_lab); if( (pShapes = getlabels(prec_lab, scale)) != NULL ) { pShapes->Set_Name(SG_File_Get_Name(m_e00_Name, false)); m_pShapes->Add_Item(pShapes); } } //----------------------------------------------------- if( !m_bTables ) { if( m_pPAT ) delete(m_pPAT); if( m_pAAT ) delete(m_pAAT); } return( true ); } /////////////////////////////////////////////////////////// // // // Grid // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Grid * CESRI_E00_Import::getraster(int prec, double scale) { const char *line; int x, y, ix; long rows, cols, depth, p[5]; float f[5]; double xres, yres, xmin, ymin, xmax, ymax, nul_val, d[3]; CSG_Grid *pGrid; //----------------------------------------------------- if( (line = E00_Read_Line()) == NULL ) return( NULL ); // sscanf(line, "%ld%ld%ld", &cols, &rows, &depth, &nul_val); sscanf(line, "%ld%ld%ld%lf", &cols, &rows, &depth, &nul_val); if( (line = E00_Read_Line()) == NULL ) return( NULL ); sscanf(line, "%lf%lf", &xres, &yres); if( (line = E00_Read_Line()) == NULL ) return( NULL ); sscanf(line, "%lf%lf", &xmin, &ymin); if( (line = E00_Read_Line()) == NULL ) return( NULL ); sscanf(line, "%lf%lf", &xmax, &ymax); xmax = xmax * scale; xmin = xmin * scale; ymax = ymax * scale; ymin = ymin * scale; xres = xres * scale; yres = yres * scale; xmin += xres / 2.0; // SAGA treats xmin/ymin as "pixel-as-point" and not as "pixel-as-area" ymin += yres / 2.0; if( depth == 2 && prec ) { depth = 3; } //----------------------------------------------------- switch( depth ) { default: pGrid = NULL; break; //----------------------------------------------------- case 1: pGrid = SG_Create_Grid(SG_DATATYPE_Int, cols, rows, xres, xmin, ymin); pGrid->Set_NoData_Value(nul_val); for(y=0; ySet_Value(x + ix, y, p[ix]); } } } } break; //----------------------------------------------------- case 2: pGrid = SG_Create_Grid(SG_DATATYPE_Float, cols, rows, xres, xmin, ymin); pGrid->Set_NoData_Value(nul_val); for(y=0; ySet_Value(x + ix, y, f[ix]); } } } } break; //----------------------------------------------------- case 3: pGrid = SG_Create_Grid(SG_DATATYPE_Double, cols, rows, xres, xmin, ymin); pGrid->Set_NoData_Value(nul_val); for(y=0; ySet_Value(x + ix, y, d[ix]); } } } } break; } //----------------------------------------------------- skip("EOG"); return( pGrid ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define ARC_FNODE 2 #define ARC_TNODE 3 #define ARC_LPOL 4 #define ARC_RPOL 5 //--------------------------------------------------------- CSG_Shapes * CESRI_E00_Import::getarcs(int prec, double scale, TSG_Shape_Type &shape_type) { const char *line; int covnum, cov_id, fnode, tnode, lpol, rpol, nPoints, iPoint; double x_buf[2], y_buf[2]; CSG_Shape *pShape; CSG_Shapes *pShapes; //----------------------------------------------------- pShapes = SG_Create_Shapes(shape_type); pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("ID#" , SG_DATATYPE_Int); pShapes->Add_Field("FNODE" , SG_DATATYPE_Int); pShapes->Add_Field("TNODE" , SG_DATATYPE_Int); pShapes->Add_Field("LPOL" , SG_DATATYPE_Int); pShapes->Add_Field("RPOL" , SG_DATATYPE_Int); Set_Progress(0, 100); //----------------------------------------------------- do { Process_Set_Text(CSG_String::Format(SG_T("Loaded arcs: %d"), pShapes->Get_Count())); if( (line = E00_Read_Line()) == NULL ) { covnum = -1; } else { sscanf(line, "%d %d %d %d %d %d %d", &covnum, &cov_id, &fnode, &tnode, &lpol, &rpol, &nPoints); } if( covnum != -1 ) { pShape = pShapes->Add_Shape(); pShape->Set_Value(0 , covnum); pShape->Set_Value(1 , cov_id); pShape->Set_Value(ARC_FNODE , fnode); pShape->Set_Value(ARC_TNODE , tnode); pShape->Set_Value(ARC_LPOL , lpol); pShape->Set_Value(ARC_RPOL , rpol); //--------------------------------------------- if( prec ) // double precision : 1 coord pair / line { for(iPoint=0; iPointAdd_Point(x_buf[0] * scale, y_buf[0] * scale); } } } //--------------------------------------------- else // single precision : 2 x,y pairs / line { for(iPoint=0; iPointAdd_Point(x_buf[0] * scale, y_buf[0] * scale); if( iPoint + 1 < nPoints ) { pShape->Add_Point(x_buf[1] * scale, y_buf[1] * scale); } } } } } } while( covnum != -1 && line && Process_Get_Okay(false) ); //----------------------------------------------------- if( pShapes->Get_Count() == 0 ) { delete(pShapes); shape_type = SHAPE_TYPE_Point; return( NULL ); } if( shape_type == SHAPE_TYPE_Polygon ) { pShapes = Arcs2Polygons(pShapes); Assign_Attributes(pShapes); } return( pShapes ); } //--------------------------------------------------------- CSG_Shapes * CESRI_E00_Import::Arcs2Polygons(CSG_Shapes *pArcs) { //----------------------------------------------------- Process_Set_Text(_TL("Arcs to polygons")); CSG_Shapes *pPolygons = SG_Create_Shapes(SHAPE_TYPE_Polygon); pPolygons->Add_Field("ID", SG_DATATYPE_Int); //----------------------------------------------------- for(int iArc=0; iArcGet_Count() && Set_Progress(iArc, pArcs->Get_Count()); iArc++) { Arcs2Polygon(pArcs, pPolygons, pArcs->Get_Shape(iArc)->asInt(ARC_LPOL)); Arcs2Polygon(pArcs, pPolygons, pArcs->Get_Shape(iArc)->asInt(ARC_RPOL)); } //----------------------------------------------------- delete(pArcs); pPolygons->Make_Clean(); return( pPolygons ); } //--------------------------------------------------------- void CESRI_E00_Import::Arcs2Polygon(CSG_Shapes *pArcs, CSG_Shapes *pPolygons, int id) { //----------------------------------------------------- if( id <= 1 ) { return; } //----------------------------------------------------- CSG_Shapes Segments(SHAPE_TYPE_Line); Segments.Add_Field("FNODE", SG_DATATYPE_Int); Segments.Add_Field("TNODE", SG_DATATYPE_Int); //----------------------------------------------------- for(int iArc=0; iArcGet_Count(); iArc++) { CSG_Shape *pArc = pArcs->Get_Shape(iArc); if( id == pArc->asInt(ARC_LPOL) ) { CSG_Shape *pSegment = Segments.Add_Shape(); pSegment->Set_Value(0, pArc->asInt(ARC_FNODE)); pSegment->Set_Value(1, pArc->asInt(ARC_TNODE)); for(int iVertex=0; iVertexGet_Point_Count(0); iVertex++) { pSegment->Add_Point(pArc->Get_Point(iVertex, 0, false), 0); } pArc->Set_Value(ARC_LPOL, -1); } else if( id == pArc->asInt(ARC_RPOL) ) { CSG_Shape *pSegment = Segments.Add_Shape(); pSegment->Set_Value(1, pArc->asInt(ARC_FNODE)); pSegment->Set_Value(0, pArc->asInt(ARC_TNODE)); for(int iVertex=0; iVertexGet_Point_Count(0); iVertex++) { pSegment->Add_Point(pArc->Get_Point(iVertex, 0, true), 0); } pArc->Set_Value(ARC_RPOL, -1); } } if( Segments.Get_Count() <= 0 ) { return; } //----------------------------------------------------- CSG_Shape *pPolygon = pPolygons->Add_Shape(); pPolygon->Set_Value(0, id); while( Segments.Get_Count() > 0 ) { CSG_Shape *pSegment = Segments.Get_Shape(0); int iPart = pPolygon->Get_Part_Count(); do { for(int iVertex=0; iVertexGet_Point_Count(0); iVertex++) { pPolygon->Add_Point(pSegment->Get_Point(iVertex), iPart); } int fNode = pSegment->asInt(0); int tNode = pSegment->asInt(1); Segments.Del_Shape(pSegment); pSegment = NULL; if( fNode != tNode ) { for(int iSegment=0; iSegmentasInt(1) ) { pSegment = Segments.Get_Shape(iSegment); } } } } while( pSegment ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shapes * CESRI_E00_Import::getlabels(int prec, double scale) // shape_type: LINE or AREA { const char *line; int num, id; // coverage-# and coverage-ID double x, y; CSG_Shapes *pShapes; CSG_Shape *pShape; pShapes = SG_Create_Shapes(SHAPE_TYPE_Point); pShapes->Add_Field("ID#" , SG_DATATYPE_Int); pShapes->Add_Field("ID" , SG_DATATYPE_Int); while( (line = E00_Read_Line()) != NULL ) { sscanf(line, "%d %d %lf %lf", &id, &num, &x, &y); if( id == -1 ) { break; } else { pShape = pShapes->Add_Shape(); pShape->Add_Point(x * scale, y * scale); pShape->Set_Value(0, num); pShape->Set_Value(1, id); //--------------------------------------------- E00_Read_Line(); // 4 values to skip if( prec ) { E00_Read_Line(); // on 2nd line when double precision } } } if( pShapes->Get_Count() <= 0 ) { delete( pShapes ); pShapes = NULL; } return( pShapes ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shapes * CESRI_E00_Import::getsites(int prec, double scale) { const char *line; int id; double x, y; CSG_Shape *pShape; CSG_Shapes *pShapes; pShapes = SG_Create_Shapes(SHAPE_TYPE_Point); pShapes->Add_Field("ID", SG_DATATYPE_Int); while( (line = E00_Read_Line()) != NULL ) { sscanf(line, "%d %*d %lf %lf", &id, &x, &y); if( id == -1 ) { break; } pShape = pShapes->Add_Shape(); pShape->Add_Point(x * scale, y * scale); pShape->Set_Value(0, id); //------------------------------------------------- E00_Read_Line(); // 4 values to skip if( prec ) { E00_Read_Line(); // on 2nd line when double precision } } if( pShapes->Get_Count() <= 0 ) { delete( pShapes ); pShapes = NULL; } else { Assign_Attributes(pShapes); } return( pShapes ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- double CESRI_E00_Import::getproj(void) { const char *line; double scale = 1.0; while( (line = E00_Read_Line()) != NULL && strncmp(line, "EOP", 3) ) { if( !strncmp(line, "Units", 5) ) { sscanf(line + 6, "%lf", &scale); } } scale = 1.0 / scale; return( scale ); } /////////////////////////////////////////////////////////// // // // info section // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- struct info_Field { char Name[18]; // name of item int Position, // position in data line Size, // size for reading Type; // type of data }; //--------------------------------------------------------- struct info_Table { char Name[34], AI[4]; // XX if Arc/info file, spaces otherwise int uFields, // number of usable items in this table nFields, // number of items in this table ldr; // length of data record long nRecords, // number of data records length; // total length for one data line struct info_Field *Field; // One per field... }; //--------------------------------------------------------- // [06.06.2006] ESRI E00 Import crash fix, James Flemer int CESRI_E00_Import::info_Get_Tables(void) { const char *line; char tmp[12], *p; int i; CSG_String s; CSG_Table *pTable; struct info_Table info; //----------------------------------------------------- while( (line = E00_Read_Line()) != NULL && strncmp(line, "EOI", 3) ) { strncpy(info.Name, line, 32); info.Name[32] = 0; p = strchr(info.Name, ' '); if( p != NULL ) *p = 0; p = strchr(info.Name, '.'); if( p == 0 ) p = info.Name; else p++; s = p; strncpy(info.AI , line + 32, 2); info.AI[2] = 0; strncpy(tmp , line + 34, 4); tmp[ 4] = 0; info.uFields = atoi(tmp); strncpy(tmp , line + 38, 4); tmp[ 4] = 0; info.nFields = atoi(tmp); strncpy(tmp , line + 42, 4); tmp[ 4] = 0; info.ldr = atoi(tmp); strncpy(tmp , line + 46, 11); tmp[11] = 0; info.nRecords = atol(tmp); info.length = 0; info.Field = (struct info_Field *)malloc(info.nFields * sizeof(struct info_Field)); //--------------------------------------------- for(i=0; iAdd_Field("XMIN", SG_DATATYPE_Double); pShapes->Add_Field("YMIN", SG_DATATYPE_Double); pShapes->Add_Field("XMAX", SG_DATATYPE_Double); pShapes->Add_Field("YMAX", SG_DATATYPE_Double); CSG_Table_Record *pRecord = pTable->Get_Record(0); CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Set_Value(0, pRecord->asDouble(0)); pShape->Set_Value(1, pRecord->asDouble(1)); pShape->Set_Value(2, pRecord->asDouble(2)); pShape->Set_Value(3, pRecord->asDouble(3)); pShape->Add_Point(pRecord->asDouble(0), pRecord->asDouble(1)); pShape->Add_Point(pRecord->asDouble(0), pRecord->asDouble(3)); pShape->Add_Point(pRecord->asDouble(2), pRecord->asDouble(3)); pShape->Add_Point(pRecord->asDouble(2), pRecord->asDouble(1)); m_pShapes->Add_Item(pShapes); } delete(pTable); } //--------------------------------------------- else if( !s.CmpNoCase(SG_T("tic")) ) // tick marks { if( m_bTic ) { CSG_Shapes *pShapes = SG_Create_Shapes(SHAPE_TYPE_Point, SG_T("Tick Points")); pShapes->Add_Field("ID", SG_DATATYPE_Int); pShapes->Add_Field("X" , SG_DATATYPE_Double); pShapes->Add_Field("Y" , SG_DATATYPE_Double); for(i=0; iGet_Record_Count(); i++) { CSG_Table_Record *pRecord = pTable->Get_Record(i); CSG_Shape *pShape = pShapes->Add_Shape(); pShape->Set_Value(0, pRecord->asInt (0)); pShape->Set_Value(1, pRecord->asDouble(1)); pShape->Set_Value(2, pRecord->asDouble(2)); pShape->Add_Point(pRecord->asDouble(1), pRecord->asDouble(2)); } m_pShapes->Add_Item(pShapes); } delete(pTable); } //--------------------------------------------- else if( m_bTables ) { m_pTables->Add_Item(pTable); } //--------------------------------------------- else if( pTable != m_pPAT && pTable != m_pAAT ) { delete(pTable); } } } //----------------------------------------------------- // 0 if none, 1 if AAT, 2 if PAT, 3 if both return( m_pPAT ? (m_pAAT ? 3 : 2) : (m_pAAT ? 1 : 0) ); } //--------------------------------------------------------- CSG_Table * CESRI_E00_Import::info_Get_Table(struct info_Table info) { char *buffer_record, *buffer_item; int iRecord, iField; CSG_Table *pTable; CSG_Table_Record *pRecord; //----------------------------------------------------- Process_Set_Text(CSG_String(info.Name)); buffer_record = (char *)malloc(info.length + 3); buffer_item = (char *)malloc(info.length + 3); pTable = SG_Create_Table(); pTable->Set_Name(CSG_String(info.Name)); //----------------------------------------------------- for(iField=0; iFieldAdd_Field(info.Field[iField].Name, SG_DATATYPE_Double); break; case 50: // short / long pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Int); break; case 40: // float pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Double); break; case 10: // short pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_Int); break; default: // string pTable->Add_Field(info.Field[iField].Name, SG_DATATYPE_String); break; } } //----------------------------------------------------- for(iRecord=0; iRecordAdd_Record(); for(iField=0; iFieldGet_Field_Type(iField) ) { default: pRecord->Set_Value(iField, atof(buffer_item)); break; case SG_DATATYPE_Int: pRecord->Set_Value(iField, atoi(buffer_item)); break; case SG_DATATYPE_String: pRecord->Set_Value(iField, CSG_String(buffer_item)); break; } } } //----------------------------------------------------- free(buffer_record); free(buffer_item); return( pTable ); } //--------------------------------------------------------- void CESRI_E00_Import::info_Skip_Table(struct info_Table info) { char *buffer_record; int iRecord; buffer_record = (char *)malloc(info.length + 3); for(iRecord=0; iRecordGet_Field_Count() <= 0 || !m_pPAT || m_pPAT->Get_Field_Count() <= 2 ) { return( false ); } Process_Set_Text(_TL("Assign attributes to shapes...")); int iField, off_Field = pShapes->Get_Field_Count(); for(iField=0; iFieldGet_Field_Count(); iField++) { pShapes->Add_Field(m_pPAT->Get_Field_Name(iField), m_pPAT->Get_Field_Type(iField)); } for(int i=0; iGet_Count() && Set_Progress(i, m_pPAT->Get_Count()); i++) { CSG_Shape *pShape = pShapes->Get_Shape(i); CSG_Table_Record *pRecord = m_pPAT->Get_Record(pShape->asInt(0) - 1); if( pRecord ) { for(iField=0; iFieldGet_Field_Count(); iField++) { if( SG_Data_Type_is_Numeric(m_pPAT->Get_Field_Type(iField)) ) pShape->Set_Value(off_Field + iField, pRecord->asDouble(iField)); else pShape->Set_Value(off_Field + iField, pRecord->asString(iField)); } } } return( true ); /* pShapes->Set_Index(0, TABLE_INDEX_Ascending); m_pPAT ->Set_Index(3, TABLE_INDEX_Ascending); for(int iShape=0, off_Record=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape_byIndex(iShape); int id = pShape->asInt(0); for(int iRecord=off_Record; iRecordGet_Record_Count(); iRecord++) { CSG_Table_Record *pRecord = m_pPAT->Get_Record_byIndex(iRecord); if( id == pRecord->asInt(3) ) { for(iField=0; iFieldGet_Field_Count(); iField++) { if( SG_Data_Type_is_Numeric(m_pPAT->Get_Field_Type(iField)) ) pShape->Set_Value(off_Field + iField, pRecord->asDouble(iField)); else pShape->Set_Value(off_Field + iField, pRecord->asString(iField)); } off_Record++; break; } } } return( true );/**/ } /////////////////////////////////////////////////////////// // // // Skips // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CESRI_E00_Import::skip(char *end) { const char *line; int l = strlen(end); while( (line = E00_Read_Line()) != NULL && strncmp(line, end, l) ); } //--------------------------------------------------------- void CESRI_E00_Import::skip_dat(void) { const char *line; int i = 0; while( (line = E00_Read_Line()) != NULL && i != -1 ) { sscanf(line, "%d", &i); } } //--------------------------------------------------------- void CESRI_E00_Import::skip_msk(void) { const char *line; double xmin, ymin, xmax, ymax, res, sk; long xsize, ysize, nskip; if( (line = E00_Read_Line()) != NULL ) { sscanf(line, "%lf %lf %lf", &xmin, &ymin, &xmax); if( (line = E00_Read_Line()) != NULL ) { sscanf(line, "%lf %lf %ld %ld", &ymax, &res, &xsize, &ysize); sk = ((ymax - ymin) / res) * ((xmax - xmin) / res) / 32.0; nskip = (long)ceil(sk / 7.0); while( nskip-- ) { E00_Read_Line(); } } } } //--------------------------------------------------------- void CESRI_E00_Import::skip_arc(int prec) { const char *line; int i, covnum, nPoints; while( (line = E00_Read_Line()) != NULL ) { sscanf(line, "%d %*d %*d %*d %*d %*d %d", &covnum, &nPoints); if( covnum == -1 ) break; if( prec == 0 ) nPoints = (nPoints + 1) / 2; // number of coordinate lines for(i=0; i&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/io/io_esri_e00 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_esri_e00_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am__dirstamp = $(am__leading_dot)dirstamp am_libio_esri_e00_la_OBJECTS = ESRI_E00_Import.lo MLB_Interface.lo \ e00compr/cpl_conv.lo e00compr/cpl_error.lo \ e00compr/cpl_vsisimple.lo e00compr/e00read.lo \ e00compr/e00write.lo libio_esri_e00_la_OBJECTS = $(am_libio_esri_e00_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(libio_esri_e00_la_SOURCES) DIST_SOURCES = $(libio_esri_e00_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_esri_e00.la libio_esri_e00_la_SOURCES = \ ESRI_E00_Import.cpp\ MLB_Interface.cpp\ e00compr/cpl_conv.c\ e00compr/cpl_error.c\ e00compr/cpl_vsisimple.c\ e00compr/e00read.c\ e00compr/e00write.c\ ESRI_E00_Import.h\ MLB_Interface.h\ e00compr/cpl_conv.h\ e00compr/cpl_error.h\ e00compr/cpl_port.h\ e00compr/cpl_vsi.h\ e00compr/e00compr.h libio_esri_e00_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .c .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/io/io_esri_e00/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_esri_e00/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } e00compr/$(am__dirstamp): @$(MKDIR_P) e00compr @: > e00compr/$(am__dirstamp) e00compr/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) e00compr/$(DEPDIR) @: > e00compr/$(DEPDIR)/$(am__dirstamp) e00compr/cpl_conv.lo: e00compr/$(am__dirstamp) \ e00compr/$(DEPDIR)/$(am__dirstamp) e00compr/cpl_error.lo: e00compr/$(am__dirstamp) \ e00compr/$(DEPDIR)/$(am__dirstamp) e00compr/cpl_vsisimple.lo: e00compr/$(am__dirstamp) \ e00compr/$(DEPDIR)/$(am__dirstamp) e00compr/e00read.lo: e00compr/$(am__dirstamp) \ e00compr/$(DEPDIR)/$(am__dirstamp) e00compr/e00write.lo: e00compr/$(am__dirstamp) \ e00compr/$(DEPDIR)/$(am__dirstamp) libio_esri_e00.la: $(libio_esri_e00_la_OBJECTS) $(libio_esri_e00_la_DEPENDENCIES) $(EXTRA_libio_esri_e00_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_esri_e00_la_OBJECTS) $(libio_esri_e00_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f e00compr/*.$(OBJEXT) -rm -f e00compr/*.lo distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ESRI_E00_Import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@e00compr/$(DEPDIR)/cpl_conv.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@e00compr/$(DEPDIR)/cpl_error.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@e00compr/$(DEPDIR)/cpl_vsisimple.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@e00compr/$(DEPDIR)/e00read.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@e00compr/$(DEPDIR)/e00write.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< .c.obj: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf e00compr/.libs e00compr/_libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f e00compr/$(DEPDIR)/$(am__dirstamp) -rm -f e00compr/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) e00compr/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) e00compr/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/io/io_esri_e00/Makefile.am0000744000175000017500000000143612737416172022602 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_esri_e00.la libio_esri_e00_la_SOURCES =\ ESRI_E00_Import.cpp\ MLB_Interface.cpp\ e00compr/cpl_conv.c\ e00compr/cpl_error.c\ e00compr/cpl_vsisimple.c\ e00compr/e00read.c\ e00compr/e00write.c\ ESRI_E00_Import.h\ MLB_Interface.h\ e00compr/cpl_conv.h\ e00compr/cpl_error.h\ e00compr/cpl_port.h\ e00compr/cpl_vsi.h\ e00compr/e00compr.h libio_esri_e00_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/io/io_esri_e00/MLB_Interface.h0000744000175000017500000000771512737416172023317 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_esri_e00 // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_esri_e00_H #define HEADER_INCLUDED__io_esri_e00_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_esri_e00_EXPORTS #define io_esri_e00_EXPORT _SAGA_DLL_EXPORT #else #define io_esri_e00_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_esri_e00_H saga-2.3.1/src/modules/io/io_esri_e00/MLB_Interface.cpp0000744000175000017500000000346112737416172023644 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("ESRI E00") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2004") ); case MLB_INFO_Description: return( _TL("Import and export filter for ESRI's E00 file exchange format.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|ESRI E00") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "ESRI_E00_Import.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { CSG_Module *pModule; switch( i ) { case 0: pModule = new CESRI_E00_Import; break; default: pModule = NULL; break; } return( pModule ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/io/io_grid/0000775000175000017500000000000012737740005020055 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/io/io_grid/mola.cpp0000744000175000017500000002230712737416173021522 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: mola.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // MOLA.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "mola.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CMOLA_Import::CMOLA_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import MOLA Grid (MEGDR)")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Import Mars Orbit Laser Altimeter (MOLA) grids of the Mars Global Surveyor (MGS) Mission " "(Topographic maps, Mission Experiment Gridded Data Records - MEGDRs). " "Find more information and obtain free data from " "" "Mars Global Surveyor: MOLA (NASA)\n\n" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("MOLA Grids (*.img)|*.img|All Files|*.*") ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Grid Type"), _TL(""), _TL("2 byte integer|4 byte floating point|"), 1 ); Parameters.Add_Choice( NULL , "ORIENT" , _TL("Orientation"), _TL(""), _TL("normal|down under|"), 1 ); } //--------------------------------------------------------- CMOLA_Import::~CMOLA_Import(void) {} //--------------------------------------------------------- bool CMOLA_Import::On_Execute(void) { bool bDown; int xa, xb, y, yy, NX, NY; short *sLine; double D, xMin, yMin; CSG_File Stream; TSG_Data_Type Type; CSG_Grid *pGrid; CSG_String fName, sName; //----------------------------------------------------- pGrid = NULL; switch( Parameters("TYPE")->asInt() ) { case 0: Type = SG_DATATYPE_Short; break; case 1: default: Type = SG_DATATYPE_Float; break; } bDown = Parameters("ORIENT")->asInt() == 1; //----------------------------------------------------- // MEGpxxnyyyrv // 012345678901 // p indicates the product type (A for areoid, C for counts, R for // radius, and T for topography) // xx is the latitude of the upper left corner of the image // n indicates whether the latitude is north (N) or south (S) // yyy is the east longitude of the upper left corner of the image // r is the map resolution using the pattern // c = 4 pixel per degree // e = 16 pixel per degree // f = 32 pixel per degree // g = 64 pixel per degree // h = 128 pixel per degree // (This convention is consistent with that used for the Mars Digital // Image Model [MDIM] archives.) // v is a letter indicating the product version. fName = SG_File_Get_Name(Parameters("FILE")->asString(), false); fName.Make_Upper(); if( fName.Length() < 12 ) { return( false ); } //----------------------------------------------------- switch( fName[3] ) { default: return( false ); case 'A': sName.Printf(SG_T("MOLA: Areoid v%c") , fName[11]); break; case 'C': sName.Printf(SG_T("MOLA: Counts v%c") , fName[11]); break; case 'R': sName.Printf(SG_T("MOLA: Radius v%c") , fName[11]); break; case 'T': sName.Printf(SG_T("MOLA: Topography v%c") , fName[11]); break; } //----------------------------------------------------- switch( fName[10] ) { default: return( false ); case 'C': // 1/4th degree... D = 1.0 / 4.0; NX = 4 * 360; NY = 4 * 180; yMin = - 90.0; xMin = -180.0; break; case 'D': // 1/8th degree... D = 1.0 / 8.0; NX = 8 * 360; NY = 8 * 180; yMin = - 90.0; xMin = -180.0; break; case 'E': // 1/16th degree... D = 1.0 / 16.0; NX = 16 * 360; NY = 16 * 180; yMin = - 90.0; xMin = -180.0; break; case 'F': // 1/32th degree... D = 1.0 / 32.0; NX = 32 * 360; NY = 32 * 180; yMin = - 90.0; xMin = -180.0; break; case 'G': // 1/64th degree... D = 1.0 / 64.0; NX = 64 * 180; NY = 64 * 90; yMin = (fName[6] == 'S' ? -1.0 : 1.0) * fName.Right(8).asInt(); yMin = bDown ? yMin - NY * D : -yMin; xMin = fName.Right(5).asInt(); if( xMin >= 180.0 ) { xMin -= 360.0; } break; case 'H': // 1/128th degree... D = 1.0 / 128.0; NX = 128 * 90; NY = 128 * 44; yMin = (fName[6] == 'S' ? -1.0 : 1.0) * fName.Right(8).asInt(); yMin = bDown ? yMin - NY * D : -yMin; xMin = fName.Right(5).asInt(); if( xMin >= 180.0 ) { xMin -= 360.0; } break; } //----------------------------------------------------- if( Stream.Open(Parameters("FILE")->asString(), SG_FILE_R, true) ) { if( (pGrid = SG_Create_Grid(Type, NX, NY, D, xMin + D / 2.0, yMin + D / 2.0)) != NULL ) { pGrid->Set_Name(sName); pGrid->Set_NoData_Value(-999999); pGrid->Get_Projection().Create(SG_T("+proj=lonlat +units=m +a=3396200.000000 +b=3376200.000000"), SG_PROJ_FMT_Proj4); //--------------------------------------------- sLine = (short *)SG_Malloc(NX * sizeof(short)); for(y=0; ySet_Value(xa, yy, sLine[xa]); } } else { for(xa=0, xb=NX/2; xbSet_Value(xa, yy, sLine[xb]); pGrid->Set_Value(xb, yy, sLine[xa]); } } } //--------------------------------------------- SG_Free(sLine); Parameters("GRID")->Set_Value(pGrid); } } return( pGrid != NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_grid/esri_arcinfo.h0000744000175000017500000001230412737416173022676 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: esri_arcinfo.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // ESRI_ArcInfo.h // // // // Copyright (C) 2007 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // ESRI_ArcInfo.h // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ESRI_ArcInfo_H #define HEADER_INCLUDED__ESRI_ArcInfo_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CESRI_ArcInfo_Import : public CSG_Module { public: CESRI_ArcInfo_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: double Read_Value (CSG_File &Stream); bool Read_Header_Value (const CSG_String &sKey, CSG_String &sLine, int &Value); bool Read_Header_Value (const CSG_String &sKey, CSG_String &sLine, double &Value); bool Read_Header_Line (CSG_File &Stream, CSG_String &sLine); CSG_Grid * Read_Header (CSG_File &Stream, TSG_Data_Type Datatype = SG_DATATYPE_Float); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CESRI_ArcInfo_Export : public CSG_Module_Grid { public: CESRI_ArcInfo_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); private: CSG_String Write_Value (double Value, int Precision, bool bComma); bool Write_Header (CSG_File &Stream, CSG_Grid *pGrid, bool bComma); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ESRI_ArcInfo_H saga-2.3.1/src/modules/io/io_grid/erdas_lan.h0000744000175000017500000001062212737416173022164 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: erdas_lan.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for an Automated Geo-Scientific Analysis // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // erdas_lan.h // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for an Automated // // Geo-Scientific Analysis'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__erdas_lan_H #define HEADER_INCLUDED__erdas_lan_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CErdas_LAN_Import : public CSG_Module { public: CErdas_LAN_Import(void); virtual ~CErdas_LAN_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__erdas_lan_H saga-2.3.1/src/modules/io/io_grid/surfer.h0000744000175000017500000001013112737416173021535 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: surfer.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Surfer.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Surfer.h // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Surfer_H #define HEADER_INCLUDED__Surfer_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CSurfer_Import : public CSG_Module { public: CSurfer_Import(void); virtual ~CSurfer_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Import") ); } protected: virtual bool On_Execute(void); private: }; //--------------------------------------------------------- class CSurfer_Export : public CSG_Module_Grid { public: CSurfer_Export(void); virtual ~CSurfer_Export(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Export") ); } protected: virtual bool On_Execute(void); private: }; #endif // #ifndef HEADER_INCLUDED__Surfer_H saga-2.3.1/src/modules/io/io_grid/esri_arcinfo.cpp0000744000175000017500000004416712737416173023245 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: esri_arcinfo.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // ESRI_ArcInfo.cpp // // // // Copyright (C) 2007 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "esri_arcinfo.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define HDR_NROWS SG_T("NROWS") #define HDR_NCOLS SG_T("NCOLS") #define HDR_X_CORNER SG_T("XLLCORNER") #define HDR_Y_CORNER SG_T("YLLCORNER") #define HDR_X_CENTER SG_T("XLLCENTER") #define HDR_Y_CENTER SG_T("YLLCENTER") #define HDR_CELLSIZE SG_T("CELLSIZE") #define HDR_NODATA SG_T("NODATA_VALUE") #define HDR_BYTEORDER SG_T("BYTE_ORDER") #define HDR_BYTEORDER_HI SG_T("MSB_FIRST") #define HDR_BYTEORDER_LO SG_T("LSB_FIRST") /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CESRI_ArcInfo_Import::CESRI_ArcInfo_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import ESRI Arc/Info Grid")); Set_Author (SG_T("O.Conrad (c) 2007")); Set_Description (_TW( "Import grid from ESRI's Arc/Info grid format.") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format( SG_T("%s|*.asc;*.flt|%s|*.asc|%s|*.flt|%s|*.*"), _TL("ESRI Arc/Info Grids"), _TL("ESRI Arc/Info ASCII Grids (*.asc)"), _TL("ESRI Arc/Info Binary Grids (*.flt)"), _TL("All Files") ) ); CSG_Parameter *pNode; pNode = Parameters.Add_Node( NULL , "NODE_ASCII" , _TL("ASCII Grid Options"), _TL("") ); Parameters.Add_Choice( pNode , "GRID_TYPE" , _TL("Target Grid Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("Integer (2 byte)"), _TL("Integer (4 byte)"), _TL("Floating Point (4 byte)"), _TL("Floating Point (8 byte)") ), 2 ); Parameters.Add_Choice( pNode , "NODATA" , _TL("NoData Value"), _TL("Choose whether the input file's NoData value or a user specified NoData value is written"), CSG_String::Format(SG_T("%s|%s|"), _TL("Input File's NoData Value"), _TL("User Defined NoData Value") ), 0 ); Parameters.Add_Value( pNode , "NODATA_VAL" , _TL("User Defined NoData Value"), _TL(""), PARAMETER_TYPE_Double , -99999.0 ); } //--------------------------------------------------------- bool CESRI_ArcInfo_Import::On_Execute(void) { CSG_File Stream; CSG_String fName; CSG_Grid *pGrid; TSG_Data_Type Datatype; int iNoData; double dNoData; //----------------------------------------------------- pGrid = NULL; fName = Parameters("FILE")->asString(); iNoData = Parameters("NODATA")->asInt(); dNoData = Parameters("NODATA_VAL")->asDouble(); switch( Parameters("GRID_TYPE")->asInt() ) { case 0: Datatype = SG_DATATYPE_Short; break; case 1: Datatype = SG_DATATYPE_Int; break; case 2: default: Datatype = SG_DATATYPE_Float; break; case 3: Datatype = SG_DATATYPE_Double; break; } //------------------------------------------------- // Binary... if( Stream.Open(SG_File_Make_Path(SG_T(""), fName, SG_T("hdr")), SG_FILE_R, false) && (pGrid = Read_Header(Stream)) != NULL ) { if( Stream.Open(SG_File_Make_Path(SG_T(""), fName, SG_T("flt")), SG_FILE_R, true) ) { float *Line = (float *)SG_Malloc(pGrid->Get_NX() * sizeof(float)); for(int iy=0, y=pGrid->Get_NY()-1; iyGet_NY() && !Stream.is_EOF() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--) { Stream.Read(Line, sizeof(float), pGrid->Get_NX()); for(int x=0; xGet_NX(); x++) { pGrid->Set_Value(x, y, Line[x]); } } SG_Free(Line); } else { delete(pGrid); return( false ); } } //------------------------------------------------- // ASCII... else if( Stream.Open(fName, SG_FILE_R, false) && (pGrid = Read_Header(Stream, Datatype)) != NULL ) { double dValue; for(int iy=0, y=pGrid->Get_NY()-1; iyGet_NY() && !Stream.is_EOF() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--) { for(int x=0; xGet_NX(); x++) { dValue = Read_Value(Stream); if( iNoData == 1 && dValue == pGrid->Get_NoData_Value() ) dValue = dNoData; pGrid->Set_Value(x, y, dValue); } } if( iNoData == 1 ) { pGrid->Set_NoData_Value(dNoData); } } //------------------------------------------------- else { return( false ); } //------------------------------------------------- pGrid->Set_Name(SG_File_Get_Name(fName, false)); pGrid->Get_Projection().Load(SG_File_Make_Path(NULL, fName, SG_T("prj"))); Parameters("GRID")->Set_Value(pGrid); return( true ); } //--------------------------------------------------------- inline bool SG_is_Numeric(int Character) { switch( Character ) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '-': case '+': case '.': case ',': case 'e': case 'E': return( true ); } return( false ); } //--------------------------------------------------------- double CESRI_ArcInfo_Import::Read_Value(CSG_File &Stream) { int c; CSG_String s; while( !Stream.is_EOF() && !SG_is_Numeric(c = Stream.Read_Char()) ); // ignore leading white space... if( !Stream.is_EOF() && SG_is_Numeric(c) ) { do { if( c == ',' ) { c = '.'; } s += (char)c; } while( !Stream.is_EOF() && SG_is_Numeric(c = Stream.Read_Char()) ); } return( s.asDouble() ); } //--------------------------------------------------------- bool CESRI_ArcInfo_Import::Read_Header_Line(CSG_File &Stream, CSG_String &sLine) { int c; sLine.Clear(); while( !Stream.is_EOF() && (c = Stream.Read_Char()) != 0x0A ) { if( c != 0x0D ) { sLine += (char)c; } } sLine.Make_Upper(); sLine.Replace(SG_T(","), SG_T(".")); return( sLine.Length() > 0 ); } //--------------------------------------------------------- bool CESRI_ArcInfo_Import::Read_Header_Value(const CSG_String &sKey, CSG_String &sLine, int &Value) { sLine.Make_Upper(); if( sLine.Contains(sKey) ) { CSG_String sValue(sLine.c_str() + sKey.Length()); return( sValue.asInt(Value) ); } return( false ); } //--------------------------------------------------------- bool CESRI_ArcInfo_Import::Read_Header_Value(const CSG_String &sKey, CSG_String &sLine, double &Value) { sLine.Make_Upper(); if( sLine.Contains(sKey) ) { CSG_String sValue(sLine.c_str() + sKey.Length()); return( sValue.asDouble(Value) ); } return( false ); } //--------------------------------------------------------- CSG_Grid * CESRI_ArcInfo_Import::Read_Header(CSG_File &Stream, TSG_Data_Type Datatype) { bool bCorner_X, bCorner_Y; int NX, NY; double CellSize, xMin, yMin, NoData = -9999.0; CSG_String sLine; CSG_Grid *pGrid; //----------------------------------------------------- if( !Stream.is_EOF() ) { //------------------------------------------------- Read_Header_Line(Stream, sLine); if( !Read_Header_Value(HDR_NCOLS , sLine, NX) ) return( NULL ); //------------------------------------------------- Read_Header_Line(Stream, sLine); if( !Read_Header_Value(HDR_NROWS , sLine, NY) ) return( NULL ); //------------------------------------------------- Read_Header_Line(Stream, sLine); if( Read_Header_Value(HDR_X_CORNER, sLine, xMin) ) bCorner_X = true; else if( Read_Header_Value(HDR_X_CENTER, sLine, xMin) ) bCorner_X = false; else return( NULL ); //------------------------------------------------- Read_Header_Line(Stream, sLine); if( Read_Header_Value(HDR_Y_CORNER, sLine, yMin) ) bCorner_Y = true; else if( Read_Header_Value(HDR_Y_CENTER, sLine, yMin) ) bCorner_Y = false; else return( NULL ); //------------------------------------------------- Read_Header_Line(Stream, sLine); if( !Read_Header_Value(HDR_CELLSIZE, sLine, CellSize) ) return( NULL ); //------------------------------------------------- Read_Header_Line(Stream, sLine); if( !Read_Header_Value(HDR_NODATA , sLine, NoData) ) // return( NULL ); {} //------------------------------------------------- if( bCorner_X ) xMin += CellSize / 2.0; if( bCorner_Y ) yMin += CellSize / 2.0; //------------------------------------------------- if( (pGrid = SG_Create_Grid(Datatype, NX, NY, CellSize, xMin, yMin)) != NULL ) { pGrid->Set_NoData_Value(NoData); return( pGrid ); } } return( NULL ); } /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CESRI_ArcInfo_Export::CESRI_ArcInfo_Export(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export ESRI Arc/Info Grid")); Set_Author (SG_T("O.Conrad (c) 2007")); Set_Description (_TW( "Export grid to ESRI's Arc/Info grid format.") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format( SG_T("%s|*.asc;*.flt|%s|*.asc|%s|*.flt|%s|*.*"), _TL("ESRI Arc/Info Grids"), _TL("ESRI Arc/Info ASCII Grids (*.asc)"), _TL("ESRI Arc/Info Binary Grids (*.flt)"), _TL("All Files") ), NULL, true ); Parameters.Add_Choice( NULL , "FORMAT" , _TL("Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("binary"), _TL("ASCII") ), 1 ); Parameters.Add_Choice( NULL , "GEOREF" , _TL("Geo-Reference"), _TL("The grids geo-reference must be related either to the center or the corner of its lower left grid cell."), CSG_String::Format(SG_T("%s|%s|"), _TL("corner"), _TL("center") ), 0 ); Parameters.Add_Value( NULL , "PREC" , _TL("ASCII Precision"), _TL("Number of decimals when writing floating point values in ASCII format."), PARAMETER_TYPE_Int , 4, -1, true ); Parameters.Add_Choice( NULL , "DECSEP" , _TL("ASCII Decimal Separator"), _TL("Applies also to the binary format header file."), CSG_String::Format(SG_T("%s|%s|"), _TL("point (.)"), _TL("comma (,)") ), 0 ); // Parameters.Add_Choice( // NULL , "BYTEORD" , _TL("Binary Byte Order"), // _TL("Byte order when writing floating point values in binary format"), // // CSG_String::Format(SG_T("%s|%s|"), // _TL("most significant first"), // _TL("least significant first") // ), 0 // ); } //--------------------------------------------------------- bool CESRI_ArcInfo_Export::On_Execute(void) { bool bResult, bSwapBytes, bComma; int x, y, iy, Precision; CSG_File Stream; CSG_Grid *pGrid; CSG_String fName; //----------------------------------------------------- bResult = false; pGrid = Parameters("GRID") ->asGrid(); fName = Parameters("FILE") ->asString(); Precision = Parameters("PREC") ->asInt(); bComma = Parameters("DECSEP") ->asInt() == 1; bSwapBytes = false; // bSwapBytes = Parameters("BYTEORD") ->asInt() == 1; //----------------------------------------------------- // Binary... if( Parameters("FORMAT")->asInt() == 0 ) { if( Stream.Open(SG_File_Make_Path(SG_T(""), fName, SG_T("hdr")), SG_FILE_W, false) && Write_Header(Stream, pGrid, bComma) && Stream.Open(SG_File_Make_Path(SG_T(""), fName, SG_T("flt")), SG_FILE_W, true) ) { float *Line = (float *)SG_Malloc(pGrid->Get_NX() * sizeof(float)); for(int iy=0, y=pGrid->Get_NY()-1; iyGet_NY() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--) { for(int x=0; xGet_NX(); x++) { Line[x] = pGrid->asFloat(x, y); if( bSwapBytes ) { SG_Swap_Bytes(Line + x, sizeof(float)); } } Stream.Write(Line, sizeof(float), pGrid->Get_NX()); } SG_Free(Line); pGrid->Get_Projection().Save(SG_File_Make_Path(NULL, fName, SG_T("prj"))); return( true ); } } //----------------------------------------------------- // ASCII... else if( Stream.Open(fName, SG_FILE_W, false) && Write_Header(Stream, pGrid, bComma) ) { for(iy=0, y=pGrid->Get_NY()-1; iyGet_NY() && Set_Progress(iy, pGrid->Get_NY()); iy++, y--) { for(x=0; xGet_NX(); x++) { if( x > 0 ) { fputs(" ",Stream.Get_Stream()); } fputs(Write_Value(pGrid->asDouble(x, y), Precision, bComma).b_str(),Stream.Get_Stream()); } fputs("\n", Stream.Get_Stream()); } pGrid->Get_Projection().Save(SG_File_Make_Path(NULL, fName, SG_T("prj"))); return( true ); } //----------------------------------------------------- return( false ); } //--------------------------------------------------------- inline CSG_String CESRI_ArcInfo_Export::Write_Value(double Value, int Precision, bool bComma) { CSG_String s; if( Precision < 0 ) { s.Printf(SG_T("%f") , Value); } else if( Precision > 0 ) { s.Printf(SG_T("%.*f"), Precision, Value); } else { s.Printf(SG_T("%d") , (int)(Value > 0.0 ? Value + 0.5 : Value - 0.5)); } if( bComma ) { s.Replace(SG_T("."), SG_T(",")); } else { s.Replace(SG_T(","), SG_T(".")); } return( s ); } //--------------------------------------------------------- bool CESRI_ArcInfo_Export::Write_Header(CSG_File &Stream, CSG_Grid *pGrid, bool bComma) { if( Stream.is_Open() && pGrid && pGrid->is_Valid() ) { CSG_String s; s += CSG_String::Format(SG_T("%s %d\n") , HDR_NCOLS , pGrid->Get_NX()); s += CSG_String::Format(SG_T("%s %d\n") , HDR_NROWS , pGrid->Get_NY()); if( Parameters("GEOREF")->asInt() == 0 ) { s += CSG_String::Format(SG_T("%s %s\n") , HDR_X_CORNER , Write_Value(pGrid->Get_XMin() - 0.5 * pGrid->Get_Cellsize(), 10, bComma).c_str()); s += CSG_String::Format(SG_T("%s %s\n") , HDR_Y_CORNER , Write_Value(pGrid->Get_YMin() - 0.5 * pGrid->Get_Cellsize(), 10, bComma).c_str()); } else { s += CSG_String::Format(SG_T("%s %s\n") , HDR_X_CENTER , Write_Value(pGrid->Get_XMin(), 10, bComma).c_str()); s += CSG_String::Format(SG_T("%s %s\n") , HDR_Y_CENTER , Write_Value(pGrid->Get_YMin(), 10, bComma).c_str()); } s += CSG_String::Format(SG_T("%s %s\n") , HDR_CELLSIZE , Write_Value(pGrid->Get_Cellsize(), -1, bComma).c_str()); s += CSG_String::Format(SG_T("%s %s\n") , HDR_NODATA , Write_Value(pGrid->Get_NoData_Value(), Parameters("PREC")->asInt(), bComma).c_str()); if( Parameters("FORMAT")->asInt() == 0 ) // binary { if( Parameters("BYTEORD") ) s += CSG_String::Format(SG_T("%s %s\n") , HDR_BYTEORDER , Parameters("BYTEORD")->asInt() == 1 ? HDR_BYTEORDER_LO : HDR_BYTEORDER_HI); } fputs(s.b_str(),Stream.Get_Stream()); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_grid/raw.cpp0000744000175000017500000002662412737416173021371 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: raw.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Raw.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "raw.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CRaw_Import::CRaw_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("Import Binary Raw Data")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description (_TW( "Imports grid from binary raw data.\n") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE_DATA" , _TL("Raw Data File"), _TL("") ); //----------------------------------------------------- Parameters.Add_Value( NULL , "NX" , _TL("Cell Count (X)"), _TL(""), PARAMETER_TYPE_Int , 1 ); Parameters.Add_Value( NULL , "NY" , _TL("Cell Count (Y)"), _TL(""), PARAMETER_TYPE_Int , 1 ); Parameters.Add_Value( NULL , "DXY" , _TL("Cell Size"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "XMIN" , _TL("Left Border (X)"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( NULL , "YMIN" , _TL("Lower Border (Y)"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_String( NULL , "UNIT" , _TL("Unit Name"), _TL(""), _TL("") ); Parameters.Add_Value( NULL , "ZFACTOR" , _TL("Z Multiplier"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "NODATA" , _TL("No Data Value"), _TL(""), PARAMETER_TYPE_Double , -99999.0 ); Parameters.Add_Value( NULL , "DATA_OFFSET" , _TL("Data Offset (Bytes)"), _TL(""), PARAMETER_TYPE_Int , 0.0 ); Parameters.Add_Value( NULL , "LINE_OFFSET" , _TL("Line Offset (Bytes)"), _TL(""), PARAMETER_TYPE_Int , 0.0 ); Parameters.Add_Value( NULL , "LINE_ENDSET" , _TL("Line Endset (Bytes)"), _TL(""), PARAMETER_TYPE_Int , 0.0 ); Parameters.Add_Choice( NULL , "DATA_TYPE" , _TL("Data Type"), _TL(""), _TW( "1 Byte Integer (unsigned)|" "1 Byte Integer (signed)|" "2 Byte Integer (unsigned)|" "2 Byte Integer (signed)|" "4 Byte Integer (unsigned)|" "4 Byte Integer (signed)|" "4 Byte Floating Point|" "8 Byte Floating Point|" ) ); Parameters.Add_Choice( NULL , "BYTEORDER_BIG" , _TL("Byte Order"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Little Endian (Intel)"), _TL("Big Endian (Motorola)") ), 0 ); Parameters.Add_Choice( NULL , "TOPDOWN" , _TL("Line Order"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Bottom to Top"), _TL("Top to Bottom") ), 0 ); } //--------------------------------------------------------- CRaw_Import::~CRaw_Import(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CRaw_Import::On_Execute(void) { bool bDown, bBig; int nx, ny, data_head, line_head, line_tail; double dxy, xmin, ymin, zFactor, zNoData; FILE *Stream; TSG_Data_Type data_type; CSG_String FileName, Unit; CSG_Grid *pGrid; //----------------------------------------------------- pGrid = NULL; FileName = Parameters("FILE_DATA") ->asString(); nx = Parameters("NX") ->asInt(); ny = Parameters("NY") ->asInt(); dxy = Parameters("DXY") ->asDouble(); xmin = Parameters("XMIN") ->asDouble(); ymin = Parameters("YMIN") ->asDouble(); data_head = Parameters("DATA_OFFSET") ->asInt(); line_head = Parameters("LINE_OFFSET") ->asInt(); line_tail = Parameters("LINE_ENDSET") ->asInt(); bDown = Parameters("TOPDOWN") ->asInt() == 1; bBig = Parameters("BYTEORDER_BIG") ->asInt() == 1; Unit = Parameters("UNIT") ->asString(); zFactor = Parameters("ZFACTOR") ->asDouble(); zNoData = Parameters("NODATA") ->asDouble(); switch( Parameters("DATA_TYPE")->asInt() ) { default: data_type = SG_DATATYPE_Undefined; break; // not handled case 0: data_type = SG_DATATYPE_Byte; break; // 1 Byte Integer (unsigned) case 1: data_type = SG_DATATYPE_Char; break; // 1 Byte Integer (signed) case 2: data_type = SG_DATATYPE_Word; break; // 2 Byte Integer (unsigned) case 3: data_type = SG_DATATYPE_Short; break; // 2 Byte Integer (signed) case 4: data_type = SG_DATATYPE_DWord; break; // 4 Byte Integer (unsigned) case 5: data_type = SG_DATATYPE_Int; break; // 4 Byte Integer (signed) case 6: data_type = SG_DATATYPE_Float; break; // 4 Byte Floating Point case 7: data_type = SG_DATATYPE_Double; break; // 8 Byte Floating Point } //----------------------------------------------------- if( data_type != SG_DATATYPE_Undefined && (Stream = fopen(FileName.b_str(), "rb")) != NULL ) { if( (pGrid = Load_Data(Stream, data_type, nx, ny, dxy, xmin, ymin, data_head, line_head, line_tail, bDown, bBig)) != NULL ) { pGrid->Set_Unit (Unit); pGrid->Set_Scaling (zFactor); pGrid->Set_NoData_Value (zNoData); pGrid->Set_Name (SG_File_Get_Name(FileName, false)); Parameters("GRID")->Set_Value(pGrid); } fclose(Stream); } //----------------------------------------------------- return( pGrid != NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Grid * CRaw_Import::Load_Data(FILE *Stream, TSG_Data_Type data_type, int nx, int ny, double dxy, double xmin, double ymin, int data_head, int line_head, int line_tail, bool bDown, bool bBig) { char *pLine, *pValue; int x, y, nBytes_Value, nBytes_Line; CSG_Grid *pGrid = NULL; //----------------------------------------------------- if( Stream && data_type != SG_DATATYPE_Undefined ) { for(x=0; xGet_NY() && !feof(Stream) && Set_Progress(y, pGrid->Get_NY()); y++) { for(x=0; xGet_NX(); x++, pValue+=nBytes_Value) { if( bBig ) { SG_Swap_Bytes(pValue, nBytes_Value); } switch( data_type ) { case SG_DATATYPE_Byte: pGrid->Set_Value(x, y, *(unsigned char *)pValue); break; // 1 Byte Integer (unsigned) case SG_DATATYPE_Char: pGrid->Set_Value(x, y, *(signed char *)pValue); break; // 1 Byte Integer (signed) case SG_DATATYPE_Word: pGrid->Set_Value(x, y, *(unsigned short *)pValue); break; // 2 Byte Integer (unsigned) case SG_DATATYPE_Short: pGrid->Set_Value(x, y, *(signed short *)pValue); break; // 2 Byte Integer (signed) case SG_DATATYPE_DWord: pGrid->Set_Value(x, y, *(unsigned int *)pValue); break; // 4 Byte Integer (unsigned) case SG_DATATYPE_Int: pGrid->Set_Value(x, y, *(signed int *)pValue); break; // 4 Byte Integer (signed) case SG_DATATYPE_Float: pGrid->Set_Value(x, y, *(float *)pValue); break; // 4 Byte Floating Point case SG_DATATYPE_Double: pGrid->Set_Value(x, y, *(double *)pValue); break; // 8 Byte Floating Point } } for(x=0; xFlip(); } } } //----------------------------------------------------- return( pGrid ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_grid/wrf.cpp0000744000175000017500000010471512737416173021374 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wrf.cpp 911 2011-11-11 11:11:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // wrf.cpp // // // // Copyright (C) 2011 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "wrf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// #define VAL_CATEGORICAL 0 #define VAL_CONTINUOUS 1 #define VAL_ENDIAN_BIG 0 #define VAL_ENDIAN_LITTLE 1 #define VAL_BOTTOM_TOP 0 #define VAL_TOP_BOTTOM 1 //--------------------------------------------------------- CWRF_Index::CWRF_Index(void) { Reset(); } //--------------------------------------------------------- bool CWRF_Index::Reset(void) { m_PROJECTION = SG_T(""); // A character string specifying the projection of the data, which may be // either lambert, polar, mercator, regular_ll, albers_nad83, or polar_wgs84. // No default value. m_TYPE = 0; // A character string, either categorical or continuous, that determines // whether the data in the data files should be interpreted as a continuous field or as discrete // indices. For categorical data represented by a fractional field for each possible category, // type should be set to continuous. // No default value. m_SIGNED = false; // Either yes or no, indicating whether the values in the data files (which are // always represented as integers) are signed in two's complement form or not. // Default value is no. m_UNITS = SG_T(""); // A character string, enclosed in quotation marks ("), specifying the units of the // interpolated field; the string will be written to the geogrid output files as a variable timeindependent // attribute. // No default value. m_DESCRIPTION = SG_T(""); // A character string, enclosed in quotation marks ("), giving a short // description of the interpolated field; the string will be written to the geogrid output files // as a variable time-independent attribute. // No default value. m_DX = 0.0; // A real value giving the grid spacing in the x-direction of the data set. If // projection is one of lambert, polar, mercator, albers_nad83, or polar_wgs84, dx // gives the grid spacing in meters; if projection is regular_ll, dx gives the grid spacing // in degrees. // No default value. m_DY = 0.0; // A real value giving the grid spacing in the y-direction of the data set. If // projection is one of lambert, polar, mercator, albers_nad83, or polar_wgs84, dy // gives the grid spacing in meters; if projection is regular_ll, dy gives the grid spacing // in degrees. // No default value. m_KNOWN_X = 1.0; // A real value specifying the i-coordinate of an (i,j) location // corresponding to a (latitude, longitude) location that is known in the projection. // Default value is 1. m_KNOWN_Y = 1.0; // A real value specifying the j-coordinate of an (i,j) location // corresponding to a (latitude, longitude) location that is known in the projection. // Default value is 1. m_KNOWN_LAT = 0.0; // A real value specifying the latitude of a (latitude, longitude) // location that is known in the projection. // No default value. m_KNOWN_LON = 0.0; // A real value specifying the longitude of a (latitude, longitude) // location that is known in the projection. // No default value. m_STDLON = 0.0; // A real value specifying the longitude that is parallel with the y-axis in // conic and azimuthal projections. // No default value. m_TRUELAT1 = 0.0; // A real value specifying the first true latitude for conic projections or // the only true latitude for azimuthal projections. // No default value. m_TRUELAT2 = 0.0; // A real value specifying the second true latitude for conic projections. // No default value. m_WORDSIZE = 1; // An integer giving the number of bytes used to represent the value of // each grid point in the data files. // No default value. m_TILE_X = 0; // An integer specifying the number of grid points in the x-direction, // excluding any halo points, for a single tile of source data. // No default value. m_TILE_Y = 0; // An integer specifying the number of grid points in the y-direction, // excluding any halo points, for a single tile of source data. // No default value. m_TILE_Z = 1; // An integer specifying the number of grid points in the z-direction for a // single tile of source data; this keyword serves as an alternative to the pair of keywords // tile_z_start and tile_z_end, and when this keyword is used, the starting z-index is // assumed to be 1. // No default value. m_TILE_Z_START = 1; // An integer specifying the starting index in the z-direction of the // array in the data files. If this keyword is used, tile_z_end must also be specified. // No default value. m_TILE_Z_END = 1; // An integer specifying the ending index in the z-direction of the array // in the data files. If this keyword is used, tile_z_start must also be specified. // No default value m_CATEGORY_MIN = 0; // For categorical data (type=categorical), an integer specifying // the minimum category index that is found in the data set. If this keyword is used, // category_max must also be specified. // No default value. m_CATEGORY_MAX = 0; // For categorical data (type=categorical), an integer // specifying the maximum category index that is found in the data set. If this keyword is // used, category_min must also be specified. // No default value. m_TILE_BDR = 0; // An integer specifying the halo width, in grid points, for each tile of data. // Default value is 0. m_MISSING_VALUE = -99999.0; // A real value that, when encountered in the data set, should be interpreted as missing data. // No default value. m_SCALE_FACTOR = 1.0; // A real value that data should be scaled by (through // multiplication) after being read in as integers from tiles of the data set. // Default value is 1. m_ROW_ORDER = VAL_BOTTOM_TOP; // A character string, either bottom_top or top_bottom, specifying // whether the rows of the data set arrays were written proceeding from the lowest-index // row to the highest (bottom_top) or from highest to lowest (top_bottom). This keyword // may be useful when utilizing some USGS data sets, which are provided in top_bottom // order. // Default value is bottom_top. m_ENDIAN = VAL_ENDIAN_BIG; // A character string, either big or little, specifying whether the values in // the static data set arrays are in big-endian or little-endian byte order. // Default value is big. m_ISWATER = 16; // An integer specifying the land use category of water. // Default value is 16. m_ISLAKE = -1; // An integer specifying the land use category of inland water bodies. // Default value is -1 (i.e., no separate inland water category). m_ISICE = 24; // An integer specifying the land use category of ice. // Default value is 24. m_ISURBAN = 1; // An integer specifying the land use category of urban areas. // Default value is 1. m_ISOILWATER = 14; // An integer specifying the soil category of water. // Default value is 14. m_MMINLU = SG_T("USGS"); // A character string, enclosed in quotation marks ("), indicating which // section of WRF's LANDUSE.TBL and VEGPARM.TBL will be used when looking up // parameters for land use categories. // Default value is "USGS". return( true ); } //--------------------------------------------------------- bool CWRF_Index::Load(const CSG_String &File) { Reset(); CSG_File Stream; if( !Stream.Open(File, SG_FILE_R, false) ) { return( false ); } CSG_String sLine, sKey, sValue; while( Stream.Read_Line(sLine) ) { sKey = sLine.BeforeFirst(SG_T('=')).Make_Upper(); sKey .Trim(); sKey .Trim(true); sValue = sLine.AfterFirst (SG_T('=')).Make_Upper(); sValue.Trim(); sValue.Trim(true); if( !sKey.Cmp(SG_T("PROJECTION")) ) { m_PROJECTION = sValue; } else if( !sKey.Cmp(SG_T("TYPE")) ) { m_TYPE = sValue.Contains(SG_T("CATEGORICAL")) ? VAL_CATEGORICAL : VAL_CONTINUOUS; } else if( !sKey.Cmp(SG_T("SIGNED")) ) { m_SIGNED = sValue.Contains(SG_T("YES")); } else if( !sKey.Cmp(SG_T("UNITS")) ) { m_UNITS = sValue; } else if( !sKey.Cmp(SG_T("DESCRIPTION")) ) { m_DESCRIPTION = sValue; } else if( !sKey.Cmp(SG_T("DX")) ) { m_DX = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("DY")) ) { m_DY = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("KNOWN_X")) ) { m_KNOWN_X = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("KNOWN_Y")) ) { m_KNOWN_Y = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("KNOWN_LAT")) ) { m_KNOWN_LAT = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("KNOWN_LON")) ) { m_KNOWN_LON = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("STDLON")) ) { m_STDLON = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("TRUELAT1")) ) { m_TRUELAT1 = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("TRUELAT2")) ) { m_TRUELAT2 = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("WORDSIZE")) ) { m_WORDSIZE = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_X")) ) { m_TILE_X = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_Y")) ) { m_TILE_Y = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_Z")) ) { m_TILE_Z = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_Z_START")) ) { m_TILE_Z_START = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_Z_END")) ) { m_TILE_Z_END = sValue.asInt(); } else if( !sKey.Cmp(SG_T("CATEGORY_MIN")) ) { m_CATEGORY_MIN = sValue.asInt(); } else if( !sKey.Cmp(SG_T("CATEGORY_MAX")) ) { m_CATEGORY_MAX = sValue.asInt(); } else if( !sKey.Cmp(SG_T("TILE_BDR")) ) { m_TILE_BDR = sValue.asInt(); } else if( !sKey.Cmp(SG_T("MISSING_VALUE")) ) { m_MISSING_VALUE = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("SCALE_FACTOR")) ) { m_SCALE_FACTOR = sValue.asDouble(); } else if( !sKey.Cmp(SG_T("ROW_ORDER")) ) { m_ROW_ORDER = sValue.Contains(SG_T("BOTTOM_TOP")) ? VAL_BOTTOM_TOP : VAL_TOP_BOTTOM; } else if( !sKey.Cmp(SG_T("ENDIAN")) ) { m_ENDIAN = sValue.Contains(SG_T("BIG")) ? VAL_ENDIAN_BIG : VAL_ENDIAN_LITTLE; } else if( !sKey.Cmp(SG_T("ISWATER")) ) { m_ISWATER = sValue.asInt(); } else if( !sKey.Cmp(SG_T("ISLAKE")) ) { m_ISLAKE = sValue.asInt(); } else if( !sKey.Cmp(SG_T("ISICE")) ) { m_ISICE = sValue.asInt(); } else if( !sKey.Cmp(SG_T("ISURBAN")) ) { m_ISURBAN = sValue.asInt(); } else if( !sKey.Cmp(SG_T("ISOILWATER")) ) { m_ISOILWATER = sValue.asInt(); } else if( !sKey.Cmp(SG_T("MMINLU")) ) { m_MMINLU = sValue; } } return( true ); } //--------------------------------------------------------- bool CWRF_Index::Save(const CSG_String &File) { CSG_File Stream; if( !Stream.Open(File, SG_FILE_W, false) ) { return( false ); } //----------------------------------------------------- Stream.Printf(SG_T("%s=%s\n"), SG_T("TYPE") , m_TYPE == VAL_CATEGORICAL ? SG_T("CATEGORICAL") : SG_T("CONTINUOUS")); if( m_CATEGORY_MIN < m_CATEGORY_MAX ) { Stream.Printf(SG_T("%s=%d\n"), SG_T("CATEGORY_MIN") , m_CATEGORY_MIN); Stream.Printf(SG_T("%s=%d\n"), SG_T("CATEGORY_MAX") , m_CATEGORY_MAX); } Stream.Printf(SG_T("%s=%s\n"), SG_T("PROJECTION") , m_PROJECTION.c_str()); if( m_PROJECTION.CmpNoCase(SG_T("regular_ll")) ) { Stream.Printf(SG_T("%s=%f\n"), SG_T("STDLON") , m_STDLON); Stream.Printf(SG_T("%s=%f\n"), SG_T("TRUELAT1") , m_TRUELAT1); Stream.Printf(SG_T("%s=%f\n"), SG_T("TRUELAT2") , m_TRUELAT2); } Stream.Printf(SG_T("%s=%.8f\n"), SG_T("DX") , m_DX); Stream.Printf(SG_T("%s=%.8f\n"), SG_T("DY") , m_DY); Stream.Printf(SG_T("%s=%f\n"), SG_T("KNOWN_X") , m_KNOWN_X); Stream.Printf(SG_T("%s=%f\n"), SG_T("KNOWN_Y") , m_KNOWN_Y); Stream.Printf(SG_T("%s=%.5f\n"), SG_T("KNOWN_LAT") , m_KNOWN_LAT); Stream.Printf(SG_T("%s=%.5f\n"), SG_T("KNOWN_LON") , m_KNOWN_LON); if( m_SIGNED ) { Stream.Printf(SG_T("%s=%s\n"), SG_T("SIGNED") , SG_T("YES")); } Stream.Printf(SG_T("%s=%d\n"), SG_T("WORDSIZE") , m_WORDSIZE); Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_X") , m_TILE_X); Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_Y") , m_TILE_Y); if( m_TILE_Z == 1 ) { Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_Z") , m_TILE_Z); } else { Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_Z_START") , m_TILE_Z_START); Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_Z_END") , m_TILE_Z_END); } if( m_TILE_BDR > 0 ) { Stream.Printf(SG_T("%s=%d\n"), SG_T("TILE_BDR") , m_TILE_BDR); } Stream.Printf(SG_T("%s=%f\n"), SG_T("MISSING_VALUE") , m_MISSING_VALUE); if( m_SCALE_FACTOR != 1.0 ) { Stream.Printf(SG_T("%s=%f\n"), SG_T("SCALE_FACTOR") , m_SCALE_FACTOR); } if( m_ROW_ORDER == VAL_TOP_BOTTOM ) { Stream.Printf(SG_T("%s=%s\n"), SG_T("ROW_ORDER") , SG_T("TOP_BOTTOM")); } if( m_ENDIAN == VAL_ENDIAN_LITTLE ) { Stream.Printf(SG_T("%s=%s\n"), SG_T("ENDIAN") , SG_T("LITTLE")); } if( m_TYPE == VAL_CATEGORICAL ) { Stream.Printf(SG_T("%s=\"%s\"\n"), SG_T("UNITS") , SG_T("CATEGORY")); } else if( m_UNITS.Length() > 0 ) { Stream.Printf(SG_T("%s=\"%s\"\n"), SG_T("UNITS") , m_UNITS.c_str()); } if( m_DESCRIPTION.Length() > 0 ) { Stream.Printf(SG_T("%s=\"%s\"\n"), SG_T("DESCRIPTION") , m_DESCRIPTION.c_str()); } if( m_MMINLU.CmpNoCase(SG_T("USGS")) ) { Stream.Printf(SG_T("%s=%s\n"), SG_T("MMINLU") , m_MMINLU.c_str()); } if( m_ISWATER != 16 ) Stream.Printf(SG_T("%s=%d\n"), SG_T("ISWATER") , m_ISWATER); if( m_ISLAKE != -1 ) Stream.Printf(SG_T("%s=%d\n"), SG_T("ISLAKE") , m_ISLAKE); if( m_ISICE != 24 ) Stream.Printf(SG_T("%s=%d\n"), SG_T("_ISICE") , m_ISICE); if( m_ISURBAN != 1 ) Stream.Printf(SG_T("%s=%d\n"), SG_T("m_ISURBAN") , m_ISURBAN); if( m_ISOILWATER != 14 ) Stream.Printf(SG_T("%s=%d\n"), SG_T("m_ISOILWATER"), m_ISOILWATER); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWRF_Import::CWRF_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import WRF Geogrid Binary Format")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Imports grid(s) from Weather Research and Forcasting Model (WRF) geogrid binary format." "\n" "WRF Homepage" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL("") ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWRF_Import::On_Execute(void) { CSG_String File; //----------------------------------------------------- File = Parameters("FILE") ->asString(); Parameters("GRIDS")->asGridList()->Del_Items(); //----------------------------------------------------- if( !m_Index.Load(SG_File_Make_Path(SG_File_Get_Path(File), SG_T("index"))) ) { Error_Set(_TL("error reading index file")); return( false ); } //----------------------------------------------------- if( !Load(File) ) { Error_Set(_TL("error loading data file")); return( false ); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWRF_Import::Load(const CSG_String &File) { //----------------------------------------------------- // 00001-00600.00001-00600 // 01234567890123456789012 CSG_String Name = SG_File_Get_Name(File, true); if( Name.Length() != 23 || Name[5] != SG_T('-') || Name[11] != SG_T('.') || Name[17] != SG_T('-') ) { Error_Set(_TL("invalid geogrid file name")); return( false ); } int xOffset = Name.asInt() - 1; int yOffset = Name.AfterFirst(SG_T('.')).asInt() - 1; //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(File, SG_FILE_R) ) { Error_Set(_TL("data file could not be openend")); return( false ); } //----------------------------------------------------- TSG_Data_Type Type; switch( m_Index.m_WORDSIZE ) { default: Error_Set(_TL("invalid word size")); return( false ); case 1: Type = m_Index.m_SIGNED == false ? SG_DATATYPE_Byte : SG_DATATYPE_Char; break; case 2: Type = m_Index.m_SIGNED == false ? SG_DATATYPE_Word : SG_DATATYPE_Short; break; case 4: Type = m_Index.m_SIGNED == false ? SG_DATATYPE_DWord : SG_DATATYPE_Int; break; } //----------------------------------------------------- char *pLine, *pValue; int x, y, nBytes_Line; nBytes_Line = (m_Index.m_TILE_X + 2 * m_Index.m_TILE_BDR) * m_Index.m_WORDSIZE; pLine = (char *)SG_Malloc(nBytes_Line); //----------------------------------------------------- for(int z=m_Index.m_TILE_Z_START; z<=m_Index.m_TILE_Z_END && !Stream.is_EOF() && Process_Get_Okay(); z++) { CSG_Grid *pGrid = SG_Create_Grid( Type, m_Index.m_TILE_X + 2 * m_Index.m_TILE_BDR, m_Index.m_TILE_Y + 2 * m_Index.m_TILE_BDR, m_Index.m_DX, m_Index.m_KNOWN_LON + (xOffset - m_Index.m_TILE_BDR) * m_Index.m_DX, m_Index.m_KNOWN_LAT + (yOffset - m_Index.m_TILE_BDR) * m_Index.m_DY ); pGrid->Set_Name (CSG_String::Format(SG_T("%s_%02d"), SG_File_Get_Name(File, false).c_str(), z)); pGrid->Set_Description (m_Index.m_DESCRIPTION); pGrid->Set_Unit (m_Index.m_UNITS); pGrid->Set_NoData_Value (m_Index.m_MISSING_VALUE); pGrid->Set_Scaling (m_Index.m_SCALE_FACTOR); Parameters("GRIDS")->asGridList()->Add_Item(pGrid); //------------------------------------------------- for(y=0; yGet_NY() && !Stream.is_EOF() && Set_Progress(y, pGrid->Get_NY()); y++) { int yy = m_Index.m_ROW_ORDER == VAL_TOP_BOTTOM ? pGrid->Get_NY() - 1 - y : y; Stream.Read(pLine, sizeof(char), nBytes_Line); for(x=0, pValue=pLine; xGet_NX(); x++, pValue+=m_Index.m_WORDSIZE) { if( m_Index.m_ENDIAN == VAL_ENDIAN_BIG ) { SG_Swap_Bytes(pValue, m_Index.m_WORDSIZE); } switch( pGrid->Get_Type() ) { case SG_DATATYPE_Byte: pGrid->Set_Value(x, yy, *(unsigned char *)pValue); break; // 1 Byte Integer (unsigned) case SG_DATATYPE_Char: pGrid->Set_Value(x, yy, *(signed char *)pValue); break; // 1 Byte Integer (signed) case SG_DATATYPE_Word: pGrid->Set_Value(x, yy, *(unsigned short *)pValue); break; // 2 Byte Integer (unsigned) case SG_DATATYPE_Short: pGrid->Set_Value(x, yy, *(signed short *)pValue); break; // 2 Byte Integer (signed) case SG_DATATYPE_DWord: pGrid->Set_Value(x, yy, *(unsigned int *)pValue); break; // 4 Byte Integer (unsigned) case SG_DATATYPE_Int: pGrid->Set_Value(x, yy, *(signed int *)pValue); break; // 4 Byte Integer (signed) } } } } //----------------------------------------------------- SG_Free(pLine); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWRF_Export::CWRF_Export(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export WRF Geogrid Binary Format")); Set_Author (SG_T("O.Conrad (c) 2011")); Set_Description (_TW( "Exports grid(s) to Weather Research and Forcasting Model (WRF) geogrid binary format." "\n" "WRF Homepage" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("Directory"), _TL(""), NULL, NULL, true, true ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_TYPE", _TL("Projection"), _TL("")); Parameters.Add_Choice( pNode , "DATATYPE" , _TL("Data Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("1 byte unsigned"), _TL("1 byte signed"), _TL("2 byte unsigned"), _TL("2 byte signed"), _TL("4 byte unsigned"), _TL("4 byte signed") ), 0 ); Parameters.Add_Choice( pNode , "TYPE" , _TL("Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("categorical"), _TL("continuous") ), 0 ); Parameters.Add_Value(pNode , "MISSING" , _TL("Missing Value") , _TL(""), PARAMETER_TYPE_Double, m_Index.m_MISSING_VALUE); Parameters.Add_Value(pNode , "SCALE" , _TL("Scale Factor") , _TL(""), PARAMETER_TYPE_Double, m_Index.m_SCALE_FACTOR); Parameters.Add_String(pNode , "UNITS" , _TL("Units") , _TL(""), m_Index.m_UNITS); Parameters.Add_String(pNode , "DESCRIPTION" , _TL("Description") , _TL(""), m_Index.m_DESCRIPTION); Parameters.Add_String(pNode , "MMINLU" , _TL("Look Up Section") , _TL(""), m_Index.m_MMINLU); Parameters.Add_Value(pNode , "TILE_BDR" , _TL("Halo Width") , _TL(""), PARAMETER_TYPE_Int, 0, 0, true); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_PRJ", _TL("Projection"), _TL("")); Parameters.Add_Choice( pNode , "PROJECTION" , _TL("Projection"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s|"), SG_T("lambert"), SG_T("polar"), SG_T("mercator"), SG_T("regular_ll"), SG_T("albers_nad83"), SG_T("polar_wgs84") ), 3 ); Parameters.Add_Value(pNode , "SDTLON" , _TL("Standard Longitude") , _TL(""), PARAMETER_TYPE_Double, 0.0); Parameters.Add_Value(pNode , "TRUELAT1" , _TL("True Latitude 1") , _TL(""), PARAMETER_TYPE_Double, 45.0); Parameters.Add_Value(pNode , "TRUELAT2" , _TL("True Latitude 2") , _TL(""), PARAMETER_TYPE_Double, 35.0); //----------------------------------------------------- // pNode = Parameters.Add_Node(NULL, "NODE_REF", _TL("Referencing"), _TL("")); // Parameters.Add_Value(pNode , "KNOWN_X" , _TL("Known X") , _TL(""), PARAMETER_TYPE_Double, 1.0); // Parameters.Add_Value(pNode , "KNOWN_Y" , _TL("Known Y") , _TL(""), PARAMETER_TYPE_Double, 1.0); // Parameters.Add_Value(pNode , "KNOWN_LON" , _TL("Longitude") , _TL(""), PARAMETER_TYPE_Double, -180.0); // Parameters.Add_Value(pNode , "KNOWN_LAT" , _TL("Latitude") , _TL(""), PARAMETER_TYPE_Double, -90.0); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "NODE_CAT", _TL("Categories"), _TL("")); Parameters.Add_Value(pNode , "ISWATER" , _TL("Water") , _TL(""), PARAMETER_TYPE_Int, m_Index.m_ISWATER); Parameters.Add_Value(pNode , "ISLAKE" , _TL("Lake") , _TL(""), PARAMETER_TYPE_Int, m_Index.m_ISLAKE); Parameters.Add_Value(pNode , "ISICE" , _TL("Ice") , _TL(""), PARAMETER_TYPE_Int, m_Index.m_ISICE); Parameters.Add_Value(pNode , "ISURBAN" , _TL("Urban") , _TL(""), PARAMETER_TYPE_Int, m_Index.m_ISURBAN); Parameters.Add_Value(pNode , "ISOILWATER" , _TL("Soil Water") , _TL(""), PARAMETER_TYPE_Int, m_Index.m_ISOILWATER); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CWRF_Export::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("MMINLU")) ) { if( !SG_STR_CMP(pParameter->asString(), SG_T("USGS")) ) { pParameters->Get_Parameter("DESCRIPTION")->Set_Value(SG_T("24-category USGS landuse")); } } //----------------------------------------------------- return( 1 ); } //--------------------------------------------------------- int CWRF_Export::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("PROJECTION")) ) { pParameters->Get_Parameter("SDTLON" )->Set_Enabled(pParameter->asInt() != 3); pParameters->Get_Parameter("TRUELAT1")->Set_Enabled(pParameter->asInt() != 3); pParameters->Get_Parameter("TRUELAT2")->Set_Enabled(pParameter->asInt() != 3); } //----------------------------------------------------- return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWRF_Export::On_Execute(void) { CSG_String Directory; CSG_Parameter_Grid_List *pGrids; //----------------------------------------------------- Directory = Parameters("FILE") ->asString(); pGrids = Parameters("GRIDS") ->asGridList(); //----------------------------------------------------- m_Index.Reset(); switch( Parameters("DATATYPE")->asInt() ) { case 0: default: m_Index.m_WORDSIZE = 1; m_Index.m_SIGNED = false; break; case 1: m_Index.m_WORDSIZE = 1; m_Index.m_SIGNED = true; break; case 2: m_Index.m_WORDSIZE = 2; m_Index.m_SIGNED = false; break; case 3: m_Index.m_WORDSIZE = 2; m_Index.m_SIGNED = true; break; case 4: m_Index.m_WORDSIZE = 4; m_Index.m_SIGNED = false; break; case 5: m_Index.m_WORDSIZE = 4; m_Index.m_SIGNED = true; break; } m_Index.m_TYPE = Parameters("TYPE") ->asInt(); m_Index.m_MISSING_VALUE = Parameters("MISSING") ->asDouble(); m_Index.m_SCALE_FACTOR = Parameters("SCALE") ->asDouble(); m_Index.m_UNITS = Parameters("UNITS") ->asString(); m_Index.m_DESCRIPTION = Parameters("DESCRIPTION") ->asString(); m_Index.m_MMINLU = Parameters("MMINLU") ->asString(); m_Index.m_TILE_BDR = Parameters("TILE_BDR") ->asInt(); m_Index.m_TILE_X = Get_NX() - 2 * m_Index.m_TILE_BDR; m_Index.m_TILE_Y = Get_NY() - 2 * m_Index.m_TILE_BDR; m_Index.m_TILE_Z = pGrids->Get_Count(); m_Index.m_TILE_Z_START = 1; m_Index.m_TILE_Z_END = pGrids->Get_Count(); m_Index.m_DX = Get_Cellsize(); m_Index.m_DY = Get_Cellsize(); m_Index.m_ENDIAN = VAL_ENDIAN_LITTLE; m_Index.m_ROW_ORDER = VAL_BOTTOM_TOP; m_Index.m_PROJECTION = Parameters("PROJECTION") ->asString(); m_Index.m_STDLON = Parameters("SDTLON") ->asDouble(); m_Index.m_TRUELAT1 = Parameters("TRUELAT1") ->asDouble(); m_Index.m_TRUELAT2 = Parameters("TRUELAT2") ->asDouble(); m_Index.m_KNOWN_LAT = - 90.0 + 0.5 * m_Index.m_DY; m_Index.m_KNOWN_LON = -180.0 + 0.5 * m_Index.m_DX; // m_Index.m_KNOWN_X = Parameters("KNOWN_X") ->asDouble(); // m_Index.m_KNOWN_Y = Parameters("KNOWN_Y") ->asDouble(); // m_Index.m_KNOWN_LAT = Parameters("KNOWN_LAT") ->asDouble(); // m_Index.m_KNOWN_LON = Parameters("KNOWN_LON") ->asDouble(); if( m_Index.m_TILE_Z == 1 ) { m_Index.m_CATEGORY_MIN = m_Index.m_TYPE == VAL_CATEGORICAL ? (int)pGrids->asGrid(0)->Get_ZMin() : 0; m_Index.m_CATEGORY_MAX = m_Index.m_TYPE == VAL_CATEGORICAL ? (int)pGrids->asGrid(0)->Get_ZMax() : 0; } else { m_Index.m_CATEGORY_MIN = m_Index.m_TILE_Z_START; m_Index.m_CATEGORY_MAX = m_Index.m_TILE_Z_END; } m_Index.m_ISWATER = Parameters("ISWATER") ->asInt(); m_Index.m_ISLAKE = Parameters("ISLAKE") ->asInt(); m_Index.m_ISICE = Parameters("ISICE") ->asInt(); m_Index.m_ISURBAN = Parameters("ISURBAN") ->asInt(); m_Index.m_ISOILWATER = Parameters("ISOILWATER") ->asInt(); //----------------------------------------------------- if( !m_Index.Save(SG_File_Make_Path(Directory, SG_T("index"))) ) { Error_Set(_TL("error saving index file")); return( false ); } //----------------------------------------------------- if( !Save(Directory, pGrids) ) { Error_Set(_TL("error saving data file")); return( false ); } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWRF_Export::Save(const CSG_String &Directory, CSG_Parameter_Grid_List *pGrids) { //----------------------------------------------------- // 00001-00600.00001-00600 // 01234567890123456789012 int xOffset = m_Index.m_TILE_BDR + (int)(0.5 + (Get_XMin() - m_Index.m_KNOWN_LON) / Get_Cellsize()); int yOffset = m_Index.m_TILE_BDR + (int)(0.5 + (Get_YMin() - m_Index.m_KNOWN_LAT) / Get_Cellsize()); CSG_String Name = SG_File_Get_Name(Directory, true); Name.Printf(SG_T("%05d-%05d.%05d-%05d"), xOffset + 1, xOffset + m_Index.m_TILE_X, yOffset + 1, yOffset + m_Index.m_TILE_Y); //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(SG_File_Make_Path(Directory, Name), SG_FILE_W) ) { Error_Set(_TL("data file could not be openend")); return( false ); } //----------------------------------------------------- char *pLine, *pValue; int x, y, nBytes_Line; nBytes_Line = Get_NX() * m_Index.m_WORDSIZE; pLine = (char *)SG_Malloc(nBytes_Line); //----------------------------------------------------- for(int z=0; zGet_Count() && Process_Get_Okay(); z++) { CSG_Grid *pGrid = pGrids->asGrid(z); //------------------------------------------------- for(y=0; yGet_NY() && !Stream.is_EOF() && Set_Progress(y, pGrid->Get_NY()); y++) { int yy = m_Index.m_ROW_ORDER == VAL_TOP_BOTTOM ? pGrid->Get_NY() - 1 - y : y; for(x=0, pValue=pLine; xGet_NX(); x++, pValue+=m_Index.m_WORDSIZE) { if( m_Index.m_SIGNED ) { switch( m_Index.m_WORDSIZE ) { case 1: *((signed char *)pValue) = (signed char )pGrid->asInt(x, yy); break; case 2: *((signed short *)pValue) = (signed short )pGrid->asInt(x, yy); break; case 4: *((signed int *)pValue) = (signed int )pGrid->asInt(x, yy); break; } } else { switch( m_Index.m_WORDSIZE ) { case 1: *((unsigned char *)pValue) = (unsigned char )pGrid->asInt(x, yy); break; case 2: *((unsigned short *)pValue) = (unsigned short)pGrid->asInt(x, yy); break; case 4: *((unsigned int *)pValue) = (unsigned int )pGrid->asInt(x, yy); break; } } if( m_Index.m_ENDIAN == VAL_ENDIAN_BIG ) { SG_Swap_Bytes(pValue, m_Index.m_WORDSIZE); } } Stream.Write(pLine, sizeof(char), nBytes_Line); } } //----------------------------------------------------- SG_Free(pLine); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_grid/srtm30.cpp0000744000175000017500000002411512737416173021721 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: srtm30.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // SRTM30.cpp // // // // Copyright (C) 2004 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "srtm30.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSRTM30_Import::CSRTM30_Import(void) { CSG_Parameter *pNode_0; CSG_Parameters *pParameters; //----------------------------------------------------- Set_Name(_TL("Import SRTM30 DEM")); Set_Author (SG_T("(c) 2004 by O.Conrad")); Set_Description (_TW( "Extracts elevation grids from SRTM30 data.\n\n" "\"SRTM30 is a near-global digital elevation model (DEM) comprising a " "combination of data from the Shuttle Radar Topography Mission, flown " "in February, 2000 and the the U.S. Geological Survey's GTOPO30 data " "set. It can be considered to be either an SRTM data set enhanced with " "GTOPO30, or as an upgrade to GTOPO30.\" (NASA)\n\n" "Further information about the GTOPO30 data set:\n" "" "http://edcdaac.usgs.gov/gtopo30/gtopo30.html\n\n" "SRTM30 data can be downloaded from:\n" "" "ftp://e0srp01u.ecs.nasa.gov/srtm/version2/SRTM30/\n\n" "A directory, that contains the uncompressed SRTM30 DEM files, can be located using " "the \"Path\" Parameter of this module.") ); //----------------------------------------------------- pNode_0 = Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); pNode_0 = Parameters.Add_FilePath( NULL , "PATH" , _TL("Path"), _TL(""), NULL, NULL, false, true ); //----------------------------------------------------- pNode_0 = Parameters.Add_Value( NULL , "XMIN" , _TL("West []"), _TL(""), PARAMETER_TYPE_Int, 60.0 ); pNode_0 = Parameters.Add_Value( NULL , "XMAX" , _TL("East []"), _TL(""), PARAMETER_TYPE_Int, 120.0 ); pNode_0 = Parameters.Add_Value( NULL , "YMIN" , _TL("South []"), _TL(""), PARAMETER_TYPE_Int, 20.0 ); pNode_0 = Parameters.Add_Value( NULL , "YMAX" , _TL("North []"), _TL(""), PARAMETER_TYPE_Int, 50.0 ); //----------------------------------------------------- pParameters = Add_Parameters("TILE", _TL(""), _TL("")); pNode_0 = pParameters->Add_Info_String( NULL , "INFO" , _TL("File does not exist:"), _TL(""), _TL("") ); pNode_0 = pParameters->Add_FilePath( NULL , "PATH" , _TL("Select file"), _TL(""), _TL("SRTM30 DEM Tiles (*.dem)|*.dem|All Files|*.*") ); } //--------------------------------------------------------- CSRTM30_Import::~CSRTM30_Import(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define X_WIDTH 4800 #define Y_WIDTH 6000 //--------------------------------------------------------- bool CSRTM30_Import::On_Execute(void) { char x_sTile[9][5] = { "W180", "W140", "W100", "W060", "W020", "E020", "E060", "E100", "E140" }, y_sTile[3][4] = { "S10", "N40", "N90" }; double dSize = 30.0 / (60.0 * 60.0); //----------------------------------------------------- int xTile, yTile; double xMin, xMax, yMin, yMax; TSG_Rect rOut, rTile; CSG_String sTile; CSG_Grid *pOut; //----------------------------------------------------- xMin = Parameters("XMIN")->asInt(); xMax = Parameters("XMAX")->asInt(); yMin = Parameters("YMIN")->asInt(); yMax = Parameters("YMAX")->asInt(); rOut.xMin = (180 + xMin) / 40.0 * X_WIDTH; rOut.xMax = rOut.xMin + (int)((xMax - xMin) / dSize); rOut.yMin = ( 60 + yMin) / 50.0 * Y_WIDTH; rOut.yMax = rOut.yMin + (int)((yMax - yMin) / dSize); //----------------------------------------------------- pOut = SG_Create_Grid(SG_DATATYPE_Short, (int)(rOut.xMax - rOut.xMin), (int)(rOut.yMax - rOut.yMin), dSize, xMin + 0.5 * dSize, yMin + 0.5 * dSize ); pOut->Set_NoData_Value(-9999); pOut->Assign_NoData(); pOut->Set_Name(SG_T("SRTM30")); pOut->Get_Projection().Create(SG_T("GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]")); //----------------------------------------------------- for(yTile=0, rTile.yMin=0, rTile.yMax=Y_WIDTH; yTile<3; yTile++, rTile.yMin+=Y_WIDTH, rTile.yMax+=Y_WIDTH) { for(xTile=0, rTile.xMin=0, rTile.xMax=X_WIDTH; xTile<9; xTile++, rTile.xMin+=X_WIDTH, rTile.xMax+=X_WIDTH) { sTile.Printf(SG_T("Tile: %s%s"), x_sTile[xTile], y_sTile[yTile]); Process_Set_Text(sTile); sTile.Printf(SG_T("%s%s%s.dem"), Parameters("PATH")->asString(), x_sTile[xTile], y_sTile[yTile]); Tile_Load(sTile, rTile, pOut, rOut); } } //----------------------------------------------------- Parameters("GRID")->Set_Value(pOut); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSRTM30_Import::Tile_Load(const SG_Char *sTile, TSG_Rect &rTile, CSG_Grid *pOut, TSG_Rect &rOut) { short Value; int x, y, xOut, yOut; FILE *Stream; CSG_Rect r(rTile); if( r.Intersects(rOut) != INTERSECTION_None && (Stream = Tile_Open(sTile)) != NULL ) { for(y=0, yOut=(int)(rTile.yMax-rOut.yMin); y=0 && Set_Progress(y, Y_WIDTH); y++, yOut--) { for(x=0, xOut=(int)(rTile.xMin-rOut.xMin); x= 0 && xOut < pOut->Get_NX() && yOut >= 0 && yOut < pOut->Get_NY() ) { SG_Swap_Bytes(&Value, sizeof(short)); pOut->Set_Value(xOut, yOut, Value); } } } fclose(Stream); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- FILE * CSRTM30_Import::Tile_Open(const SG_Char *sTile) { const SG_Char *sPath; FILE *Stream; CSG_String fName; CSG_Parameters *pParameters; fName = sTile; if( (Stream = fopen(fName.b_str(), "rb")) == NULL ) { pParameters = Get_Parameters("TILE"); pParameters->Get_Parameter("INFO")->Set_Value(sTile); if( Dlg_Parameters(pParameters, _TL("Locate STRM30 Data File")) && (sPath = pParameters->Get_Parameter("PATH")->asString()) != NULL ) { fName = sPath; Stream = fopen(fName.b_str(), "rb"); } } return( Stream ); } saga-2.3.1/src/modules/io/io_grid/mola.h0000744000175000017500000000745412737416173021175 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: mola.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // MOLA.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // MOLA.h // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__MOLA_Import_H #define HEADER_INCLUDED__MOLA_Import_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CMOLA_Import : public CSG_Module { public: CMOLA_Import(void); virtual ~CMOLA_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Import") ); } protected: virtual bool On_Execute(void); private: }; #endif // #ifndef HEADER_INCLUDED__MOLA_Import_H saga-2.3.1/src/modules/io/io_grid/import_clip_resample.h0000744000175000017500000001070512737416173024447 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: import_clip_resample.h 1380 2012-04-26 12:02:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // import_clip_resample.h // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__import_clip_resample_H #define HEADER_INCLUDED__import_clip_resample_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CImport_Clip_Resample : public CSG_Module { public: CImport_Clip_Resample(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Import") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Parameter_Grid_List *m_pGrids; bool Load_File (const CSG_String &File); bool Load_Grid (CSG_Grid *pImport); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__import_clip_resample_H saga-2.3.1/src/modules/io/io_grid/surfer.cpp0000744000175000017500000003220612737416173022077 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: surfer.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Surfer.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "surfer.h" //--------------------------------------------------------- #define NODATAVALUE 1.70141e38f /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSurfer_Import::CSurfer_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name(_TL("Import Surfer Grid")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (_TW( "Import grid from Golden Software's Surfer grid format.\n") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("Surfer Grid (*.grd)|*.grd|All Files|*.*") ); pNode = Parameters.Add_Choice( NULL , "NODATA" , _TL("No Data Value"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Surfer's No Data Value"), _TL("User Defined") ), 0 ); Parameters.Add_Value( pNode , "NODATA_VAL" , _TL("User Defined No Data Value"), _TL(""), PARAMETER_TYPE_Double , -99999.0 ); } //--------------------------------------------------------- CSurfer_Import::~CSurfer_Import(void) {} //--------------------------------------------------------- bool CSurfer_Import::On_Execute(void) { int x, y, NX, NY; short sValue; long lValue; float *fLine; double *dLine, dValue, DX, DY, xMin, yMin; FILE *Stream; CSG_String fName; CSG_Grid *pGrid; //----------------------------------------------------- pGrid = NULL; fName = Parameters("FILE")->asString(); //----------------------------------------------------- if( fName.Length() > 0 && (Stream = fopen(fName.b_str(), "rb")) != NULL ) { fread(&lValue, 1, sizeof(long), Stream); //------------------------------------------------- // Surfer 7: Binary... if( !strncmp((char *)&lValue, "DSRB", 4) ) { fread(&lValue, 1, sizeof(long) , Stream); // SectionSize... fread(&lValue, 1, sizeof(long) , Stream); // Version fread(&lValue, 1, sizeof(long) , Stream); if( lValue == 0x44495247 ) // Grid-Header... { fread(&lValue , 1, sizeof(long) , Stream); // SectionSize... fread(&lValue , 1, sizeof(long) , Stream); // NX... NY = (int)lValue; fread(&lValue , 1, sizeof(long) , Stream); // NY... NX = (int)lValue; fread(&xMin , 1, sizeof(double) , Stream); // xMin... fread(&yMin , 1, sizeof(double) , Stream); // yMin... fread(&DX , 1, sizeof(double) , Stream); // DX... fread(&DY , 1, sizeof(double) , Stream); // DY... fread(&dValue , 1, sizeof(double) , Stream); // zMin... fread(&dValue , 1, sizeof(double) , Stream); // zMax... fread(&dValue , 1, sizeof(double) , Stream); // Rotation (unused)... fread(&dValue , 1, sizeof(double) , Stream); // Blank Value... fread(&lValue , 1, sizeof(long) , Stream); // ???... if( lValue == 0x41544144 ) // Load Binary Double... { fread(&lValue, 1, sizeof(long) , Stream); // SectionSize... //------------------------------------- if( !feof(Stream) && (pGrid = SG_Create_Grid(SG_DATATYPE_Double, NX, NY, DX, xMin, yMin)) != NULL ) { dLine = (double *)SG_Malloc(pGrid->Get_NX() * sizeof(double)); for(y=0; yGet_NY() && !feof(Stream) && Set_Progress(y, pGrid->Get_NY()); y++) { fread(dLine, pGrid->Get_NX(), sizeof(double), Stream); for(x=0; xGet_NX(); x++) { pGrid->Set_Value(x, y, dLine[x]); } } SG_Free(dLine); } } } } //------------------------------------------------- // Surfer 6: Binary... else if( !strncmp((char *)&lValue, "DSBB", 4) ) { fread(&sValue , 1, sizeof(short) , Stream); NX = sValue; fread(&sValue , 1, sizeof(short) , Stream); NY = sValue; fread(&xMin , 1, sizeof(double) , Stream); fread(&dValue , 1, sizeof(double) , Stream); // XMax DX = (dValue - xMin) / (NX - 1.0); fread(&yMin , 1, sizeof(double) , Stream); fread(&dValue , 1, sizeof(double) , Stream); // YMax... DY = (dValue - yMin) / (NY - 1.0); fread(&dValue , 1, sizeof(double) , Stream); // ZMin... fread(&dValue , 1, sizeof(double) , Stream); // ZMax... //--------------------------------------------- if( !feof(Stream) && (pGrid = SG_Create_Grid(SG_DATATYPE_Float, NX, NY, DX, xMin, yMin)) != NULL ) { fLine = (float *)SG_Malloc(pGrid->Get_NX() * sizeof(float)); for(y=0; yGet_NY() && !feof(Stream) && Set_Progress(y, pGrid->Get_NY()); y++) { fread(fLine, pGrid->Get_NX(), sizeof(float), Stream); for(x=0; xGet_NX(); x++) { pGrid->Set_Value(x, y, fLine[x]); } } SG_Free(fLine); } } //------------------------------------------------- // Surfer 6: ASCII... else if( !strncmp((char *)&lValue, "DSAA", 4) ) { fscanf(Stream, "%d %d" , &NX , &NY); fscanf(Stream, "%lf %lf", &xMin , &dValue); DX = (dValue - xMin) / (NX - 1.0); fscanf(Stream, "%lf %lf", &yMin , &dValue); DY = (dValue - yMin) / (NY - 1.0); fscanf(Stream, "%lf %lf", &dValue, &dValue); //--------------------------------------------- if( !feof(Stream) && (pGrid = SG_Create_Grid(SG_DATATYPE_Float, NX, NY, DX, xMin, yMin)) != NULL ) { for(y=0; yGet_NY() && !feof(Stream) && Set_Progress(y, pGrid->Get_NY()); y++) { for(x=0; xGet_NX(); x++) { fscanf(Stream, "%lf", &dValue); pGrid->Set_Value(x, y, dValue); } } } } fclose(Stream); } //----------------------------------------------------- if( pGrid ) { pGrid->Set_Name(Parameters("FILE")->asString()); pGrid->Set_NoData_Value(Parameters("NODATA")->asInt() == 0 ? NODATAVALUE : Parameters("NODATA_VAL")->asDouble()); Parameters("GRID")->Set_Value(pGrid); } return( pGrid != NULL ); } /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSurfer_Export::CSurfer_Export(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("Export Surfer Grid")); Set_Author (SG_T("(c) 2001 by O.Conrad")); Set_Description (_TW( "Export grid to Golden Software's Surfer grid format.\n") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid( NULL , "GRID" , _TL("Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL( "Surfer Grid (*.grd)|*.grd|All Files|*.*"), NULL, true ); Parameters.Add_Choice( NULL , "FORMAT" , _TL("Format"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("binary"), _TL("ASCII") ), 0 ); Parameters.Add_Value( NULL , "NODATA" , _TL("Use Surfer's No-Data Value"), _TL(""), PARAMETER_TYPE_Bool , false ); } //--------------------------------------------------------- CSurfer_Export::~CSurfer_Export(void) {} //--------------------------------------------------------- bool CSurfer_Export::On_Execute(void) { const char ID_BINARY[] = "DSBB"; bool bNoData; short sValue; int x, y; float *fLine; double dValue; FILE *Stream; CSG_String fName; CSG_Grid *pGrid; //----------------------------------------------------- pGrid = Parameters("GRID") ->asGrid(); fName = Parameters("FILE") ->asString(); bNoData = Parameters("NODATA") ->asBool(); switch( Parameters("FORMAT")->asInt() ) { //----------------------------------------------------- case 0: // Surfer 6 - Binary... if( (Stream = fopen(fName.b_str(), "wb")) != NULL ) { fwrite(ID_BINARY, 4, sizeof(char ), Stream); sValue = (short)pGrid->Get_NX(); fwrite(&sValue , 1, sizeof(short ), Stream); sValue = (short)pGrid->Get_NY(); fwrite(&sValue , 1, sizeof(short ), Stream); dValue = pGrid->Get_XMin(); fwrite(&dValue , 1, sizeof(double), Stream); dValue = pGrid->Get_XMax(); fwrite(&dValue , 1, sizeof(double), Stream); dValue = pGrid->Get_YMin(); fwrite(&dValue , 1, sizeof(double), Stream); dValue = pGrid->Get_YMax(); fwrite(&dValue , 1, sizeof(double), Stream); dValue = pGrid->Get_ZMin(); fwrite(&dValue , 1, sizeof(double), Stream); dValue = pGrid->Get_ZMax(); fwrite(&dValue , 1, sizeof(double), Stream); //--------------------------------------------- fLine = (float *)SG_Malloc(pGrid->Get_NX() * sizeof(float)); for(y=0; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++) { for(x=0; xGet_NX(); x++) { fLine[x] = bNoData && pGrid->is_NoData(x, y) ? NODATAVALUE : pGrid->asFloat(x, y); } fwrite(fLine, pGrid->Get_NX(), sizeof(float), Stream); } SG_Free(fLine); fclose(Stream); return( true ); } break; //----------------------------------------------------- case 1: // Surfer - ASCII... if( (Stream = fopen(fName.b_str(), "w")) != NULL ) { fprintf(Stream, "DSAA\n" ); fprintf(Stream, "%d %d\n", pGrid->Get_NX() , pGrid->Get_NY() ); fprintf(Stream, "%f %f\n", pGrid->Get_XMin(), pGrid->Get_XMax() ); fprintf(Stream, "%f %f\n", pGrid->Get_YMin(), pGrid->Get_YMax() ); fprintf(Stream, "%f %f\n", pGrid->Get_ZMin(), pGrid->Get_ZMax() ); //--------------------------------------------- for(y=0; yGet_NY() && Set_Progress(y, pGrid->Get_NY()); y++) { for(x=0; xGet_NX(); x++) { if( bNoData && pGrid->is_NoData(x, y) ) { fprintf(Stream, "1.70141e38 "); } else { fprintf(Stream, "%f ", pGrid->asFloat(x, y)); } } fprintf(Stream, "\n"); } fclose(Stream); return( true ); } break; } //----------------------------------------------------- return( false ); } saga-2.3.1/src/modules/io/io_grid/grid_table.cpp0000744000175000017500000001763412737416173022675 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_table.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Grid_Table.cpp // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "grid_table.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGrid_Table_Import::CGrid_Table_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name(_TL("Import Grid from Table")); Set_Author (SG_T("(c) 2006 by O.Conrad")); Set_Description (_TW( "Imports grid from from table.\n") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE_DATA" , _TL("Table"), _TL("") ); //----------------------------------------------------- Parameters.Add_Value( NULL , "DXY" , _TL("Cell Size"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "XMIN" , _TL("Left Border (X)"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( NULL , "YMIN" , _TL("Lower Border (Y)"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_String( NULL , "UNIT" , _TL("Unit Name"), _TL(""), _TL("") ); Parameters.Add_Value( NULL , "ZFACTOR" , _TL("Z Multiplier"), _TL(""), PARAMETER_TYPE_Double , 1.0 ); Parameters.Add_Value( NULL , "NODATA" , _TL("No Data Value"), _TL(""), PARAMETER_TYPE_Double , -99999.0 ); Parameters.Add_Choice( NULL , "DATA_TYPE" , _TL("Data Type"), _TL(""), _TW( "1 Byte Integer (unsigned)|" "1 Byte Integer (signed)|" "2 Byte Integer (unsigned)|" "2 Byte Integer (signed)|" "4 Byte Integer (unsigned)|" "4 Byte Integer (signed)|" "4 Byte Floating Point|" "8 Byte Floating Point|") ); Parameters.Add_Choice( NULL , "TOPDOWN" , _TL("Line Order"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Bottom to Top"), _TL("Top to Bottom") ), 0 ); } //--------------------------------------------------------- CGrid_Table_Import::~CGrid_Table_Import(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGrid_Table_Import::On_Execute(void) { bool bDown; int x, y, nx, ny; double dxy, xmin, ymin, zFactor, zNoData; TSG_Data_Type data_type; CSG_String FileName, Unit; CSG_Grid *pGrid; CSG_Table Table; CSG_Table_Record *pRecord; //----------------------------------------------------- FileName = Parameters("FILE_DATA") ->asString(); dxy = Parameters("DXY") ->asDouble(); xmin = Parameters("XMIN") ->asDouble(); ymin = Parameters("YMIN") ->asDouble(); bDown = Parameters("TOPDOWN") ->asInt() == 1; Unit = Parameters("UNIT") ->asString(); zFactor = Parameters("ZFACTOR") ->asDouble(); zNoData = Parameters("NODATA") ->asDouble(); switch( Parameters("DATA_TYPE")->asInt() ) { default: data_type = SG_DATATYPE_Undefined; break; // not handled case 0: data_type = SG_DATATYPE_Byte; break; // 1 Byte Integer (unsigned) case 1: data_type = SG_DATATYPE_Char; break; // 1 Byte Integer (signed) case 2: data_type = SG_DATATYPE_Word; break; // 2 Byte Integer (unsigned) case 3: data_type = SG_DATATYPE_Short; break; // 2 Byte Integer (signed) case 4: data_type = SG_DATATYPE_DWord; break; // 4 Byte Integer (unsigned) case 5: data_type = SG_DATATYPE_Int; break; // 4 Byte Integer (signed) case 6: data_type = SG_DATATYPE_Float; break; // 4 Byte Floating Point case 7: data_type = SG_DATATYPE_Double; break; // 8 Byte Floating Point } //----------------------------------------------------- if( Table.Create(FileName) && (nx = Table.Get_Field_Count()) > 0 && (ny = Table.Get_Record_Count()) > 0 ) { pGrid = SG_Create_Grid(data_type, nx, ny, dxy, xmin, ymin); for(y=0; ySet_Value(x, y, pRecord->asDouble(x)); } } pGrid->Set_Unit (Unit); pGrid->Set_Scaling (zFactor); pGrid->Set_NoData_Value (zNoData); pGrid->Set_Name (SG_File_Get_Name(FileName, false)); Parameters("GRID")->Set_Value(pGrid); return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_grid/bmp_export.h0000744000175000017500000001104412737416173022412 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: bmp_export.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for an Automated Geo-Scientific Analysis // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // bmp_export.h // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for an Automated // // Geo-Scientific Analysis'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__bmp_export_H #define HEADER_INCLUDED__bmp_export_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CBMP_Export : public CSG_Module_Grid { public: CBMP_Export(void); virtual ~CBMP_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); private: void Write_WORD (FILE *Stream, WORD Value); void Write_DWORD (FILE *Stream, DWORD Value); void Write_LONG (FILE *Stream, long Value); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__bmp_export_H saga-2.3.1/src/modules/io/io_grid/xyz.cpp0000744000175000017500000002503712737416173021427 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: xyz.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // XYZ.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "xyz.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CXYZ_Export::CXYZ_Export(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export Grid to XYZ")); Set_Author (SG_T("O. Conrad (c) 2003")); Set_Description (_TW( "Export grid to a table (text format), that contains for each grid cell " "the x/y-coordinates and additionally data from selected grids.\n" "Optionally, it is possible to skip NoData cells from the output. In this " "case, the first input grid will perform like a mask.\n\n") ); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("File Name"), _TL(""), CSG_String::Format( SG_T("%s|*.xyz|%s|*.txt|%s|*.*"), _TL("XYZ files (*.xyz)"), _TL("Text files (*.txt)"), _TL("All Files") ), NULL, true ); Parameters.Add_Value( NULL , "CAPTION" , _TL("Write Field Names"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "EX_NODATA" , _TL("Exclude NoData Cells"), _TL(""), PARAMETER_TYPE_Bool, false ); } //--------------------------------------------------------- CXYZ_Export::~CXYZ_Export(void) {} //--------------------------------------------------------- bool CXYZ_Export::On_Execute(void) { bool bExNoData; int x, y, i; TSG_Point p; CSG_File Stream; CSG_String FileName; CSG_Parameter_Grid_List *pGrids; pGrids = Parameters("GRIDS") ->asGridList(); FileName = Parameters("FILENAME")->asString(); bExNoData = Parameters("EX_NODATA")->asBool(); if( pGrids->Get_Count() > 0 && Stream.Open(FileName, SG_FILE_W, false) ) { if( Parameters("CAPTION")->asBool() ) { Stream.Printf(SG_T("\"X\"\t\"Y\"")); for(i=0; iGet_Count(); i++) { Stream.Printf(SG_T("\t\"%s\""), pGrids->asGrid(i)->Get_Name()); } Stream.Printf(SG_T("\n")); } for(y=0, p.y=Get_YMin(); yasGrid(0)->is_NoData(x, y)) ) { Stream.Printf(SG_T("%f\t%f"), p.x, p.y); for(i=0; iGet_Count(); i++) { Stream.Printf(SG_T("\t%f"), pGrids->asGrid(i)->asDouble(x, y)); } Stream.Printf(SG_T("\n")); } } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CXYZ_Import::CXYZ_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import Grid from XYZ")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "Import grid from a table (text format), that contains for each grid cell " "the x/y/z-coordinates and additional data from selected grids.\n" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_Grid_Output( NULL , "COUNT" , _TL("Count"), _TL("") ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("File Name"), _TL(""), CSG_String::Format( SG_T("%s|*.xyz|%s|*.txt|%s|*.*"), _TL("XYZ files (*.xyz)"), _TL("Text files (*.txt)"), _TL("All Files") ), NULL, false ); Parameters.Add_Value( NULL , "CAPTION" , _TL("Has Field Names"), _TL(""), PARAMETER_TYPE_Bool, true ); Parameters.Add_Value( NULL , "CELLSIZE" , _TL("Target Cellsize"), _TL(""), PARAMETER_TYPE_Double, 1.0, 0.0, true ); Parameters.Add_Choice( NULL , "SEPARATOR" , _TL("Separator"), _TL(""), CSG_String::Format(SG_T("%s|%s|,|;|"), _TL("space"), _TL("tabulator") ), 1 ); } //--------------------------------------------------------- bool CXYZ_Import::On_Execute(void) { int nx, ny, nValues, fLength; double x, y, z, xMin, yMin, xMax, yMax, Cellsize; CSG_File Stream; CSG_String FileName, sLine; CSG_Grid *pGrid, *pCount; FileName = Parameters("FILENAME")->asString(); Cellsize = Parameters("CELLSIZE")->asDouble(); switch( Parameters("SEPARATOR")->asInt() ) { case 0: m_Separator = SG_T(' '); break; case 1: m_Separator = SG_T('\t'); break; case 2: m_Separator = SG_T(','); break; case 3: m_Separator = SG_T(';'); break; } if( Cellsize > 0.0 && Stream.Open(FileName, SG_FILE_R, false) ) { if( Parameters("CAPTION")->asBool() ) { Stream.Read_Line(sLine); } fLength = Stream.Length(); nValues = 0; xMin = xMax = 0; yMin = yMax = 0; while( Read_Values(Stream, x, y, z) && Set_Progress(Stream.Tell(), fLength) ) { if( nValues == 0 ) { xMin = xMax = x; yMin = yMax = y; } else { if( xMin > x ) xMin = x; else if( xMax < x ) xMax = x; if( yMin > y ) yMin = y; else if( yMax < y ) yMax = y; } nValues++; } //------------------------------------------------- if( Process_Get_Okay() && xMin < xMax && yMin < yMax ) { nx = 1 + (int)((xMax - xMin) / Cellsize); ny = 1 + (int)((yMax - yMin) / Cellsize); Parameters("GRID" )->Set_Value(pGrid = SG_Create_Grid(SG_DATATYPE_Float, nx, ny, Cellsize, xMin, yMin)); Parameters("COUNT")->Set_Value(pCount = SG_Create_Grid(SG_DATATYPE_Byte , nx, ny, Cellsize, xMin, yMin)); if( pGrid && pCount ) { pGrid ->Set_Name(FileName = SG_File_Get_Name(FileName, false)); pCount ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), FileName.c_str(), _TL("Count"))); Stream.Seek_Start(); if( Parameters("CAPTION")->asBool() ) { Stream.Read_Line(sLine); } while( Read_Values(Stream, x, y, z) && Set_Progress(Stream.Tell(), fLength) ) { if( pGrid->Get_System().Get_World_to_Grid(nx, ny, x, y) ) { pGrid ->Add_Value(nx, ny, z); pCount->Add_Value(nx, ny, 1.0); } } for(ny=0; nyGet_NY() && Set_Progress(ny, pGrid->Get_NY()); ny++) { for(nx=0; nxGet_NX(); nx++) { nValues = pCount->asInt(nx, ny); if( nValues == 0 ) { pGrid->Set_NoData(nx, ny); } else if( nValues > 1 ) { pGrid->Mul_Value(nx, ny, 1.0 / nValues); } } } return( true ); } } } return( false ); } //--------------------------------------------------------- inline bool CXYZ_Import::Read_Values(CSG_File &Stream, double &x, double &y, double &z) { CSG_String sLine; if( Stream.Read_Line(sLine) ) { sLine.Trim(); if( sLine.asDouble(x) ) { sLine = sLine.AfterFirst(m_Separator); sLine.Trim(); if( sLine.asDouble(y) ) { sLine = sLine.AfterFirst(m_Separator); if( sLine.asDouble(z) ) { return( true ); } } } } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_grid/erdas_lan.cpp0000744000175000017500000002367112737416173022527 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: erdas_lan.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for an Automated Geo-Scientific Analysis // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // erdas_lan.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for an Automated // // Geo-Scientific Analysis'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "erdas_lan.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CErdas_LAN_Import::CErdas_LAN_Import(void) { //----------------------------------------------------- Set_Name (_TL("Import Erdas LAN/GIS")); Set_Author (SG_T("(c) 2005 by O.Conrad")); Set_Description (_TW( "Import Erdas LAN/GIS files. \n" "The format analysis is based on the GRASS module i.in.erdas. " "Go to the " "GRASS GIS Hompage " "for more information.\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("Erdas LAN/GIS files (*.lan, *.gis)|*.lan;*.gis|All Files|*.*"), NULL, false, false ); } //--------------------------------------------------------- CErdas_LAN_Import::~CErdas_LAN_Import(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SWAP(v) if( bSwap ) SG_Swap_Bytes(&v, sizeof(v)); //--------------------------------------------------------- bool CErdas_LAN_Import::On_Execute(void) { //----------------------------------------------------- bool bResult = false, bSwap = false; BYTE *Line, *pLine; char head[6], empty[56]; short vType, nBands, maptyp, nclass, unit; int x, y, i, nLine; long nx, ny, px, py; float area, dx, dy, xPos, yPos; double Cellsize, xMin, yMin, Value; FILE *Stream; TSG_Data_Type gType; CSG_Parameter_Grid_List *Grids; CSG_String FileName; //----------------------------------------------------- Grids = Parameters("GRIDS") ->asGridList(); FileName = Parameters("FILE") ->asString(); Grids->Del_Items(); //----------------------------------------------------- if( (Stream = fopen(FileName.b_str(), "rb")) != NULL ) { fread( head , 6, sizeof(char) , Stream); // "HEAD74" fread(&vType , 1, sizeof(short) , Stream); SWAP(vType); // 0 = 8 bit, 1 = 4 bit, 2 = 16 bit fread(&nBands , 1, sizeof(short) , Stream); SWAP(nBands); // number of bands fread( empty , 6, sizeof(char) , Stream); // empty fread(&nx , 1, sizeof(long) , Stream); SWAP(nx); // number of columns fread(&ny , 1, sizeof(long) , Stream); SWAP(ny); // number of rows fread(&px , 1, sizeof(long) , Stream); SWAP(px); // x position of top-left pixel "database location" fread(&py , 1, sizeof(long) , Stream); SWAP(py); // y position of top-left pixel "database location" fread( empty , 56, sizeof(char) , Stream); // empty fread(&maptyp , 1, sizeof(short) , Stream); SWAP(maptyp); // map projection fread(&nclass , 1, sizeof(short) , Stream); SWAP(nclass); // number of classes fread( empty , 14, sizeof(char) , Stream); // empty fread(&unit , 1, sizeof(short) , Stream); SWAP(unit); // units of area per pixel - 0 = none, 1 = acre, 2 = hectare, 3 = other fread(&area , 1, sizeof(float) , Stream); SWAP(area); // area per pixel fread(&xPos , 1, sizeof(float) , Stream); SWAP(xPos); // x coordinate of top-left pixel fread(&yPos , 1, sizeof(float) , Stream); SWAP(yPos); // y coordinate of top-left pixel fread(&dx , 1, sizeof(float) , Stream); SWAP(dx); // linear size of a pixel (feet/degrees/meters) fread(&dy , 1, sizeof(float) , Stream); SWAP(dy); // linear size of a pixel (feet/degrees/meters) //------------------------------------------------- CSG_File fWorld; if( fWorld.Open(SG_File_Make_Path(NULL, FileName, SG_T("lnw")), SG_FILE_R, false) ) { double d; CSG_String sLine; if( fWorld.Read_Line(sLine) ) { if( sLine.asDouble(d) ) dx = (float)d; } if( fWorld.Read_Line(sLine) ) { } if( fWorld.Read_Line(sLine) ) { } if( fWorld.Read_Line(sLine) ) { if( sLine.asDouble(d) ) dy = (float)d; } if( fWorld.Read_Line(sLine) ) { if( sLine.asDouble(d) ) xPos = (float)d; } if( fWorld.Read_Line(sLine) ) { if( sLine.asDouble(d) ) yPos = (float)d; } } //------------------------------------------------- if( feof(Stream) ) { Message_Add(_TL("File error")); } else if( strncmp(head, "HEAD74", sizeof(head)) ) { Message_Add(_TL("ERDAS files other than version 7.4 are not supported.")); } //------------------------------------------------- else { bResult = true; Cellsize = dx; xMin = xPos; yMin = yPos - ny * Cellsize; switch( vType ) { case 0: default: // 8 bit gType = SG_DATATYPE_Byte; nLine = nx; break; case 1: // 4 bit gType = SG_DATATYPE_Byte; nLine = nx / 2 + (nx % 2 ? 1 : 0); break; case 2: // 16 bit gType = SG_DATATYPE_Word; nLine = nx * 2; break; } Line = (BYTE *)SG_Malloc(nLine * sizeof(BYTE)); for(i=0; iAdd_Item(SG_Create_Grid(gType, nx, ny, Cellsize, xMin, yMin)); Grids->asGrid(i)->Set_Name(CSG_String::Format(SG_T("%s [%d]"), SG_File_Get_Name(FileName, false).c_str(), i + 1)); } //--------------------------------------------- for(y=0; y> 4; pLine ++; } else { Value = (*pLine & 0x11); } break; case 2: if( bSwap ) { SG_Swap_Bytes(pLine, 2); } Value = *((short *)pLine); pLine += 2; break; } Grids->asGrid(i)->Set_Value(x, ny - y - 1, Value); } } } //--------------------------------------------- SG_Free(Line); for(i=0; iasGrid(i)); DataObject_Set_Colors (Grids->asGrid(i), 100, SG_COLORS_BLACK_WHITE); } } //------------------------------------------------- fclose(Stream); } //----------------------------------------------------- return( bResult ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_grid/raw.h0000744000175000017500000001133412737416173021026 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: raw.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Raw.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Raw_Import_H #define HEADER_INCLUDED__Raw_Import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CRaw_Import : public CSG_Module { public: CRaw_Import(void); virtual ~CRaw_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: CSG_Grid * Load_Data (FILE *Stream, TSG_Data_Type data_type, int nx, int ny, double dxy, double xmin, double ymin, int data_head, int line_head, int line_tail, bool bDown, bool bBig); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Raw_Import_H saga-2.3.1/src/modules/io/io_grid/usgs_srtm.h0000744000175000017500000000757312737416173022275 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: usgs_srtm.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // USGS_SRTM.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // USGS_SRTM.h // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__USGS_SRTM_H #define HEADER_INCLUDED__USGS_SRTM_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CUSGS_SRTM_Import : public CSG_Module { public: CUSGS_SRTM_Import(void); virtual ~CUSGS_SRTM_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: CSG_Grid * Load (CSG_String fName, int N, double D); }; #endif // #ifndef HEADER_INCLUDED__USGS_SRTM_H saga-2.3.1/src/modules/io/io_grid/grid_table.h0000744000175000017500000001105712737416173022333 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: grid_table.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // Grid_Table.h // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Grid_Table_H #define HEADER_INCLUDED__Grid_Table_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGrid_Table_Import : public CSG_Module { public: CGrid_Table_Import(void); virtual ~CGrid_Table_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Grid_Table_H saga-2.3.1/src/modules/io/io_grid/Makefile.in0000664000175000017500000005732312737447616022150 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/io/io_grid ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_grid_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libio_grid_la_OBJECTS = bmp_export.lo erdas_lan.lo esri_arcinfo.lo \ grid_table.lo import_clip_resample.lo MLB_Interface.lo mola.lo \ raw.lo srtm30.lo surfer.lo usgs_srtm.lo wrf.lo xyz.lo libio_grid_la_OBJECTS = $(am_libio_grid_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_grid_la_SOURCES) DIST_SOURCES = $(libio_grid_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_grid.la libio_grid_la_SOURCES = \ bmp_export.cpp\ erdas_lan.cpp\ esri_arcinfo.cpp\ grid_table.cpp\ import_clip_resample.cpp\ MLB_Interface.cpp\ mola.cpp\ raw.cpp\ srtm30.cpp\ surfer.cpp\ usgs_srtm.cpp\ wrf.cpp\ xyz.cpp\ bmp_export.h\ erdas_lan.h\ esri_arcinfo.h\ grid_table.h\ import_clip_resample.h\ MLB_Interface.h\ mola.h\ raw.h\ srtm30.h\ surfer.h\ usgs_srtm.h\ wrf.h\ xyz.h libio_grid_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/io/io_grid/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_grid/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_grid.la: $(libio_grid_la_OBJECTS) $(libio_grid_la_DEPENDENCIES) $(EXTRA_libio_grid_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_grid_la_OBJECTS) $(libio_grid_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bmp_export.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/erdas_lan.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/esri_arcinfo.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grid_table.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/import_clip_resample.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mola.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raw.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/srtm30.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/surfer.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usgs_srtm.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wrf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xyz.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/io/io_grid/usgs_srtm.cpp0000744000175000017500000001754512737416173022630 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: usgs_srtm.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // USGS_SRTM.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "usgs_srtm.h" /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CUSGS_SRTM_Import::CUSGS_SRTM_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import USGS SRTM Grid")); Set_Author (SG_T("O.Conrad (c) 2004")); Set_Description (_TW( "Import grid from USGS SRTM (Shuttle Radar Topography Mission) data.\n" "You find data and further information at:\n" " " " http://dds.cr.usgs.gov/srtm/\n" " " " http://www.jpl.nasa.gov/srtm/\n" "\nFarr, T.G., M. Kobrick (2000):\n" " 'Shuttle Radar Topography Mission produces a wealth of data',\n" " Amer. Geophys. Union Eos, v. 81, p. 583-585\n" "\nRosen, P.A., S. Hensley, I.R. Joughin, F.K. Li, S.N. Madsen, E. Rodriguez, R.M. Goldstein (2000):\n" " 'Synthetic aperture radar interferometry'\n" " Proc. IEEE, v. 88, p. 333-382\n" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, false ); Parameters.Add_FilePath( NULL , "FILE" , _TL("Files"), _TL(""), _TL("USGS SRTM Grids (*.hgt)|*.hgt|All Files|*.*"), NULL, false, false, true ); Parameters.Add_Choice( NULL , "RESOLUTION" , _TL("Resolution"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("1 arc-second"), _TL("3 arc-second") ), 1 ); } //--------------------------------------------------------- CUSGS_SRTM_Import::~CUSGS_SRTM_Import(void) {} //--------------------------------------------------------- bool CUSGS_SRTM_Import::On_Execute(void) { int N; double D; CSG_Strings fNames; CSG_Grid *pGrid; CSG_Parameter_Grid_List *pGrids; pGrids = Parameters("GRIDS")->asGridList(); pGrids ->Del_Items(); //----------------------------------------------------- switch( Parameters("RESOLUTION")->asInt() ) { default: return( false ); case 0: // 1 arcsec... N = 3601; D = 1.0 / 3600.0; break; case 1: // 3 arcsec... N = 1201; D = 3.0 / 3600.0; break; } //----------------------------------------------------- if( Parameters("FILE")->asFilePath()->Get_FilePaths(fNames) && fNames.Get_Count() > 0 ) { for(int i=0; iAdd_Item(pGrid); } } return( pGrids->Get_Count() > 0 ); } return( false ); } //--------------------------------------------------------- CSG_Grid * CUSGS_SRTM_Import::Load(CSG_String File, int N, double D) { int x, y; short *sLine; double xMin, yMin; CSG_File Stream; CSG_String fName; CSG_Grid *pGrid; //----------------------------------------------------- pGrid = NULL; fName = SG_File_Get_Name(File, false); if( fName.Length() >= 7 ) { fName .Make_Upper(); Process_Set_Text(CSG_String::Format(SG_T("%s: %s"), _TL("Importing"), fName.c_str())); yMin = (fName[0] == 'N' ? 1.0 : -1.0) * fName.Right(6).asInt(); xMin = (fName[3] == 'W' ? -1.0 : 1.0) * fName.Right(3).asInt(); //------------------------------------------------- if( Stream.Open(File, SG_FILE_R, true) ) { if( (pGrid = SG_Create_Grid(SG_DATATYPE_Short, N, N, D, xMin, yMin)) != NULL ) { pGrid->Set_Name (fName); pGrid->Get_Projection().Create(SG_T("GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]")); pGrid->Set_NoData_Value (-32768); //----------------------------------------- sLine = (short *)SG_Malloc(N * sizeof(short)); for(y=0; ySet_Value(x, N - 1 - y, sLine[x]); } } SG_Free(sLine); } } } return( pGrid ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_grid/xyz.h0000744000175000017500000001212512737416173021066 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: xyz.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // XYZ.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__XYZ_H #define HEADER_INCLUDED__XYZ_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CXYZ_Export : public CSG_Module_Grid { public: CXYZ_Export(void); virtual ~CXYZ_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CXYZ_Import : public CSG_Module { public: CXYZ_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: SG_Char m_Separator; bool Read_Values (CSG_File &Stream, double &x, double &y, double &z); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__XYZ_H saga-2.3.1/src/modules/io/io_grid/Makefile.am0000744000175000017500000000151012737416173022113 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_grid.la libio_grid_la_SOURCES =\ bmp_export.cpp\ erdas_lan.cpp\ esri_arcinfo.cpp\ grid_table.cpp\ import_clip_resample.cpp\ MLB_Interface.cpp\ mola.cpp\ raw.cpp\ srtm30.cpp\ surfer.cpp\ usgs_srtm.cpp\ wrf.cpp\ xyz.cpp\ bmp_export.h\ erdas_lan.h\ esri_arcinfo.h\ grid_table.h\ import_clip_resample.h\ MLB_Interface.h\ mola.h\ raw.h\ srtm30.h\ surfer.h\ usgs_srtm.h\ wrf.h\ xyz.h libio_grid_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/io/io_grid/import_clip_resample.cpp0000744000175000017500000002275612737416173025013 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: import_clip_resample.cpp 1380 2012-04-26 12:02:19Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // climate_tools // // // //-------------------------------------------------------// // // // import_clip_resample.cpp // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "import_clip_resample.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CImport_Clip_Resample::CImport_Clip_Resample(void) { //----------------------------------------------------- Set_Name (_TL("Import, Clip and Resample Grids")); Set_Author ("O.Conrad (c) 2015"); Set_Description (_TW( "" )); //----------------------------------------------------- CSG_Parameter *pNode; Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_FilePath( NULL , "FILES" , _TL("Image Files"), _TL(""), CSG_String::Format("%s|*.tif;*.tiff|%s|*.*", _TL("GeoTIFF Files"), _TL("All Files") ), NULL, false, false, true ); //----------------------------------------------------- Parameters.Add_Bool( NULL , "KEEP_TYPE" , _TL("Preserve Data Type"), _TL(""), false ); pNode = Parameters.Add_Bool( NULL , "NODATA" , _TL("User Defined No-Data Value"), _TL(""), false ); Parameters.Add_Double( pNode , "NODATA_VAL" , _TL("No-Data Value"), _TL("") ); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "CLIP" , _TL("Region of Interest"), _TL("bounding box for clipping"), PARAMETER_INPUT_OPTIONAL ); //----------------------------------------------------- pNode = Parameters.Add_Bool( NULL , "RESAMPLE" , _TL("Resample"), _TL(""), true ); Parameters.Add_Double( pNode , "CELLSIZE" , _TL("Cell Size"), _TL(""), 100.0, 0.0, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CImport_Clip_Resample::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( CSG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CImport_Clip_Resample::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "NODATA") ) { pParameters->Set_Enabled("NODATA_VAL", pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "RESAMPLE") ) { pParameters->Set_Enabled("CELLSIZE" , pParameter->asBool()); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CImport_Clip_Resample::On_Execute(void) { //----------------------------------------------------- CSG_Strings Files; if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) || Files.Get_Count() == 0 ) { return( false ); } //----------------------------------------------------- m_pGrids = Parameters("GRIDS")->asGridList(); m_pGrids->Del_Items(); //----------------------------------------------------- for(int i=0; iGet_Count() == 0 ) { Error_Set(_TL("no grids have been imported")); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CImport_Clip_Resample::Load_File(const CSG_String &File) { CSG_Data_Manager Grids; if( !Grids.Add(File) || !Grids.Get_Grid_System(0) || !Grids.Get_Grid_System(0)->Get(0) ) { Error_Set(CSG_String::Format("%s: %s", _TL("could not load file"), File.c_str())); return( false ); } int n = 0; for(size_t iSystem=0; iSystemCount(); iGrid++) { if( Load_Grid((CSG_Grid *)Grids.Get_Grid_System(iSystem)->Get(iGrid)) ) { n++; } } } return( n > 0 ); } //--------------------------------------------------------- bool CImport_Clip_Resample::Load_Grid(CSG_Grid *pImport) { CSG_Grid_System System = pImport->Get_System(); //----------------------------------------------------- const CSG_Rect *pClip = Parameters("CLIP")->asShapes() ? &Parameters("CLIP")->asShapes()->Get_Extent() : NULL; if( pClip ) { if( !pClip->Intersects(System.Get_Extent()) ) { return( false ); } TSG_Rect Extent = System.Get_Extent(); if( pClip->Get_XMin() > System.Get_XMin() ) Extent.xMin = System.Fit_xto_Grid_System(pClip->Get_XMin()); if( pClip->Get_XMax() < System.Get_XMax() ) Extent.xMax = System.Fit_xto_Grid_System(pClip->Get_XMax()); if( pClip->Get_YMin() > System.Get_YMin() ) Extent.yMin = System.Fit_yto_Grid_System(pClip->Get_YMin()); if( pClip->Get_YMax() < System.Get_YMax() ) Extent.yMax = System.Fit_yto_Grid_System(pClip->Get_YMax()); System.Assign(System.Get_Cellsize(), Extent); } //----------------------------------------------------- if( Parameters("RESAMPLE")->asBool() ) { double Cellsize = Parameters("CELLSIZE")->asDouble(); if( Cellsize > 0.0 && Cellsize != System.Get_Cellsize() ) { System.Assign(Cellsize, System.Get_Extent()); } } //----------------------------------------------------- if( Parameters("NODATA")->asBool() ) { pImport->Set_NoData_Value(Parameters("NODATA_VAL")->asDouble()); } //----------------------------------------------------- CSG_Grid *pGrid = SG_Create_Grid(System, Parameters("KEEP_TYPE")->asBool() ? pImport->Get_Type() : SG_DATATYPE_Float); if( pGrid ) { pGrid->Assign (pImport); pGrid->Set_Name(pImport->Get_Name()); m_pGrids->Add_Item(pGrid); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_grid/srtm30.h0000744000175000017500000000774712737416173021402 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: srtm30.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // SRTM30.h // // // // Copyright (C) 2004 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Import_SRTM30_H #define HEADER_INCLUDED__Import_SRTM30_H //--------------------------------------------------------- #include "MLB_Interface.h" //--------------------------------------------------------- class CSRTM30_Import : public CSG_Module { public: CSRTM30_Import(void); virtual ~CSRTM30_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Import") ); } protected: virtual bool On_Execute(void); private: bool Tile_Load(const SG_Char *sTile, TSG_Rect &rTile, CSG_Grid *pOut, TSG_Rect &rOut); FILE * Tile_Open(const SG_Char *sTile); }; #endif // #ifndef HEADER_INCLUDED__Import_SRTM30_H saga-2.3.1/src/modules/io/io_grid/bmp_export.cpp0000744000175000017500000002102512737416173022745 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: bmp_export.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for an Automated Geo-Scientific Analysis // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // bmp_export.cpp // // // // Copyright (C) 2005 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for an Automated // // Geo-Scientific Analysis'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@gwdg.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "bmp_export.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CBMP_Export::CBMP_Export(void) { //----------------------------------------------------- Set_Name (_TL("Export True Color Bitmap")); Set_Author (SG_T("(c) 2005 by O.Conrad")); Set_Description (_TW( "Export red-green-blue coded image grids to MS-Windows true color bitmaps. " "This module writes the data directly to the file and is hence particularly " "suitable for very large data sets. " )); //----------------------------------------------------- Parameters.Add_Grid( NULL , "IMAGE" , _TL("Image Grid"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("MS Windows Bitmap (*.bmp)|*.bmp|All Files|*.*"), NULL, true, false ); } //--------------------------------------------------------- CBMP_Export::~CBMP_Export(void) {} /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SIZE_HEADER_FILE 14 #define SIZE_HEADER_BITMAP 40 #define SIZE_HEADER_TOTAL (SIZE_HEADER_FILE + SIZE_HEADER_BITMAP) //--------------------------------------------------------- bool CBMP_Export::On_Execute(void) { //----------------------------------------------------- char *Line, *pLine; int x, y, Value, nBytes_Image, nBytes_Line; FILE *Stream; CSG_Grid *pGrid; CSG_String FileName; //----------------------------------------------------- pGrid = Parameters("IMAGE") ->asGrid(); FileName = Parameters("FILE") ->asString(); //----------------------------------------------------- if( (Stream = fopen(FileName.b_str(), "wb")) != NULL ) { nBytes_Line = 3 * sizeof(BYTE) * Get_NX(); if( (Value = nBytes_Line % 4) != 0 ) // must be a multiple of DWORD size... { nBytes_Line += 4 - Value; } nBytes_Image = nBytes_Line * Get_NY(); //------------------------------------------------- Write_WORD (Stream, 0x4d42); // bfType - 0x42 = "B", 0x4d = "M"... Write_DWORD (Stream, SIZE_HEADER_TOTAL + nBytes_Image); // bfSize - size of the entire file... Write_WORD (Stream, 0); // bfReserved1 Write_WORD (Stream, 0); // bfReserved2 Write_DWORD (Stream, SIZE_HEADER_TOTAL); // bfOffBits - offset to the array of color indices... //------------------------------------------------- Write_DWORD (Stream, SIZE_HEADER_BITMAP); // biSize; Write_LONG (Stream, Get_NX()); // biWidth; Write_LONG (Stream, Get_NY()); // biHeight; Write_WORD (Stream, 1); // biPlanes; Write_WORD (Stream, 24); // biBitCount; Write_DWORD (Stream, 0); // biCompression; Write_DWORD (Stream, nBytes_Image); // biSizeImage; Write_LONG (Stream, 0); // biXPelsPerMeter; Write_LONG (Stream, 0); // biYPelsPerMeter; Write_DWORD (Stream, 2^24); // biClrUsed; Write_DWORD (Stream, 0); // biClrImportant; //------------------------------------------------- Line = (char *)SG_Calloc(nBytes_Line, sizeof(char)); for(y=0; yasInt(x, y); pLine[0] = SG_GET_B(Value); pLine[1] = SG_GET_G(Value); pLine[2] = SG_GET_R(Value); } fwrite(Line, sizeof(char), nBytes_Line, Stream); } SG_Free(Line); fclose(Stream); //------------------------------------------------- FileName = SG_File_Make_Path(SG_File_Get_Path(FileName), SG_File_Get_Name(FileName, false), SG_T("prj")); pGrid->Get_Projection().Save(FileName); //------------------------------------------------- FileName = SG_File_Make_Path(SG_File_Get_Path(FileName), SG_File_Get_Name(FileName, false), SG_T("bpw")); if( (Stream = fopen(FileName.b_str(), "w")) != NULL ) { fprintf(Stream, "%f\n%f\n%f\n%f\n%f\n%f\n", pGrid->Get_Cellsize(), 0.0, 0.0, -pGrid->Get_Cellsize(), pGrid->Get_XMin(), pGrid->Get_YMax() ); fclose(Stream); } return( true ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CBMP_Export::Write_WORD (FILE *Stream, WORD Value) { fwrite(&Value, sizeof(Value), 1, Stream); } //--------------------------------------------------------- void CBMP_Export::Write_DWORD (FILE *Stream, DWORD Value) { fwrite(&Value, sizeof(Value), 1, Stream); } //--------------------------------------------------------- void CBMP_Export::Write_LONG (FILE *Stream, long Value) { fwrite(&Value, sizeof(Value), 1, Stream); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_grid/MLB_Interface.h0000744000175000017500000000766512737416173022643 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_grid_H #define HEADER_INCLUDED__io_grid_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_grid_EXPORTS #define io_grid_EXPORT _SAGA_DLL_EXPORT #else #define io_grid_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_grid_H saga-2.3.1/src/modules/io/io_grid/MLB_Interface.cpp0000744000175000017500000001303412737416173023161 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Grids") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( _TL("SAGA User Group Associaton (c) 2002") ); case MLB_INFO_Description: return( _TL("Tools for the import and export of gridded data.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Grid") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "esri_arcinfo.h" #include "surfer.h" #include "raw.h" #include "xyz.h" #include "usgs_srtm.h" #include "mola.h" #include "srtm30.h" #include "bmp_export.h" #include "erdas_lan.h" #include "grid_table.h" #include "wrf.h" #include "import_clip_resample.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0 : return( new CESRI_ArcInfo_Export ); case 1 : return( new CESRI_ArcInfo_Import ); case 2 : return( new CSurfer_Export ); case 3 : return( new CSurfer_Import ); case 4 : return( new CRaw_Import ); case 5 : return( new CXYZ_Export ); case 6 : return( new CXYZ_Import ); case 7 : return( new CUSGS_SRTM_Import ); case 8 : return( new CMOLA_Import ); case 9 : return( new CSRTM30_Import ); case 10: return( new CBMP_Export ); case 11: return( new CErdas_LAN_Import ); case 12: return( new CGrid_Table_Import ); case 13: return( new CWRF_Import ); case 14: return( new CWRF_Export ); case 16: return( new CImport_Clip_Resample ); //----------------------------------------------------- case 17: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/io/io_grid/wrf.h0000744000175000017500000001373212737416173021037 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wrf.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO // // // //-------------------------------------------------------// // // // wrf.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__wrf_Import_H #define HEADER_INCLUDED__wrf_Import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWRF_Index { public: CWRF_Index(void); bool Reset (void); bool Load (const CSG_String &File); bool Save (const CSG_String &File); bool m_SIGNED, m_ENDIAN; int m_TYPE, m_WORDSIZE, m_TILE_X, m_TILE_Y, m_TILE_Z, m_TILE_Z_START, m_TILE_Z_END, m_CATEGORY_MIN, m_CATEGORY_MAX, m_TILE_BDR, m_ROW_ORDER; int m_ISWATER, m_ISLAKE, m_ISICE, m_ISURBAN, m_ISOILWATER; double m_DX, m_DY, m_KNOWN_X, m_KNOWN_Y, m_KNOWN_LAT, m_KNOWN_LON, m_STDLON, m_TRUELAT1, m_TRUELAT2, m_MISSING_VALUE, m_SCALE_FACTOR; CSG_String m_PROJECTION, m_UNITS, m_DESCRIPTION, m_MMINLU; }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWRF_Import : public CSG_Module { public: CWRF_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: CWRF_Index m_Index; bool Load (const CSG_String &File); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWRF_Export : public CSG_Module_Grid { public: CWRF_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CWRF_Index m_Index; bool Save (const CSG_String &Directory, CSG_Parameter_Grid_List *pGrids); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__wrf_Import_H saga-2.3.1/src/modules/io/io_shapes_las/0000775000175000017500000000000012737740005021252 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/io/io_shapes_las/las_info.cpp0000744000175000017500000005452612737416175023573 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_info.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_info.cpp // // // // Copyright (C) 2010 by // // Volker Wichmann // // // // Implementation builds upon the lasinfo tool of // // Martin Isenburg (isenburg@cs.unc.edu) // // Copyright (C) 2007 // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "las_info.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLAS_Info::CLAS_Info(void) { Set_Name (_TL("LAS Info")); Set_Author (SG_T("Volker Wichmann (c) 2010, LASERDATA GmbH")); CSG_String Description(_TW( "Prints information on ASPRS LAS files (versions 1.0, 1.1 and 1.2) " "using the \"libLAS\" library. " "Get more information about this library at " "http://liblas.org\n" "Implementation of this module builds upon the lasinfo tool of " "Martin Isenburg.\n" "\n" "\nliblas version: " )); Description += CSG_String(LIBLAS_RELEASE_NAME); Set_Description (Description); //----------------------------------------------------- Parameters.Add_FilePath( NULL , "FILE" , _TL("LAS File"), _TL(""), _TL("LAS Files (*.las)|*.las|All Files|*.*") ); Parameters.Add_Value( NULL , "HEADER" , _TL("Only Header Info"), _TL("Print only information available in LAS header."), PARAMETER_TYPE_Bool, false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLAS_Info::On_Execute(void) { CSG_String fName; bool bHeader; std::ifstream ifs; LASPointSummary summary; //----------------------------------------------------- fName = Parameters("FILE")->asString(); bHeader = Parameters("HEADER")->asBool(); //----------------------------------------------------- ifs.open(fName.b_str(), std::ios::in | std::ios::binary); if (!ifs) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unable to open LAS file!"))); return (false); } //----------------------------------------------------- // Check if LAS version is supported liblas::LASReader *pReader; try { pReader = new liblas::LASReader(ifs); } catch(std::exception &e) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("LAS header exception: %s"), e.what())); ifs.close(); return (false); } catch(...) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unknown LAS header exception!"))); ifs.close(); return (false); } delete (pReader); ifs.clear(); //----------------------------------------------------- liblas::LASReader reader(ifs); liblas::LASHeader const& header = reader.GetHeader(); //----------------------------------------------------- Print_Header(fName, header); if( !bHeader ) { LASPointSummary *pSummary; pSummary = (LASPointSummary*) malloc(sizeof(LASPointSummary)); if( !Summarize_Points(&reader, pSummary, header.GetPointRecordsCount()) ) return (false); if( !Print_Point_Summary(header, pSummary) ) return (false); free (pSummary); } //----------------------------------------------------- ifs.close(); return( true ); } //--------------------------------------------------------- bool CLAS_Info::Print_Header(CSG_String fName, liblas::LASHeader header) { SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); SG_UI_Msg_Add(_TL(" Header Summary"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" File Name:\t\t\t%s"), fName.c_str()), true); if (SG_STR_CMP(header.GetFileSignature().c_str(), SG_T("LASF"))) { SG_UI_Msg_Add_Error(_TL("File signature is not 'LASF'!")); return (false); } SG_UI_Msg_Add(CSG_String::Format(_TL(" Version:\t\t\t%d.%d"), header.GetVersionMajor(), header.GetVersionMinor()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Source ID:\t\t\t%d"), header.GetFileSourceId()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Reserved:\t\t\t%d"), header.GetReserved()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Project ID/GUID:\t\t'%s'"), CSG_String(header.GetProjectId().to_string().c_str()).w_str()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" System Identifier:\t\t'%s'"), CSG_String(header.GetSystemId().c_str()).w_str()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Generating Software:\t\t'%s'"), CSG_String(header.GetSoftwareId().c_str()).w_str()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" File Creation Day/Year:\t\t%d/%d"), header.GetCreationDOY(), header.GetCreationYear()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Header Size:\t\t\t%d"), header.GetHeaderSize()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Offset to Point Data:\t\t%d"), header.GetDataOffset()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Number Var. Length Records:\t%d"), header.GetRecordsCount()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Point Data Format:\t\t%d"), header.GetDataFormatId()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Point Data Record Length:\t%d"), header.GetDataRecordLength()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Number of Point Records:\t%d"), header.GetPointRecordsCount()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Number of Points by Return:\t%d %d %d %d %d"), header.GetPointRecordsByReturnCount().at(0), header.GetPointRecordsByReturnCount().at(1), header.GetPointRecordsByReturnCount().at(2), header.GetPointRecordsByReturnCount().at(3), header.GetPointRecordsByReturnCount().at(4)), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Scale Factor X Y Z:\t\t%.6g %.6g %.6g"), header.GetScaleX(), header.GetScaleY(), header.GetScaleZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Offset X Y Z:\t\t\t%.6f %.6f %.6f"), header.GetOffsetX(), header.GetOffsetY(), header.GetOffsetZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Min X Y Z:\t\t\t%.6f %.6f %.6f"), header.GetMinX(), header.GetMinY(), header.GetMinZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Max X Y Z:\t\t\t%.6f %.6f %.6f"), header.GetMaxX(), header.GetMaxY(), header.GetMaxZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Spatial Reference:\t\t%s"), CSG_String(header.GetSRS().GetProj4().c_str()).w_str()), true); return (true); } //--------------------------------------------------------- bool CLAS_Info::Print_Point_Summary(liblas::LASHeader header, LASPointSummary *pSummary) { long rgpsum = 0; long pbretsum = 0; int i = 0; if( pSummary->number_of_point_records == 0 ) { SG_UI_Msg_Add_Error(_TL("Point summary contains no points!")); return (false); } SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); SG_UI_Msg_Add(_TL(" Point Inspection Summary"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Header Point Count:\t\t%d"), header.GetPointRecordsCount()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Actual Point Count:\t\t%d"), pSummary->number_of_point_records), true); SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL(" Minimum and Maximum Attributes (min, max)"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Min X Y Z:\t\t\t%.6f %.6f %.6f"), pSummary->pmin.GetX(), pSummary->pmin.GetY(), pSummary->pmin.GetZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Max X Y Z:\t\t\t%.6f %.6f %.6f"), pSummary->pmax.GetX(), pSummary->pmax.GetY(), pSummary->pmax.GetZ()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Bounding Box:\t\t\t%.2f, %.2f, %.2f, %.2f"), pSummary->pmin.GetX(), pSummary->pmin.GetY(), pSummary->pmax.GetX(), pSummary->pmax.GetY()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Time:\t\t\t\t%.6f, %.6f"), pSummary->pmin.GetTime(), pSummary->pmax.GetTime()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Return Number:\t\t%d, %d"), pSummary->pmin.GetReturnNumber(), pSummary->pmax.GetReturnNumber()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Return Count:\t\t\t%d, %d"), pSummary->pmin.GetNumberOfReturns(), pSummary->pmax.GetNumberOfReturns()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Flightline Edge:\t\t\t%d, %d"), pSummary->pmin.GetFlightLineEdge(), pSummary->pmax.GetFlightLineEdge()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Intensity:\t\t\t%d, %d"), pSummary->pmin.GetIntensity(), pSummary->pmax.GetIntensity()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Scan Direction Flag:\t\t%d, %d"), pSummary->pmin.GetScanDirection(), pSummary->pmax.GetScanDirection()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Scan Angle Rank:\t\t%d, %d"), pSummary->pmin.GetScanAngleRank(), pSummary->pmax.GetScanAngleRank()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Classification:\t\t\t%d, %d"), pSummary->pmin.GetClassification(), pSummary->pmax.GetClassification()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Point Source Id:\t\t%d, %d"), pSummary->pmin.GetPointSourceID(), pSummary->pmax.GetPointSourceID()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Minimum Color:\t\t\t%d %d %d"), pSummary->pmin.GetColor().GetRed(), pSummary->pmin.GetColor().GetGreen(), pSummary->pmin.GetColor().GetBlue()), true); SG_UI_Msg_Add(CSG_String::Format(_TL(" Maximum Color:\t\t%d %d %d"), pSummary->pmax.GetColor().GetRed(), pSummary->pmax.GetColor().GetGreen(), pSummary->pmax.GetColor().GetBlue()), true); SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL(" Number of Points by Return"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); for( i=0; i<5; i++ ) { pbretsum = pbretsum + pSummary->number_of_points_by_return[i]; SG_UI_Msg_Add(CSG_String::Format(SG_T("\t(%d) %d"), i, pSummary->number_of_points_by_return[i]), true); } SG_UI_Msg_Add(CSG_String::Format(_TL(" Total Points:\t%ld"), pbretsum), true); SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL(" Number of Returns by Pulse"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); for( i=0; i<8; i++ ) { rgpsum = rgpsum + pSummary->number_of_returns_of_given_pulse[i]; SG_UI_Msg_Add(CSG_String::Format(SG_T("\t(%d) %d"), i, pSummary->number_of_returns_of_given_pulse[i]), true); } SG_UI_Msg_Add(CSG_String::Format(_TL(" Total Pulses:\t%ld"), rgpsum), true); for( i=0; i<5; i++ ) { if( header.GetPointRecordsByReturnCount().at(i) != pSummary->number_of_points_by_return[i] ) { SG_UI_Msg_Add(CSG_String::Format(_TL(" Actual number of points by return is different from header (actual, header):")), true); for( int j=0; i<5; i++ ) { SG_UI_Msg_Add(CSG_String::Format(SG_T("\t(%d, %d"), pSummary->number_of_points_by_return[j], header.GetPointRecordsByReturnCount().at(j)), true); } } } SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL(" Point Classifications"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); for( i=0; i<32; i++ ) { if( pSummary->classification[i] ) { SG_UI_Msg_Add(CSG_String::Format(SG_T("\t%d\t\t%s (%d)"), pSummary->classification[i], gLASPointClassification_Key_Name[i], i), true); } } if( pSummary->classification_synthetic || pSummary->classification_keypoint || pSummary->classification_withheld ) { SG_UI_Msg_Add(SG_T(""), true); SG_UI_Msg_Add(_TL(" Point Classification Histogram"), true, SG_UI_MSG_STYLE_BOLD); SG_UI_Msg_Add(SG_T("---------------------------------------------------------"), true); if( pSummary->classification_synthetic ) SG_UI_Msg_Add(CSG_String::Format(_TL(" +-> flagged as synthetic:\t%d"), pSummary->classification_synthetic), true); if( pSummary->classification_keypoint ) SG_UI_Msg_Add(CSG_String::Format(_TL(" +-> flagged as keypoints:\t%d"), pSummary->classification_keypoint), true); if( pSummary->classification_withheld ) SG_UI_Msg_Add(CSG_String::Format(_TL(" +-> flagged as withheld:\t%d"), pSummary->classification_withheld), true); } return (true); } //--------------------------------------------------------- bool CLAS_Info::Summarize_Points(liblas::LASReader *pReader, LASPointSummary *pSummary, int headerPts) { liblas::LASColor color; liblas::LASColor min_color; liblas::LASColor max_color; liblas::uint8_t cls = 0; liblas::uint16_t red = 0; liblas::uint16_t green = 0; liblas::uint16_t blue = 0; liblas::uint16_t ptsrc = 0; int i = 0; bool bValid = false; pSummary->number_of_point_records = 0; for( i=0; i<8; i++ ) pSummary->number_of_points_by_return[i] = 0; for( i=0; i<8; i++ ) pSummary->number_of_returns_of_given_pulse[i] = 0; for( i=0; i<32; i++ ) pSummary->classification[i] = 0; pSummary->classification_synthetic = 0; pSummary->classification_keypoint = 0; pSummary->classification_withheld = 0; //----------------------------------------------------- if( !pReader->ReadNextPoint() ) { SG_UI_Msg_Add_Error(_TL("Unable to read points from LAS file!")); return (false); } else bValid = true; liblas::LASPoint const& p = pReader->GetPoint(); pSummary->pmin = p; pSummary->pmax = p; i = 1; //----------------------------------------------------- while( bValid ) { if (i % 100000 == 0) SG_UI_Process_Set_Progress(i, headerPts); pSummary->x = p.GetX(); if( pSummary->x < pSummary->pmin.GetX() ) pSummary->pmin.SetX(pSummary->x); if( pSummary->x > pSummary->pmax.GetX() ) pSummary->pmax.SetX(pSummary->x); pSummary->y = p.GetY(); if( pSummary->y < pSummary->pmin.GetY() ) pSummary->pmin.SetY(pSummary->y); if( pSummary->y > pSummary->pmax.GetY() ) pSummary->pmax.SetY(pSummary->y); pSummary->z = p.GetZ(); if( pSummary->z < pSummary->pmin.GetZ() ) pSummary->pmin.SetZ(pSummary->z); if( pSummary->z > pSummary->pmax.GetZ() ) pSummary->pmax.SetZ(pSummary->z); pSummary->intensity = p.GetIntensity(); if( pSummary->intensity < pSummary->pmin.GetIntensity() ) pSummary->pmin.SetIntensity(pSummary->intensity); if( pSummary->intensity > pSummary->pmax.GetIntensity() ) pSummary->pmax.SetIntensity(pSummary->intensity); pSummary->t = p.GetTime(); if( pSummary->t < pSummary->pmin.GetTime() ) pSummary->pmin.SetTime(pSummary->t); if( pSummary->t > pSummary->pmax.GetTime() ) pSummary->pmax.SetTime(pSummary->t); pSummary->retnum = p.GetReturnNumber(); if( pSummary->retnum < pSummary->pmin.GetReturnNumber() ) pSummary->pmin.SetReturnNumber(pSummary->retnum); if( pSummary->retnum > pSummary->pmax.GetReturnNumber() ) pSummary->pmax.SetReturnNumber(pSummary->retnum); pSummary->numret = p.GetNumberOfReturns(); if( pSummary->numret < pSummary->pmin.GetNumberOfReturns() )pSummary->pmin.SetNumberOfReturns(pSummary->numret); if( pSummary->numret > pSummary->pmax.GetNumberOfReturns() )pSummary->pmax.SetNumberOfReturns(pSummary->numret); pSummary->scandir = p.GetScanDirection(); if( pSummary->scandir < pSummary->pmin.GetScanDirection() ) pSummary->pmin.SetScanDirection(pSummary->scandir); if( pSummary->scandir > pSummary->pmax.GetScanDirection() ) pSummary->pmax.SetScanDirection(pSummary->scandir); pSummary->fedge = p.GetFlightLineEdge(); if( pSummary->fedge < pSummary->pmin.GetFlightLineEdge() ) pSummary->pmin.SetFlightLineEdge(pSummary->fedge); if( pSummary->fedge > pSummary->pmax.GetFlightLineEdge() ) pSummary->pmax.SetFlightLineEdge(pSummary->fedge); pSummary->scan_angle = p.GetScanAngleRank(); if( pSummary->scan_angle < pSummary->pmin.GetScanAngleRank() ) pSummary->pmin.SetScanAngleRank(pSummary->scan_angle); if( pSummary->scan_angle > pSummary->pmax.GetScanAngleRank() ) pSummary->pmax.SetScanAngleRank(pSummary->scan_angle); pSummary->user_data = p.GetUserData(); if( pSummary->user_data < pSummary->pmin.GetUserData() ) pSummary->pmin.SetUserData(pSummary->user_data); if( pSummary->user_data > pSummary->pmax.GetUserData() ) pSummary->pmax.SetUserData(pSummary->user_data); pSummary->number_of_point_records = i; if( p.GetReturnNumber() ) pSummary->number_of_points_by_return[p.GetReturnNumber() - 1]++; else pSummary->number_of_points_by_return[p.GetReturnNumber()]++; pSummary->number_of_returns_of_given_pulse[p.GetNumberOfReturns()]++; cls = p.GetClassification(); if( cls < pSummary->pmin.GetClassification() ) pSummary->pmin.SetClassification(cls); if( cls > pSummary->pmax.GetClassification() ) pSummary->pmax.SetClassification(cls); ptsrc = p.GetPointSourceID(); if( ptsrc < pSummary->pmin.GetPointSourceID() ) pSummary->pmin.SetPointSourceID(ptsrc); if( ptsrc > pSummary->pmax.GetPointSourceID() ) pSummary->pmax.SetPointSourceID(ptsrc); color = p.GetColor(); min_color = pSummary->pmin.GetColor(); max_color = pSummary->pmax.GetColor(); min_color.GetRed() < color.GetRed() ? red = min_color.GetRed() : red = color.GetRed(); min_color.GetGreen() < color.GetGreen() ? green = min_color.GetGreen() : green = color.GetGreen(); min_color.GetBlue() < color.GetBlue() ? blue = min_color.GetBlue() : blue = color.GetBlue(); min_color.SetRed(red); min_color.SetGreen(green); min_color.SetBlue(blue); pSummary->pmin.SetColor(min_color); max_color.GetRed() > color.GetRed() ? red = max_color.GetRed() : red = color.GetRed(); max_color.GetGreen() > color.GetGreen() ? green = max_color.GetGreen() : green = color.GetGreen(); max_color.GetBlue() > color.GetBlue() ? blue = max_color.GetBlue() : blue = color.GetBlue(); max_color.SetRed(red); max_color.SetGreen(green); max_color.SetBlue(blue); pSummary->pmax.SetColor(max_color); pSummary->classification[cls & 31]++; if( cls & 32 ) pSummary->classification_synthetic++; if( cls & 64 ) pSummary->classification_keypoint++; if( cls & 128 ) pSummary->classification_withheld++; if( !pReader->ReadNextPoint() ) bValid = false; else { bValid = true; liblas::LASPoint const& p = pReader->GetPoint(); i++; } } return (true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes_las/las_export.cpp0000744000175000017500000003551412737416174024154 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_export.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_export.cpp // // // // Copyright (C) 2010 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "las_export.h" #include #include #include #include #include #include //--------------------------------------------------------- #define MAX_NUM_RETURN 5 //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLAS_Export::CLAS_Export(void) { CSG_Parameter *pNodeAttr; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export LAS Files")); Set_Author (SG_T("Volker Wichmann (c) 2010, LASERDATA GmbH")); CSG_String Description(_TW( "This module exports a SAGA Point Cloud as ASPRS LAS file (version 1.2) " "using the \"libLAS\" library. It allows writing Point Data Record Formats 1 to 4. " "Please have a look at the ASPRS LAS 1.2 Format Specification for " "more information on the attributes supported with each format.\n" "Get more information about the \"libLAS\" library at " "http://liblas.org\n" "Please note, that the liblas writer does an \"isValid()\" check on each point. " "This might cause problems with MLS data because of the included scan angle check. " "MLS data ususally includes larger scan angles than ALS data and thus points may fail the " "test. Please always have a look at the summary printed in the message window.\n\n" "\nliblas version: " )); Description += CSG_String(LIBLAS_RELEASE_NAME); Set_Description (Description); //----------------------------------------------------- // 2. Parameters... pNodeAttr = Parameters.Add_PointCloud( NULL , "POINTS" , _TL("Point Cloud"), _TL("The point cloud to export."), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNodeAttr , "T" , _TL("gps-time"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "i" , _TL("intensity"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "a" , _TL("scan angle"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "r" , _TL("number of the return"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "n" , _TL("number of returns of given pulse"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "c" , _TL("classification"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "u" , _TL("user data"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "R" , _TL("red channel color"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "G" , _TL("green channel color"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "B" , _TL("blue channel color"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "e" , _TL("edge of flight line flag"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "d" , _TL("direction of scan flag"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "p" , _TL("point source ID"), _TL(""), true ); Parameters.Add_Table_Field( pNodeAttr , "RGB" , _TL("SAGA RGB color"), _TL(""), true ); Parameters.Add_Value( NULL , "OFF_X" , _TL("Offset X"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( NULL , "OFF_Y" , _TL("Offset Y"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( NULL , "OFF_Z" , _TL("Offset Z"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_Value( NULL , "SCALE_X" , _TL("Scale X"), _TL(""), PARAMETER_TYPE_Double, 0.001 ); Parameters.Add_Value( NULL , "SCALE_Y" , _TL("Scale Y"), _TL(""), PARAMETER_TYPE_Double, 0.001 ); Parameters.Add_Value( NULL , "SCALE_Z" , _TL("Scale Z"), _TL(""), PARAMETER_TYPE_Double, 0.001 ); Parameters.Add_Choice( NULL, "FORMAT", _TL("Point Data Record Format"), _TL("Choose the Point Data Record Format you like to use"), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("0"), _TL("1"), _TL("2"), _TL("3") ), 3 ); Parameters.Add_FilePath( NULL , "FILE" , _TL("Output File"), _TL("The LAS output file."), _TL("LAS Files (*.las)|*.las|All Files|*.*"), NULL, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLAS_Export::On_Execute(void) { CSG_PointCloud *pPoints; CSG_String fName; int i_T, i_i, i_a, i_r, i_n, i_c, i_u, i_R, i_G, i_B, i_e, i_d, i_p, i_RGB; double off_X, off_Y, off_Z; double scale_X, scale_Y, scale_Z; int format; int cntRead = 0, cntWrite = 0; double x, y, z, xmin, ymin, zmin, xmax, ymax, zmax; liblas::uint32_t binPulse[MAX_NUM_RETURN]; liblas::uint16_t r; std::ofstream ofs; //----------------------------------------------------- pPoints = Parameters("POINTS")->asPointCloud(); i_T = Parameters("T")->asInt(); i_i = Parameters("i")->asInt(); i_a = Parameters("a")->asInt(); i_r = Parameters("r")->asInt(); i_n = Parameters("n")->asInt(); i_c = Parameters("c")->asInt(); i_u = Parameters("u")->asInt(); i_R = Parameters("R")->asInt(); i_G = Parameters("G")->asInt(); i_B = Parameters("B")->asInt(); i_e = Parameters("e")->asInt(); i_d = Parameters("d")->asInt(); i_p = Parameters("p")->asInt(); i_RGB = Parameters("RGB")->asInt(); off_X = Parameters("OFF_X")->asDouble(); off_Y = Parameters("OFF_Y")->asDouble(); off_Z = Parameters("OFF_Z")->asDouble(); scale_X = Parameters("SCALE_X")->asDouble(); scale_Y = Parameters("SCALE_Y")->asDouble(); scale_Z = Parameters("SCALE_Z")->asDouble(); format = Parameters("FORMAT")->asInt(); fName = Parameters("FILE")->asString(); ofs.open(fName.b_str(), std::ios::out | std::ios::binary); if (!ofs) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unable to open LAS file!"))); return (false); } //----------------------------------------------------- liblas::LASHeader header; switch (format) { case 0: header.SetDataFormatId(liblas::LASHeader::ePointFormat0); break; case 1: header.SetDataFormatId(liblas::LASHeader::ePointFormat1); break; case 2: header.SetDataFormatId(liblas::LASHeader::ePointFormat2); break; case 3: default: header.SetDataFormatId(liblas::LASHeader::ePointFormat3); break; } header.SetOffset(off_X, off_Y, off_Z); header.SetScale(scale_X, scale_Y, scale_Z); // Get_ZMin() and Get_ZMax() do currently not work: /*header.SetMin( (pPoints->Get_Extent().Get_XMin() - off_X) / scale_X, (pPoints->Get_Extent().Get_YMin() - off_Y) / scale_Y, (pPoints->Get_ZMin() - off_Z) / scale_Z); header.SetMax( (pPoints->Get_Extent().Get_XMax() - off_X) / scale_X, (pPoints->Get_Extent().Get_YMax() - off_Y) / scale_Y, (pPoints->Get_ZMax() - off_Z) / scale_Z);*/ liblas::LASWriter writer(ofs, header); if( pPoints->Get_Count() > 0 ) { xmin = xmax = pPoints->Get_X(0); ymin = ymax = pPoints->Get_Y(0); zmin = zmax = pPoints->Get_Z(0); } for( int i=0; iGet_Count(); i++ ) { if (i % 100000 == 0) SG_UI_Process_Set_Progress(i, pPoints->Get_Count()); cntRead++; liblas::LASPoint point; x = pPoints->Get_X(i); y = pPoints->Get_Y(i); z = pPoints->Get_Z(i); x < xmin ? xmin = x : NULL; x > xmax ? xmax = x : NULL; y < ymin ? ymin = y : NULL; y > ymax ? ymax = y : NULL; z < zmin ? zmin = z : NULL; z > zmax ? zmax = z : NULL; point.SetCoordinates(x, y, z); if( i_T > -1 ) point.SetTime(pPoints->Get_Value(i, i_T)); if( i_i > -1 ) point.SetIntensity((liblas::uint16_t)pPoints->Get_Value(i, i_i)); if( i_a > -1 ) point.SetScanAngleRank((liblas::int8_t)pPoints->Get_Value(i, i_a)); if( i_r > -1 ) { r = (liblas::uint16_t)pPoints->Get_Value(i, i_r); point.SetReturnNumber(r); if( r > 0 && r <= MAX_NUM_RETURN ) binPulse[r-1] += 1; } if( i_n > -1 ) point.SetNumberOfReturns((liblas::uint16_t)pPoints->Get_Value(i, i_n)); if( i_c > -1 ) point.SetClassification((liblas::int8_t)pPoints->Get_Value(i, i_c)); if( i_u > -1 ) point.SetUserData((liblas::int8_t)pPoints->Get_Value(i, i_u)); if( i_R > -1 && i_G > -1 && i_B > -1 ) { liblas::LASColor color; color.SetRed((liblas::uint16_t)pPoints->Get_Value(i, i_R)); color.SetGreen((liblas::uint16_t)pPoints->Get_Value(i, i_G)); color.SetBlue((liblas::uint16_t)pPoints->Get_Value(i, i_B)); point.SetColor(color); } else if( i_RGB > -1 ) { liblas::LASColor color; color.SetRed((liblas::uint16_t)SG_GET_R((int)pPoints->Get_Value(i, i_RGB))); color.SetGreen((liblas::uint16_t)SG_GET_G((int)pPoints->Get_Value(i, i_RGB))); color.SetBlue((liblas::uint16_t)SG_GET_B((int)pPoints->Get_Value(i, i_RGB))); point.SetColor(color); } if( i_e > -1 ) point.SetFlightLineEdge((liblas::uint16_t)pPoints->Get_Value(i, i_e)); if( i_d > -1 ) point.SetScanDirection((liblas::uint16_t)pPoints->Get_Value(i, i_d)); if( i_p > -1 ) point.SetPointSourceID((liblas::uint16_t)pPoints->Get_Value(i, i_p)); if( writer.WritePoint(point) ) cntWrite++; } header.SetMin(xmin, ymin, zmin); header.SetMax(xmax, ymax, zmax); SG_UI_Msg_Add(_TL("Summary:\n"), true); if( i_r > -1 ) { SG_UI_Msg_Add(_TL("Number of points per return:"), true); for( int i=0; iGet_Identifier(), SG_T("POINTS"))) // set attribute field choices to - NOT SET - { if (pParameters->Get_Parameter("POINTS")->asPointCloud() != NULL) { int cntFields = pParameters->Get_Parameter("POINTS")->asPointCloud()->Get_Field_Count(); pParameters->Get_Parameter("T")->Set_Value(cntFields); pParameters->Get_Parameter("i")->Set_Value(cntFields); pParameters->Get_Parameter("a")->Set_Value(cntFields); pParameters->Get_Parameter("r")->Set_Value(cntFields); pParameters->Get_Parameter("n")->Set_Value(cntFields); pParameters->Get_Parameter("c")->Set_Value(cntFields); pParameters->Get_Parameter("u")->Set_Value(cntFields); pParameters->Get_Parameter("R")->Set_Value(cntFields); pParameters->Get_Parameter("G")->Set_Value(cntFields); pParameters->Get_Parameter("B")->Set_Value(cntFields); pParameters->Get_Parameter("e")->Set_Value(cntFields); pParameters->Get_Parameter("d")->Set_Value(cntFields); pParameters->Get_Parameter("p")->Set_Value(cntFields); pParameters->Get_Parameter("RGB")->Set_Value(cntFields); } } return (true); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes_las/las_info.h0000744000175000017500000001540712737416175023233 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_info.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_info.h // // // // Copyright (C) 2010 by // // Volker Wichmann // // // // Implementation builds upon the lasinfo tool of // // Martin Isenburg (isenburg@cs.unc.edu) // // Copyright (C) 2007 // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__las_info_H #define HEADER_INCLUDED__las_info_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #include #include #include #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// const SG_Char gLASPointClassification_Key_Name[32][32] = { SG_T("Created, never classified"), SG_T("Unclassified"), SG_T("Ground"), SG_T("Low Vegetation"), SG_T("Medium Vegetation"), SG_T("High Vegetation"), SG_T("Building"), SG_T("Low Point (noise)"), SG_T("Model Key-point (mass point)"), SG_T("Water"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Overlap Points"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition"), SG_T("Reserved for ASPRS Definition") }; typedef struct { double t; double x, y, z; liblas::uint16_t intensity; liblas::uint8_t cls; liblas::int8_t scan_angle; liblas::uint8_t user_data; liblas::uint16_t retnum; liblas::uint16_t numret; liblas::uint16_t scandir; liblas::uint16_t fedge; liblas::uint16_t red; liblas::uint16_t green; liblas::uint16_t blue; long rgpsum; int number_of_point_records; int number_of_points_by_return[8]; int number_of_returns_of_given_pulse[8]; int classification[32]; int classification_synthetic; int classification_keypoint; int classification_withheld; liblas::LASPoint pmax; liblas::LASPoint pmin; } LASPointSummary; //--------------------------------------------------------- class CLAS_Info : public CSG_Module { public: CLAS_Info(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); bool Print_Header (CSG_String fName, liblas::LASHeader header); bool Print_Point_Summary (liblas::LASHeader header, LASPointSummary *pSummary); bool Summarize_Points (liblas::LASReader *pReader, LASPointSummary *pSummary, int headerPts); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__las_info_H saga-2.3.1/src/modules/io/io_shapes_las/las_import.cpp0000744000175000017500000003440712737416175024146 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_import.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_import.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad, Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "las_import.h" #include #include #include #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { VAR_T = 0, // gps-time VAR_i, // intensity VAR_a, // scan angle VAR_r, // number of the return VAR_c, // classification VAR_u, // user data VAR_n, // number of returns of given pulse VAR_R, // red channel color VAR_G, // green channel color VAR_B, // blue channel color VAR_e, // edge of flight line flag VAR_d, // direction of scan flag VAR_p, // point source ID VAR_C, // color VAR_Count }; //--------------------------------------------------------- #define ADD_FIELD(id, var, name, type) if( Parameters(id)->asBool() ) { iField[var] = nFields++; pPoints->Add_Field(name, type); } else { iField[var] = -1; } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CLAS_Import::CLAS_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import LAS Files")); Set_Author (SG_T("O. Conrad, V. Wichmann (c) 2009")); CSG_String Description(_TW( "This module imports ASPRS LAS files (versions 1.0, 1.1 and 1.2) as Point Clouds " "using the \"libLAS\" library. " "Get more information about this library at " "http://liblas.org\n" "\n" "Besides the x,y,z coordinates, the user can decide upon which attributes " "should be imported from the LAS file.\n\n" "Module development was supported by " "http://Laserdata GmbH, Austria\n" "and " "http://alpS GmbH, Austria\n" "\nliblas version: " )); Description += CSG_String(LIBLAS_RELEASE_NAME); Set_Description (Description); //----------------------------------------------------- // 2. Parameters... Parameters.Add_FilePath( NULL , "FILES" , _TL("Input Files"), _TL(""), _TL("LAS Files (*.las)|*.las|LAS Files (*.LAS)|*.LAS|All Files|*.*"), NULL, false, false, true ); Parameters.Add_PointCloud_List( NULL , "POINTS" , _TL("Point Clouds"), _TL(""), PARAMETER_OUTPUT ); pNode = Parameters.Add_Node( NULL , "NODE_VARS" , _TL("Attributes to import besides x,y,z ..."), _TL("") ); Parameters.Add_Value(pNode, "T", _TL("gps-time") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "i", _TL("intensity") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "a", _TL("scan angle") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "r", _TL("number of the return") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "c", _TL("classification") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "u", _TL("user data") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "n", _TL("number of returns of given pulse"), _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "R", _TL("red channel color") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "G", _TL("green channel color") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "B", _TL("blue channel color") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "e", _TL("edge of flight line flag") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "d", _TL("direction of scan flag") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "p", _TL("point source ID") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value(pNode, "C", _TL("rgb color") , _TL(""), PARAMETER_TYPE_Bool, false); Parameters.Add_Value( NULL , "VALID" , _TL("Check Point Validity"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL , "RGB_RANGE", _TL("R,G,B value range"), _TL("Range of R,G,B values in LAS file."), CSG_String::Format(SG_T("%s|%s|"), _TL("16 bit"), _TL("8 bit") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CLAS_Import::On_Execute(void) { CSG_Parameter_PointCloud_List *pPointsList; bool bValidity; CSG_Strings Files; int RGBrange; int cntInvalid = 0; bValidity = Parameters("VALID")->asBool(); RGBrange = Parameters("RGB_RANGE")->asInt(); //----------------------------------------------------- if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) ) { return( false ); } //----------------------------------------------------- pPointsList = Parameters("POINTS")->asPointCloudList(); pPointsList ->Del_Items(); for(int i=0; iSet_Name(SG_File_Get_Name(Files[i], false)); nFields = 3; ADD_FIELD("T", VAR_T, _TL("gps-time") , SG_DATATYPE_Double); // SG_DATATYPE_Long ADD_FIELD("i", VAR_i, _TL("intensity") , SG_DATATYPE_Float); // SG_DATATYPE_Word ADD_FIELD("a", VAR_a, _TL("scan angle") , SG_DATATYPE_Float); // SG_DATATYPE_Byte ADD_FIELD("r", VAR_r, _TL("number of the return") , SG_DATATYPE_Int); ADD_FIELD("c", VAR_c, _TL("classification") , SG_DATATYPE_Int); // SG_DATATYPE_Byte ADD_FIELD("u", VAR_u, _TL("user data") , SG_DATATYPE_Double); // SG_DATATYPE_Byte ADD_FIELD("n", VAR_n, _TL("number of returns of given pulse") , SG_DATATYPE_Int); ADD_FIELD("R", VAR_R, _TL("red channel color") , SG_DATATYPE_Int); // SG_DATATYPE_Word ADD_FIELD("G", VAR_G, _TL("green channel color") , SG_DATATYPE_Int); ADD_FIELD("B", VAR_B, _TL("blue channel color") , SG_DATATYPE_Int); ADD_FIELD("e", VAR_e, _TL("edge of flight line flag") , SG_DATATYPE_Char); ADD_FIELD("d", VAR_d, _TL("direction of scan flag") , SG_DATATYPE_Char); ADD_FIELD("p", VAR_p, _TL("point source ID") , SG_DATATYPE_Int); // SG_DATATYPE_Word ADD_FIELD("C", VAR_C, _TL("rgb color") , SG_DATATYPE_Int); //----------------------------------------------------- int iPoint = 0; try { while( reader.ReadNextPoint() ) { if (iPoint % 100000 == 0) SG_UI_Process_Set_Progress(iPoint, header.GetPointRecordsCount()); liblas::LASPoint const& point = reader.GetPoint(); if( bValidity ) { if( !point.IsValid() ) { cntInvalid++; continue; } } pPoints->Add_Point(point.GetX(), point.GetY(), point.GetZ()); if( iField[VAR_T] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_T], point.GetTime()); if( iField[VAR_i] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_i], point.GetIntensity()); if( iField[VAR_a] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_a], point.GetScanAngleRank()); if( iField[VAR_r] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_r], point.GetReturnNumber()); if( iField[VAR_c] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_c], point.GetClassification()); if( iField[VAR_u] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_u], point.GetUserData()); if( iField[VAR_n] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_n], point.GetNumberOfReturns()); if( iField[VAR_R] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_R], point.GetColor().GetRed()); if( iField[VAR_G] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_G], point.GetColor().GetGreen()); if( iField[VAR_B] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_B], point.GetColor().GetBlue()); if( iField[VAR_e] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_e], point.GetFlightLineEdge()); if( iField[VAR_d] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_d], point.GetScanDirection()); if( iField[VAR_p] > 0 ) pPoints->Set_Value(iPoint, iField[VAR_p], point.GetPointSourceID()); if( iField[VAR_C] > 0 ) { double r, g, b; r = point.GetColor().GetRed(); g = point.GetColor().GetGreen(); b = point.GetColor().GetBlue(); if (RGBrange == 0) // 16 bit { r = r / 65535 * 255; g = g / 65535 * 255; b = b / 65535 * 255; } pPoints->Set_Value(iPoint, iField[VAR_C], SG_GET_RGB(r, g, b)); } iPoint++; } } catch(std::exception &e) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("LAS reader exception: %s"), e.what())); ifs.close(); return( false ); } catch(...) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unknown LAS reader exception!"))); ifs.close(); return( false ); } ifs.close(); pPointsList->Add_Item(pPoints); DataObject_Add(pPoints); //----------------------------------------------------- CSG_Parameters sParms; DataObject_Get_Parameters(pPoints, 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); // highest z sParms("COLORS_TYPE")->Set_Value(2); // graduated color sParms("METRIC_COLORS")->asColors()->Set_Count(255); // number of colors sParms("METRIC_ATTRIB")->Set_Value(2); // z attrib sParms("METRIC_ZRANGE")->asRange()->Set_Range(pPoints->Get_Minimum(2),pPoints->Get_Maximum(2)); } DataObject_Set_Parameters(pPoints, sParms); SG_UI_Msg_Add(_TL("okay"), false); } //----------------------------------------------------- if( bValidity && cntInvalid > 0 ) SG_UI_Msg_Add(CSG_String::Format(_TL("WARNING: %d invalid points skipped!"), cntInvalid), true); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes_las/las_import.h0000744000175000017500000001036012737416175023603 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_import.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_import.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__las_import_H #define HEADER_INCLUDED__las_import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLAS_Import : public CSG_Module { public: CLAS_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__las_import_H saga-2.3.1/src/modules/io/io_shapes_las/Makefile.in0000664000175000017500000005666512737447616023355 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/io/io_shapes_las ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) @HAVE_LLAS_TRUE@libio_shapes_las_la_DEPENDENCIES = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am__libio_shapes_las_la_SOURCES_DIST = las_export.cpp las_import.cpp \ las_info.cpp MLB_Interface.cpp las_export.h las_import.h \ las_info.h MLB_Interface.h @HAVE_LLAS_TRUE@am_libio_shapes_las_la_OBJECTS = las_export.lo \ @HAVE_LLAS_TRUE@ las_import.lo las_info.lo MLB_Interface.lo libio_shapes_las_la_OBJECTS = $(am_libio_shapes_las_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = @HAVE_LLAS_TRUE@am_libio_shapes_las_la_rpath = -rpath $(pkglibdir) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_shapes_las_la_SOURCES) DIST_SOURCES = $(am__libio_shapes_las_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG @HAVE_LLAS_TRUE@DEP_LIBS = -llas @HAVE_LLAS_TRUE@DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE @HAVE_LLAS_TRUE@CXX_INCS = -I$(top_srcdir)/src/saga_core @HAVE_LLAS_TRUE@AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) @HAVE_LLAS_TRUE@AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) @HAVE_LLAS_TRUE@pkglib_LTLIBRARIES = libio_shapes_las.la @HAVE_LLAS_TRUE@libio_shapes_las_la_SOURCES = \ @HAVE_LLAS_TRUE@las_export.cpp\ @HAVE_LLAS_TRUE@las_import.cpp\ @HAVE_LLAS_TRUE@las_info.cpp\ @HAVE_LLAS_TRUE@MLB_Interface.cpp\ @HAVE_LLAS_TRUE@las_export.h\ @HAVE_LLAS_TRUE@las_import.h\ @HAVE_LLAS_TRUE@las_info.h\ @HAVE_LLAS_TRUE@MLB_Interface.h @HAVE_LLAS_TRUE@libio_shapes_las_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/io/io_shapes_las/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_shapes_las/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_shapes_las.la: $(libio_shapes_las_la_OBJECTS) $(libio_shapes_las_la_DEPENDENCIES) $(EXTRA_libio_shapes_las_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) $(am_libio_shapes_las_la_rpath) $(libio_shapes_las_la_OBJECTS) $(libio_shapes_las_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/las_export.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/las_import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/las_info.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/io/io_shapes_las/las_export.h0000744000175000017500000001061312737416175023613 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: las_export.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // las_export.h // // // // Copyright (C) 2010 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata // // // // contact: Volker Wichmann // // LASERDATA GmbH // // Management and analysis of // // laserscanning data // // Innsbruck, Austria // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__las_export_H #define HEADER_INCLUDED__las_export_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CLAS_Export : public CSG_Module { public: CLAS_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); virtual int On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__las_export_H saga-2.3.1/src/modules/io/io_shapes_las/Makefile.am0000744000175000017500000000127712737416174023323 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif if HAVE_LLAS DEP_LIBS = -llas DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) pkglib_LTLIBRARIES = libio_shapes_las.la libio_shapes_las_la_SOURCES =\ las_export.cpp\ las_import.cpp\ las_info.cpp\ MLB_Interface.cpp\ las_export.h\ las_import.h\ las_info.h\ MLB_Interface.h libio_shapes_las_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) endif saga-2.3.1/src/modules/io/io_shapes_las/MLB_Interface.h0000744000175000017500000000754112737416174024032 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_shapes_las_H #define HEADER_INCLUDED__io_shapes_las_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_shapes_las_EXPORTS #define io_shapes_las_EXPORT _SAGA_DLL_EXPORT #else #define io_shapes_las_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_shapes_las_H saga-2.3.1/src/modules/io/io_shapes_las/MLB_Interface.cpp0000744000175000017500000001116312737416174024360 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_LAS // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("LAS") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("O. Conrad, V. Wichmann (c) 2009-10") ); case MLB_INFO_Description: return( _TL("Tools for the import and export of ASPRS LAS files.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Shapes") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "las_export.h" #include "las_import.h" #include "las_info.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CLAS_Export ); case 1: return( new CLAS_Import ); case 2: return( new CLAS_Info ); default: return( NULL ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/io/io_shapes_dxf/0000775000175000017500000000000012737740005021254 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/io/io_shapes_dxf/dxf_import.h0000744000175000017500000001317412737416174023614 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: dxf_import.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes_dxf // // // //-------------------------------------------------------// // // // dxf_import.cpp // // // // Copyright (C) 2007 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__dxf_import_H #define HEADER_INCLUDED__dxf_import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" #ifdef SYSTEM_DXFLIB #include #else #include "./dxflib/dl_creationadapter.h" #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CDXF_Import : public CSG_Module, DL_CreationAdapter { public: CDXF_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: int m_Filter; double m_dArc; TSG_Point_Z m_Offset; CSG_Shape *m_pPolyLine; CSG_Table *m_pLayers, *m_pBlocks; CSG_Shapes *m_pPoints, *m_pLines, *m_pPolyLines, *m_pPolygons, *m_pCircles, *m_pTriangles, *m_pText; void Check_Process (void); bool Check_Layer (const CSG_String &Name); void Add_Arc_Point (CSG_Shape *pShape, double cx, double cy, double d, double theta); void Add_Arc (CSG_Shape *pShape, double cx, double cy, double d, double alpha, double beta); virtual void addLayer (const DL_LayerData &data); virtual void addBlock (const DL_BlockData &data); virtual void endBlock (void); virtual void addPoint (const DL_PointData &data); virtual void addLine (const DL_LineData &data); virtual void addPolyline (const DL_PolylineData &data); virtual void addVertex (const DL_VertexData &data); virtual void endSequence (void); virtual void addArc (const DL_ArcData &data); virtual void addCircle (const DL_CircleData &data); virtual void add3dFace (const DL_3dFaceData &data); virtual void addText (const DL_TextData &data); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__dxf_import_H saga-2.3.1/src/modules/io/io_shapes_dxf/dxf_import.cpp0000744000175000017500000004274612737416174024156 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: dxf_import.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes_dxf // // // //-------------------------------------------------------// // // // dxf_import.cpp // // // // Copyright (C) 2007 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "dxf_import.h" #ifdef SYSTEM_DXFLIB #include #else #include "./dxflib/dl_dxf.h" #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define ADD_RESULT(list, result) if( result->is_Valid() && result->Get_Count() > 0 ) Parameters(list)->asList()->Add_Item(result); else delete(result); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { TBL_LAYERS_NAME = 0, TBL_LAYERS_FLAGS }; enum { TBL_BLOCKS_NAME = 0, TBL_BLOCKS_FLAGS, TBL_BLOCKS_X, TBL_BLOCKS_Y, TBL_BLOCKS_Z }; enum { TBL_POINTS_LAYER = 0, TBL_POINTS_Z }; enum { TBL_LINES_LAYER = 0, TBL_LINES_Z1, TBL_LINES_Z2 }; enum { TBL_POLYOBJ_LAYER = 0, TBL_POLYOBJ_FLAGS }; enum { TBL_TRIANGLE_LAYER = 0, TBL_TRIANGLE_THICK, TBL_TRIANGLE_Z1, TBL_TRIANGLE_Z2, TBL_TRIANGLE_Z3 }; enum { TBL_TEXT_LAYER = 0, TBL_TEXT_Z, TBL_TEXT_TEXT, TBL_TEXT_HEIGHT, TBL_TEXT_ANGLE, TBL_TEXT_APX, TBL_TEXT_APY, TBL_TEXT_APZ, TBL_TEXT_SCALE, TBL_TEXT_HJUST, TBL_TEXT_VJUST, TBL_TEXT_STYLE, TBL_TEXT_FLAGS }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CDXF_Import::CDXF_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import DXF Files")); Set_Author (SG_T("(c) 2007 by O.Conrad")); Set_Description (_TW( "This module imports DXF files using the free \"dxflib\" library. Get more information " "about this library from the RibbonSoft homepage at:\n" "http://www.ribbonsoft.com/dxflib.html" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_Shapes_List( NULL , "TABLES" , _TL("Tables"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("DXF Files (*.dxf)|*.dxf|All Files|*.*") ); Parameters.Add_Choice( NULL , "FILTER" , _TL("Import Filter"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("all entities"), _TL("only entities with layer definition"), _TL("only entities without layer definition") ), 1 ); Parameters.Add_Value( NULL , "DCIRCLE" , _TL("Circle Point Distance [Degree]"), _TL(""), PARAMETER_TYPE_Double, 5.0, 0.01, true, 45.0, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CDXF_Import::On_Execute(void) { CSG_String fName = Parameters("FILE")->asString(); Parameters("TABLES")->asTableList() ->Del_Items(); Parameters("SHAPES")->asShapesList()->Del_Items(); m_Filter = Parameters("FILTER") ->asInt(); m_dArc = Parameters("DCIRCLE") ->asDouble() * M_DEG_TO_RAD; //----------------------------------------------------- if( SG_File_Exists(fName) ) { m_pLayers = SG_Create_Table(); m_pLayers ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), SG_File_Get_Name(fName, false).c_str(), _TL("Layers"))); m_pLayers ->Add_Field("LAYER" , SG_DATATYPE_String); m_pLayers ->Add_Field("FLAGS" , SG_DATATYPE_Int); m_pBlocks = SG_Create_Table(); m_pBlocks ->Set_Name(CSG_String::Format(SG_T("%s [%s]"), SG_File_Get_Name(fName, false).c_str(), _TL("Blocks"))); m_pBlocks ->Add_Field("BLOCK" , SG_DATATYPE_String); m_pBlocks ->Add_Field("FLAGS" , SG_DATATYPE_Int); m_pBlocks ->Add_Field("X" , SG_DATATYPE_Double); m_pBlocks ->Add_Field("Y" , SG_DATATYPE_Double); m_pBlocks ->Add_Field("Z" , SG_DATATYPE_Double); m_pPoints = SG_Create_Shapes(SHAPE_TYPE_Point , CSG_String::Format(SG_T("%s [%s]"), SG_File_Get_Name(fName, false).c_str(), _TL("Points"))); m_pPoints ->Add_Field("LAYER" , SG_DATATYPE_String); m_pPoints ->Add_Field("Z" , SG_DATATYPE_Double); m_pLines = SG_Create_Shapes(SHAPE_TYPE_Line , CSG_String::Format(SG_T("%s [%s]"), SG_File_Get_Name(fName, false).c_str(), _TL("Lines"))); m_pLines ->Add_Field("LAYER" , SG_DATATYPE_String); m_pLines ->Add_Field("Z1" , SG_DATATYPE_Double); m_pLines ->Add_Field("Z2" , SG_DATATYPE_Double); m_pPolyLines = SG_Create_Shapes(SHAPE_TYPE_Line , CSG_String::Format(SG_T("%s [%s]"), SG_File_Get_Name(fName, false).c_str(), _TL("Polylines"))); m_pPolyLines ->Add_Field("LAYER" , SG_DATATYPE_String); m_pPolyLines ->Add_Field("FLAGS" , SG_DATATYPE_Int); m_pPolygons = SG_Create_Shapes(SHAPE_TYPE_Polygon , CSG_String::Format(SG_T("%s [%s]"), SG_File_Get_Name(fName, false).c_str(), _TL("Polygons"))); m_pPolygons ->Add_Field("LAYER" , SG_DATATYPE_String); m_pPolygons ->Add_Field("FLAGS" , SG_DATATYPE_Int); m_pCircles = SG_Create_Shapes(SHAPE_TYPE_Line , CSG_String::Format(SG_T("%s [%s]"), SG_File_Get_Name(fName, false).c_str(), _TL("Circles"))); m_pCircles ->Add_Field("LAYER" , SG_DATATYPE_String); m_pCircles ->Add_Field("FLAGS" , SG_DATATYPE_Int); m_pTriangles = SG_Create_Shapes(SHAPE_TYPE_Polygon , CSG_String::Format(SG_T("%s [%s]"), SG_File_Get_Name(fName, false).c_str(), _TL("Triangles"))); m_pTriangles ->Add_Field("LAYER" , SG_DATATYPE_String); m_pTriangles ->Add_Field("THICK" , SG_DATATYPE_Int); m_pTriangles ->Add_Field("Z1" , SG_DATATYPE_Double); m_pTriangles ->Add_Field("Z2" , SG_DATATYPE_Double); m_pTriangles ->Add_Field("Z3" , SG_DATATYPE_Double); m_pText = SG_Create_Shapes(SHAPE_TYPE_Point , CSG_String::Format(SG_T("%s [%s]"), SG_File_Get_Name(fName, false).c_str(), _TL("Text"))); m_pText ->Add_Field("LAYER" , SG_DATATYPE_String); m_pText ->Add_Field("Z" , SG_DATATYPE_Double); m_pText ->Add_Field("TEXT" , SG_DATATYPE_String); m_pText ->Add_Field("HEIGHT", SG_DATATYPE_Int); m_pText ->Add_Field("ANGLE" , SG_DATATYPE_Double); m_pText ->Add_Field("APX" , SG_DATATYPE_Double); m_pText ->Add_Field("APY" , SG_DATATYPE_Double); m_pText ->Add_Field("APZ" , SG_DATATYPE_Double); m_pText ->Add_Field("SCALE" , SG_DATATYPE_Double); m_pText ->Add_Field("HJUST" , SG_DATATYPE_Int); m_pText ->Add_Field("VJUST" , SG_DATATYPE_Int); m_pText ->Add_Field("STYLE" , SG_DATATYPE_String); m_pText ->Add_Field("FLAGS" , SG_DATATYPE_Int); //------------------------------------------------- m_Offset.x = 0.0; m_Offset.y = 0.0; m_Offset.z = 0.0; m_pPolyLine = NULL; DL_Dxf *pDXF = new DL_Dxf(); pDXF->in(fName.b_str(), this); delete(pDXF); //------------------------------------------------- ADD_RESULT("TABLES", m_pLayers); ADD_RESULT("TABLES", m_pBlocks); ADD_RESULT("SHAPES", m_pPoints); ADD_RESULT("SHAPES", m_pLines); ADD_RESULT("SHAPES", m_pPolyLines); ADD_RESULT("SHAPES", m_pPolygons); ADD_RESULT("SHAPES", m_pCircles); ADD_RESULT("SHAPES", m_pTriangles); ADD_RESULT("SHAPES", m_pText); } //----------------------------------------------------- return( Parameters("SHAPES")->asShapesList()->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline void CDXF_Import::Check_Process(void) { static int iProcess = 0; if( (iProcess++) % 100 == 0 ) { Process_Get_Okay(); } } //--------------------------------------------------------- inline bool CDXF_Import::Check_Layer(const CSG_String &Name) { Check_Process(); switch( m_Filter ) { case 1: return( Name.Cmp(SG_T("0")) != 0 ); case 2: return( Name.Cmp(SG_T("0")) == 0 ); } return( true ); } //--------------------------------------------------------- inline void CDXF_Import::Add_Arc_Point(CSG_Shape *pShape, double cx, double cy, double d, double theta) { pShape->Add_Point( cx + d * cos(theta), cy + d * sin(theta) ); } //--------------------------------------------------------- void CDXF_Import::Add_Arc(CSG_Shape *pShape, double cx, double cy, double d, double alpha, double beta) { double theta; alpha *= M_DEG_TO_RAD; beta *= M_DEG_TO_RAD; if( alpha > beta ) { beta += M_PI_360; } for(theta=alpha; thetaAdd_Record(); pRecord->Set_Value(TBL_LAYERS_NAME , CSG_String(data.name.c_str())); pRecord->Set_Value(TBL_LAYERS_FLAGS , data.flags); } //--------------------------------------------------------- void CDXF_Import::addBlock(const DL_BlockData &data) { CSG_Table_Record *pRecord = m_pBlocks->Add_Record(); pRecord->Set_Value(TBL_BLOCKS_NAME , CSG_String(data.name.c_str())); pRecord->Set_Value(TBL_BLOCKS_FLAGS , data.flags); pRecord->Set_Value(TBL_BLOCKS_X , data.bpx); pRecord->Set_Value(TBL_BLOCKS_Y , data.bpy); pRecord->Set_Value(TBL_BLOCKS_Z , data.bpz); } //--------------------------------------------------------- void CDXF_Import::endBlock(void) { } //--------------------------------------------------------- void CDXF_Import::addPoint(const DL_PointData &data) { if( !Check_Layer(attributes.getLayer().c_str()) ) return; CSG_Shape *pPoint = m_pPoints->Add_Shape(); pPoint->Add_Point(m_Offset.x + data.x, m_Offset.y + data.y); pPoint->Set_Value(TBL_POINTS_LAYER , CSG_String(attributes.getLayer().c_str())); pPoint->Set_Value(TBL_POINTS_Z , m_Offset.z + data.z); } //--------------------------------------------------------- void CDXF_Import::addLine(const DL_LineData &data) { if( !Check_Layer(attributes.getLayer().c_str()) ) return; CSG_Shape *pLine = m_pLines->Add_Shape(); pLine->Add_Point(m_Offset.x + data.x1, m_Offset.y + data.y1); pLine->Add_Point(m_Offset.x + data.x2, m_Offset.y + data.y2); pLine->Set_Value(TBL_LINES_LAYER , CSG_String(attributes.getLayer().c_str())); pLine->Set_Value(TBL_LINES_Z1 , m_Offset.z + data.z1); pLine->Set_Value(TBL_LINES_Z2 , m_Offset.z + data.z2); } //--------------------------------------------------------- void CDXF_Import::addPolyline(const DL_PolylineData &data) { if( !Check_Layer(attributes.getLayer().c_str()) ) return; switch( data.flags ) { default: case 0: m_pPolyLine = m_pPolyLines ->Add_Shape(); break; case 1: m_pPolyLine = m_pPolygons ->Add_Shape(); break; } m_pPolyLine->Set_Value(TBL_POLYOBJ_LAYER, CSG_String(attributes.getLayer().c_str())); } //--------------------------------------------------------- void CDXF_Import::addVertex(const DL_VertexData &data) { if( m_pPolyLine ) { m_pPolyLine->Add_Point(m_Offset.x + data.x, m_Offset.y + data.y); // data.z, data.bulge } } //--------------------------------------------------------- void CDXF_Import::endSequence(void) { if( m_pPolyLine ) { if( !m_pPolyLine->is_Valid() ) { ((CSG_Shapes *)m_pPolyLine->Get_Table())->Del_Shape(m_pPolyLine); } m_pPolyLine = NULL; } } //--------------------------------------------------------- void CDXF_Import::addCircle(const DL_CircleData &data) { if( !Check_Layer(attributes.getLayer().c_str()) ) return; CSG_Shape *pCircle = m_pCircles->Add_Shape(); Add_Arc(pCircle, data.cx, data.cy, data.radius, 0.0, 360.0); } //--------------------------------------------------------- void CDXF_Import::addArc(const DL_ArcData &data) { if( !Check_Layer(attributes.getLayer().c_str()) ) return; CSG_Shape *pArc = m_pPolyLine ? m_pPolyLine : m_pPolyLines->Add_Shape(); Add_Arc(pArc, data.cx, data.cy, data.radius, data.angle1, data.angle2); if( pArc != m_pPolyLine ) { pArc->Set_Value(TBL_POLYOBJ_LAYER, CSG_String(attributes.getLayer().c_str())); } } //--------------------------------------------------------- void CDXF_Import::add3dFace(const DL_3dFaceData &data) { if( !Check_Layer(attributes.getLayer().c_str()) ) return; CSG_Shape *pTriangle = m_pTriangles->Add_Shape(); for(int i=0; i<3; i++) { pTriangle->Add_Point(m_Offset.x + data.x[i], m_Offset.y + data.y[i]); } pTriangle->Set_Value(TBL_TRIANGLE_LAYER , CSG_String(attributes.getLayer().c_str())); pTriangle->Set_Value(TBL_TRIANGLE_THICK , data.thickness); pTriangle->Set_Value(TBL_TRIANGLE_Z1 , m_Offset.z + data.z[0]); pTriangle->Set_Value(TBL_TRIANGLE_Z2 , m_Offset.z + data.z[1]); pTriangle->Set_Value(TBL_TRIANGLE_Z3 , m_Offset.z + data.z[2]); } //--------------------------------------------------------- void CDXF_Import::addText(const DL_TextData &data) { if( !Check_Layer(attributes.getLayer().c_str()) ) return; CSG_Shape *pText = m_pText->Add_Shape(); pText->Add_Point(m_Offset.x + data.ipx, m_Offset.y + data.ipy); pText->Set_Value(TBL_TEXT_LAYER , CSG_String(attributes.getLayer().c_str())); pText->Set_Value(TBL_TEXT_Z , m_Offset.z + data.ipz); pText->Set_Value(TBL_TEXT_TEXT , CSG_String(data.text.c_str())); pText->Set_Value(TBL_TEXT_HEIGHT, data.height); pText->Set_Value(TBL_TEXT_ANGLE , data.angle * M_RAD_TO_DEG); pText->Set_Value(TBL_TEXT_APX , m_Offset.z + data.apx); pText->Set_Value(TBL_TEXT_APY , m_Offset.z + data.apy); pText->Set_Value(TBL_TEXT_APZ , m_Offset.z + data.apz); pText->Set_Value(TBL_TEXT_SCALE , data.xScaleFactor); pText->Set_Value(TBL_TEXT_HJUST , data.hJustification); pText->Set_Value(TBL_TEXT_VJUST , data.vJustification); pText->Set_Value(TBL_TEXT_STYLE , CSG_String(data.style.c_str())); pText->Set_Value(TBL_TEXT_SCALE , data.textGenerationFlags); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes_dxf/Makefile.in0000664000175000017500000006115012737447616023340 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @SYSTEM_DXFLIB_TRUE@am__append_1 = -ldxflib @SYSTEM_DXFLIB_FALSE@am__append_2 = \ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_dxf.cpp\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_writer_ascii.cpp\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_attributes.h\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_codes.h\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_creationadapter.h\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_creationinterface.h\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_dxf.h\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_entities.h\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_exception.h\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_extrusion.h\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_writer.h\ @SYSTEM_DXFLIB_FALSE@./dxflib/dl_writer_ascii.h subdir = src/modules/io/io_shapes_dxf ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) @SYSTEM_DXFLIB_FALSE@libio_shapes_dxf_la_DEPENDENCIES = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am__libio_shapes_dxf_la_SOURCES_DIST = dxf_import.cpp \ MLB_Interface.cpp dxf_import.h MLB_Interface.h \ ./dxflib/dl_dxf.cpp ./dxflib/dl_writer_ascii.cpp \ ./dxflib/dl_attributes.h ./dxflib/dl_codes.h \ ./dxflib/dl_creationadapter.h ./dxflib/dl_creationinterface.h \ ./dxflib/dl_dxf.h ./dxflib/dl_entities.h \ ./dxflib/dl_exception.h ./dxflib/dl_extrusion.h \ ./dxflib/dl_writer.h ./dxflib/dl_writer_ascii.h am__dirstamp = $(am__leading_dot)dirstamp @SYSTEM_DXFLIB_FALSE@am__objects_1 = ./dxflib/dl_dxf.lo \ @SYSTEM_DXFLIB_FALSE@ ./dxflib/dl_writer_ascii.lo am_libio_shapes_dxf_la_OBJECTS = dxf_import.lo MLB_Interface.lo \ $(am__objects_1) libio_shapes_dxf_la_OBJECTS = $(am_libio_shapes_dxf_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_shapes_dxf_la_SOURCES) DIST_SOURCES = $(am__libio_shapes_dxf_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(am__append_1) pkglib_LTLIBRARIES = libio_shapes_dxf.la libio_shapes_dxf_la_SOURCES = dxf_import.cpp MLB_Interface.cpp \ dxf_import.h MLB_Interface.h $(am__append_2) @SYSTEM_DXFLIB_FALSE@libio_shapes_dxf_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/io/io_shapes_dxf/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_shapes_dxf/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } dxflib/$(am__dirstamp): @$(MKDIR_P) ./dxflib @: > dxflib/$(am__dirstamp) dxflib/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) ./dxflib/$(DEPDIR) @: > dxflib/$(DEPDIR)/$(am__dirstamp) ./dxflib/dl_dxf.lo: dxflib/$(am__dirstamp) \ dxflib/$(DEPDIR)/$(am__dirstamp) ./dxflib/dl_writer_ascii.lo: dxflib/$(am__dirstamp) \ dxflib/$(DEPDIR)/$(am__dirstamp) libio_shapes_dxf.la: $(libio_shapes_dxf_la_OBJECTS) $(libio_shapes_dxf_la_DEPENDENCIES) $(EXTRA_libio_shapes_dxf_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_shapes_dxf_la_OBJECTS) $(libio_shapes_dxf_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) -rm -f ./dxflib/*.$(OBJEXT) -rm -f ./dxflib/*.lo distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dxf_import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./dxflib/$(DEPDIR)/dl_dxf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./dxflib/$(DEPDIR)/dl_writer_ascii.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs -rm -rf ./dxflib/.libs ./dxflib/_libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f dxflib/$(DEPDIR)/$(am__dirstamp) -rm -f dxflib/$(am__dirstamp) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) ./dxflib/$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) ./dxflib/$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/io/io_shapes_dxf/Makefile.am0000744000175000017500000000173012737416174023317 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_shapes_dxf.la libio_shapes_dxf_la_SOURCES =\ dxf_import.cpp\ MLB_Interface.cpp\ dxf_import.h\ MLB_Interface.h if SYSTEM_DXFLIB AM_LDFLAGS += -ldxflib else libio_shapes_dxf_la_SOURCES +=\ ./dxflib/dl_dxf.cpp\ ./dxflib/dl_writer_ascii.cpp\ ./dxflib/dl_attributes.h\ ./dxflib/dl_codes.h\ ./dxflib/dl_creationadapter.h\ ./dxflib/dl_creationinterface.h\ ./dxflib/dl_dxf.h\ ./dxflib/dl_entities.h\ ./dxflib/dl_exception.h\ ./dxflib/dl_extrusion.h\ ./dxflib/dl_writer.h\ ./dxflib/dl_writer_ascii.h libio_shapes_dxf_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) endif saga-2.3.1/src/modules/io/io_shapes_dxf/MLB_Interface.h0000744000175000017500000000773112737416174024035 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_DXF // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2007 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_shapes_dxf_H #define HEADER_INCLUDED__io_shapes_dxf_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_shapes_dxf_EXPORTS #define io_shapes_dxf_EXPORT _SAGA_DLL_EXPORT #else #define io_shapes_dxf_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_shapes_dxf_H saga-2.3.1/src/modules/io/io_shapes_dxf/MLB_Interface.cpp0000744000175000017500000001124012737416174024356 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO_DXF // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2007 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("DXF") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("O. Conrad (c) 2007") ); case MLB_INFO_Description: return( _TL("Tools for the import and export of DXF files.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Shapes") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "dxf_import.h" //#include "dxf_export.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CDXF_Import ); // case 1: return( new CDXF_Export ); default: return( NULL ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/io/Makefile.in0000664000175000017500000004722112737447616020530 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/io ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ distdir am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags DIST_SUBDIRS = io_esri_e00 io_gdal io_gps io_grid io_shapes \ io_shapes_dxf io_shapes_las io_table io_virtual io_grid_image am__DIST_COMMON = $(srcdir)/Makefile.in DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @WITH_GUI_FALSE@SUBDIRS = io_esri_e00 io_gdal io_gps io_grid io_shapes io_shapes_dxf io_shapes_las io_table io_virtual @WITH_GUI_TRUE@SUBDIRS = io_esri_e00 io_gdal io_gps io_grid io_grid_image io_shapes io_shapes_dxf io_shapes_las io_table io_virtual all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/io/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-recursive CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-recursive cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ check-am clean clean-generic clean-libtool cscopelist-am ctags \ ctags-am distclean distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-am uninstall uninstall-am .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/io/io_table/0000775000175000017500000000000012737740005020217 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/io/io_table/io_table_txt.cpp0000744000175000017500000005371112737416175023416 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: io_table_txt.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_io // // // //-------------------------------------------------------// // // // io_table_txt.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "io_table_txt.h" /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Text_Export::CTable_Text_Export(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Export Text Table")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Value( NULL , "HEADLINE" , _TL("Save Headline"), _TL(""), PARAMETER_TYPE_Bool , true ); Parameters.Add_Value( NULL , "STRQUOTA" , _TL("Strings in Quota"), _TL(""), PARAMETER_TYPE_Bool , true ); pNode = Parameters.Add_Choice( NULL , "SEPARATOR" , _TL("Separator"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("tabulator"), SG_T(";"), SG_T(","), _TL("space"), _TL("other") ), 0 ); Parameters.Add_String( pNode , "SEP_OTHER" , _TL("other"), _TL(""), SG_T("*") ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"), _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("CSV Files (*.csv)") , SG_T("*.csv"), _TL("All Files") , SG_T("*.*") ), NULL, true ); } //--------------------------------------------------------- bool CTable_Text_Export::On_Execute(void) { CSG_String StrFormat, Separator; CSG_File Stream; CSG_Table *pTable; //----------------------------------------------------- pTable = Parameters("TABLE" )->asTable(); StrFormat = Parameters("STRQUOTA")->asBool() ? SG_T("\"%s\"") : SG_T("%s"); switch( Parameters("SEPARATOR")->asInt() ) { case 0: Separator = "\t"; break; case 1: Separator = ";"; break; case 2: Separator = ","; break; case 3: Separator = " "; break; default: Separator = Parameters("SEP_OTHER")->asString(); break; } //----------------------------------------------------- if( !Stream.Open(Parameters("FILENAME")->asString(), SG_FILE_W, false) ) { Message_Add(_TL("file could not be opened.")); } //----------------------------------------------------- else { if( Parameters("HEADLINE")->asBool() ) { for(int iField=0; iFieldGet_Field_Count(); iField++) { Stream.Printf(StrFormat.c_str(), pTable->Get_Field_Name(iField)); Stream.Printf(iField < pTable->Get_Field_Count() - 1 ? Separator.c_str() : SG_T("\n")); } } //------------------------------------------------- for(int iRecord=0; iRecordGet_Record_Count() && Set_Progress(iRecord, pTable->Get_Record_Count()); iRecord++) { CSG_Table_Record *pRecord = pTable->Get_Record(iRecord); for(int iField=0; iFieldGet_Field_Count(); iField++) { switch( pTable->Get_Field_Type(iField) ) { default: case SG_DATATYPE_Char: case SG_DATATYPE_String: case SG_DATATYPE_Date: Stream.Printf(StrFormat.c_str(), pRecord->asString(iField)); break; case SG_DATATYPE_Short: case SG_DATATYPE_Int: case SG_DATATYPE_Color: Stream.Printf(SG_T("%d") , pRecord->asInt(iField)); break; case SG_DATATYPE_Long: Stream.Printf(SG_T("%ld") , (long)pRecord->asDouble(iField)); break; case SG_DATATYPE_ULong: Stream.Printf(SG_T("%lu") , (unsigned long)pRecord->asDouble(iField)); break; case SG_DATATYPE_Float: case SG_DATATYPE_Double: Stream.Printf(SG_T("%f") , pRecord->asDouble(iField)); break; } Stream.Printf(iField < pTable->Get_Field_Count() - 1 ? Separator.c_str() : SG_T("\n")); } } //------------------------------------------------- Stream.Close(); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Text_Import::CTable_Text_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import Text Table")); Set_Author ("O. Conrad (c) 2008"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "HEADLINE" , _TL("File contains headline"), _TL(""), PARAMETER_TYPE_Bool , true ); pNode = Parameters.Add_Choice( NULL , "SEPARATOR" , _TL("Separator"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|", _TL("tabulator"), SG_T(";"), SG_T(","), _TL("space"), _TL("other") ), 0 ); Parameters.Add_String( pNode , "SEP_OTHER" , _TL("Separator (other)"), _TL(""), SG_T("*") ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("File"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|%s", _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("CSV Files (*.csv)") , SG_T("*.csv"), _TL("All Files") , SG_T("*.*") ), NULL, false ); } //--------------------------------------------------------- int CTable_Text_Import::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "SEPARATOR") ) { pParameters->Set_Enabled("SEP_OTHER", pParameter->asInt() >= 4); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } //--------------------------------------------------------- bool CTable_Text_Import::On_Execute(void) { //----------------------------------------------------- CSG_Table *pTable = Parameters("TABLE")->asTable(); SG_Char Separator; switch( Parameters("SEPARATOR")->asInt() ) { case 0: Separator = '\t'; break; case 1: Separator = ';'; break; case 2: Separator = ','; break; case 3: Separator = ' '; break; default: Separator = *Parameters("SEP_OTHER")->asString(); break; } //----------------------------------------------------- if( !pTable->Create(Parameters("FILENAME")->asString(), Parameters("HEADLINE")->asBool() ? TABLE_FILETYPE_Text : TABLE_FILETYPE_Text_NoHeadLine, Separator) ) { Error_Set(_TL("table could not be opened.")); return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Text_Import_Numbers::CTable_Text_Import_Numbers(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import Text Table with Numbers only")); Set_Author ("O. Conrad (c) 2008"); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "SKIP" , _TL("Skip Lines"), _TL(""), PARAMETER_TYPE_Int, 0, 0, true ); Parameters.Add_Value( NULL , "HEADLINE" , _TL("Headline"), _TL(""), PARAMETER_TYPE_Bool, false ); pNode = Parameters.Add_Choice( NULL , "SEPARATOR" , _TL("Separator"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|", _TL("tabulator"), SG_T(";"), SG_T(","), _TL("space"), _TL("other") ), 0 ); Parameters.Add_String( pNode , "SEP_OTHER" , _TL("other"), _TL(""), SG_T("*") ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("File"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|%s", _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("CSV Files (*.csv)") , SG_T("*.csv"), _TL("All Files") , SG_T("*.*") ), NULL, false ); } //--------------------------------------------------------- int CTable_Text_Import_Numbers::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "SEPARATOR") ) { pParameters->Set_Enabled("SEP_OTHER", pParameter->asInt() >= 4); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } //--------------------------------------------------------- bool CTable_Text_Import_Numbers::On_Execute(void) { CSG_String sHead, sLine, Separator; CSG_File Stream; //----------------------------------------------------- if( !Stream.Open(Parameters("FILENAME")->asString(), SG_FILE_R, false) ) { Error_Set(_TL("file could not be opened")); return( false ); } if( Parameters("SKIP")->asInt() > 0 ) { int i = Parameters("SKIP")->asInt(); while( i > 0 && Stream.Read_Line(sLine) ) { i--; } } if( !Stream.Read_Line(sHead) || sHead.Length() == 0 ) { Error_Set(_TL("empty or corrupted file")); return( false ); } if( !Parameters("HEADLINE")->asBool() ) { sLine = sHead; } else if( !Stream.Read_Line(sLine) || sLine.Length() == 0 ) { Error_Set(_TL("empty or corrupted file")); return( false ); } //----------------------------------------------------- switch( Parameters("SEPARATOR")->asInt() ) { case 0: Separator = "\t"; break; case 1: Separator = ";"; break; case 2: Separator = ","; break; case 3: Separator = " "; break; default: Separator = Parameters("SEP_OTHER")->asString(); break; } //----------------------------------------------------- CSG_Table *pTable = Parameters("TABLE")->asTable(); pTable->Destroy(); pTable->Set_Name(SG_File_Get_Name(Parameters("FILENAME")->asString(), false)); sHead.Trim(true); sHead.Replace(Separator, "\t"); while( sHead.Length() > 0 ) { sHead.Trim(); if( Parameters("HEADLINE")->asBool() ) { pTable->Add_Field(sHead.BeforeFirst('\t'), SG_DATATYPE_Double); } else { pTable->Add_Field(CSG_String::Format("FIELD%02d", 1 + pTable->Get_Field_Count()), SG_DATATYPE_Double); } sHead = sHead.AfterFirst('\t'); } if( pTable->Get_Field_Count() <= 0 ) { Error_Set(_TL("empty or corrupted file")); return( false ); } //----------------------------------------------------- int fLength = Stream.Length(); bool bOkay = true; do { sLine.Replace(Separator, "\t"); CSG_Table_Record *pRecord = pTable->Add_Record(); for(int i=0; bOkay && iGet_Field_Count(); i++) { double Value; sLine.Trim(); if( (bOkay = sLine.asDouble(Value)) == true ) { pRecord->Set_Value(i, Value); sLine = sLine.AfterFirst('\t'); } else { pTable->Del_Record(pTable->Get_Count() - 1); } } } while( bOkay && Stream.Read_Line(sLine) && Set_Progress(Stream.Tell(), fLength) ); return( pTable->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CTable_Text_Import_Fixed_Cols::CTable_Text_Import_Fixed_Cols(void) { Set_Name (_TL("Import Text Table (Fixed Column Sizes)")); Set_Author (SG_T("O. Conrad (c) 2010")); Set_Description (_TW( "" )); //----------------------------------------------------- Parameters.Add_Table( NULL , "TABLE" , _TL("Table"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Value( NULL , "HEADLINE" , _TL("File contains headline"), _TL(""), PARAMETER_TYPE_Bool , true ); Parameters.Add_Choice( NULL , "FIELDDEF" , _TL("Field Definition"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("mark breaks in first line"), _TL("specify fields with type"), _TL("from list") ), 2 ); Parameters.Add_Value( NULL , "NFIELDS" , _TL("Number of Fields"), _TL(""), PARAMETER_TYPE_Int , 1, 1, true ); CSG_Table *pList = Parameters.Add_FixedTable( NULL , "LIST" , _TL("List"), _TL("") )->asTable(); pList->Add_Field(_TL("Name") , SG_DATATYPE_String); pList->Add_Field(_TL("Size") , SG_DATATYPE_Int); pList->Add_Field(_TL("Numeric") , SG_DATATYPE_Byte); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("All Files") , SG_T("*.*") ), NULL, false ); Add_Parameters("BREAKS", _TL("Breaks"), _TL("")); Add_Parameters("FIELDS", _TL("Fields"), _TL("")); } //--------------------------------------------------------- int CTable_Text_Import_Fixed_Cols::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), SG_T("FIELDDEF")) ) { // pParameters->Get_Parameter("BREAKS" )->Set_Enabled(pParameter->asInt() == 0); // pParameters->Get_Parameter("FIELDS" )->Set_Enabled(pParameter->asInt() == 1); pParameters->Get_Parameter("NFIELDS")->Set_Enabled(pParameter->asInt() == 1); pParameters->Get_Parameter("LIST" )->Set_Enabled(pParameter->asInt() == 2); } return( 1 ); } //--------------------------------------------------------- bool CTable_Text_Import_Fixed_Cols::On_Execute(void) { bool bHeader; int i, nChars, iField, nFields, *iFirst, *iLength; CSG_String sLine; CSG_File Stream; CSG_Table *pTable; //----------------------------------------------------- pTable = Parameters("TABLE") ->asTable(); bHeader = Parameters("HEADLINE") ->asBool(); //----------------------------------------------------- if( !Stream.Open(Parameters("FILENAME")->asString(), SG_FILE_R, true) ) { Message_Add(_TL("file could not be opened")); return( false ); } if( !Stream.Read_Line(sLine) || (nChars = (int)sLine.Length()) <= 0 ) { Message_Add(_TL("empty or corrupted file")); return( false ); } //----------------------------------------------------- pTable->Destroy(); pTable->Set_Name(SG_File_Get_Name(Parameters("FILENAME")->asString(), false)); switch( Parameters("FIELDDEF")->asInt() ) { //----------------------------------------------------- case 0: { CSG_Parameters *pBreaks = Get_Parameters("BREAKS"); pBreaks->Del_Parameters(); for(i=0; iAdd_Value(NULL, CSG_String::Format(SG_T("%03d"), i), CSG_String::Format(SG_T("%03d %c"), i + 1, sLine[i]), _TL(""), PARAMETER_TYPE_Bool, false ); } if( !Dlg_Parameters("BREAKS") ) { return( false ); } //------------------------------------------------- for(i=0, nFields=1; iGet_Count(); i++) { if( pBreaks->Get_Parameter(i)->asBool() ) { nFields++; } } //------------------------------------------------- iFirst = new int[nFields]; iLength = new int[nFields]; iFirst[0] = 0; for(i=0, iField=1; iGet_Count() && iFieldGet_Parameter(i)->asBool() ) { iFirst[iField++] = i + 1; } } //------------------------------------------------- for(iField=0; iFieldAdd_Field(bHeader ? sLine.Mid(iFirst[iField], iLength[iField]) : CSG_String::Format(SG_T("FIELD%03d"), iField + 1), SG_DATATYPE_String); } } break; //----------------------------------------------------- case 1: { CSG_Parameters *pFields = Get_Parameters("FIELDS"); pFields->Del_Parameters(); nFields = Parameters("NFIELDS")->asInt(); for(iField=0; iFieldAdd_Node(NULL, SG_T("NODE") + s, _TL("Field") + s, _TL("")); pFields->Add_Value (pNode, SG_T("LENGTH") + s, _TL("Length"), _TL(""), PARAMETER_TYPE_Int, 1, 1, true); // pFields->Add_Value (pNode, SG_T("IMPORT") + s, _TL("Import"), _TL(""), PARAMETER_TYPE_Bool, true); pFields->Add_Choice (pNode, SG_T("TYPE") + s, _TL("Type") , _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("text"), _TL("2 byte integer"), _TL("4 byte integer"), _TL("4 byte float"), _TL("8 byte float")) ); } if( !Dlg_Parameters("FIELDS") ) { return( false ); } //------------------------------------------------- iFirst = new int[nFields]; iLength = new int[nFields]; iFirst[0] = 0; for(iField=0, i=0; iFieldGet_Parameter(SG_T("LENGTH") + s)->asInt(); i += iLength[iField]; CSG_String Name = bHeader ? sLine.Mid(iFirst[iField], iLength[iField]) : CSG_String::Format(SG_T("FIELD%03d"), iField + 1); switch( pFields->Get_Parameter(SG_T("TYPE") + s)->asInt() ) { default: case 0: pTable->Add_Field(Name, SG_DATATYPE_String); break; case 1: pTable->Add_Field(Name, SG_DATATYPE_Short); break; case 2: pTable->Add_Field(Name, SG_DATATYPE_Int); break; case 3: pTable->Add_Field(Name, SG_DATATYPE_Float); break; case 4: pTable->Add_Field(Name, SG_DATATYPE_Double); break; } } } break; //----------------------------------------------------- case 2: { CSG_Table *pList = Parameters("LIST")->asTable(); nFields = pList->Get_Count(); //------------------------------------------------- iFirst = new int[nFields]; iLength = new int[nFields]; iFirst[0] = 0; for(iField=0, i=0; iFieldGet_Record(iField)->asInt(1); i += iLength[iField]; CSG_String Name = bHeader ? sLine.Mid(iFirst[iField], iLength[iField]) : CSG_String(pList->Get_Record(iField)->asString(0)); switch( pList->Get_Record(iField)->asInt(2) ) { case 0: pTable->Add_Field(Name, SG_DATATYPE_String); break; case 1: pTable->Add_Field(Name, SG_DATATYPE_Short); break; case 2: pTable->Add_Field(Name, SG_DATATYPE_Int); break; case 3: pTable->Add_Field(Name, SG_DATATYPE_Float); break; default: case 4: pTable->Add_Field(Name, SG_DATATYPE_Double); break; } } } break; } //----------------------------------------------------- if( bHeader ) { Stream.Read_Line(sLine); } //----------------------------------------------------- int fLength = Stream.Length(); do { if( sLine.Length() == nChars ) { CSG_Table_Record *pRecord = pTable->Add_Record(); for(iField=0; iFieldSet_Value(iField, sLine.Mid(iFirst[iField], iLength[iField])); } } } while( Stream.Read_Line(sLine) && Set_Progress(Stream.Tell(), fLength) ); //----------------------------------------------------- delete[](iFirst); delete[](iLength); //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_table/Makefile.in0000664000175000017500000005507312737447616022312 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/io/io_table ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_table_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libio_table_la_OBJECTS = io_table_txt.lo MLB_Interface.lo libio_table_la_OBJECTS = $(am_libio_table_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_table_la_SOURCES) DIST_SOURCES = $(libio_table_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_table.la libio_table_la_SOURCES = \ io_table_txt.cpp\ MLB_Interface.cpp\ io_table_txt.h\ MLB_Interface.h libio_table_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/io/io_table/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_table/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_table.la: $(libio_table_la_OBJECTS) $(libio_table_la_DEPENDENCIES) $(EXTRA_libio_table_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_table_la_OBJECTS) $(libio_table_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io_table_txt.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/io/io_table/Makefile.am0000744000175000017500000000110412737416175022256 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1277 2011-12-22 15:48:59Z reklov_w $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version pkglib_LTLIBRARIES = libio_table.la libio_table_la_SOURCES =\ io_table_txt.cpp\ MLB_Interface.cpp\ io_table_txt.h\ MLB_Interface.h libio_table_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) saga-2.3.1/src/modules/io/io_table/io_table_txt.h0000744000175000017500000001367512737416175023070 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: io_table_txt.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // table_io // // // //-------------------------------------------------------// // // // io_table_txt.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_table_txt_H #define HEADER_INCLUDED__io_table_txt_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Text_Export : public CSG_Module { public: CTable_Text_Export(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Text_Import : public CSG_Module { public: CTable_Text_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Import") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Text_Import_Numbers : public CSG_Module { public: CTable_Text_Import_Numbers(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Import") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CTable_Text_Import_Fixed_Cols : public CSG_Module { public: CTable_Text_Import_Fixed_Cols(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Import") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_table_txt_H saga-2.3.1/src/modules/io/io_table/MLB_Interface.h0000744000175000017500000000767312737416175023006 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_table // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_table_H #define HEADER_INCLUDED__io_table_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_table_EXPORTS #define io_table_EXPORT _SAGA_DLL_EXPORT #else #define io_table_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_table_H saga-2.3.1/src/modules/io/io_table/MLB_Interface.cpp0000744000175000017500000001137112737416175023327 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_table // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "MLB_Interface.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("Tables") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( SG_T("SAGA User Group Associaton (c) 2002-10") ); case MLB_INFO_Description: return( _TL("Tools for the import and export of tables.") ); case MLB_INFO_Version: return( SG_T("1.0") ); case MLB_INFO_Menu_Path: return( _TL("File|Tables") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "io_table_txt.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CTable_Text_Export ); case 1: return( new CTable_Text_Import ); case 2: return( new CTable_Text_Import_Numbers ); case 3: return( new CTable_Text_Import_Fixed_Cols ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/io/Makefile.am0000744000175000017500000000036312737416172020503 0ustar00oconradoconrad00000000000000if WITH_GUI SUBDIRS = io_esri_e00 io_gdal io_gps io_grid io_grid_image io_shapes io_shapes_dxf io_shapes_las io_table io_virtual else SUBDIRS = io_esri_e00 io_gdal io_gps io_grid io_shapes io_shapes_dxf io_shapes_las io_table io_virtual endif saga-2.3.1/src/modules/io/io_gdal/0000775000175000017500000000000012737740005020037 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/io/io_gdal/gdal_driver.h0000744000175000017500000002246712737416172022511 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_driver.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_driver.h // // // // Copyright (C) 2007 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_driver_H #define HEADER_INCLUDED__gdal_driver_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_gdal_EXPORT CSG_GDAL_Drivers { public: CSG_GDAL_Drivers(void); virtual ~CSG_GDAL_Drivers(void); CSG_String Get_Version (void) const; int Get_Count (void) const; class GDALDriver * Get_Driver (const CSG_String &Name) const; class GDALDriver * Get_Driver (int Index) const; CSG_String Get_Name (int Index) const; CSG_String Get_Description (int Index) const; CSG_String Get_Extension (int Index) const; bool is_Raster (int Index) const; bool Can_Read (int Index) const; bool Can_Write (int Index) const; static int Get_GDAL_Type (TSG_Data_Type Type); static TSG_Data_Type Get_SAGA_Type (int Type); private: class GDALDriverManager *m_pDrivers; }; //--------------------------------------------------------- io_gdal_EXPORT const CSG_GDAL_Drivers & SG_Get_GDAL_Drivers (void); /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SG_GDAL_IO_CLOSED 0x00 #define SG_GDAL_IO_READ 0x01 #define SG_GDAL_IO_WRITE 0x02 #define SG_GDAL_IO_READWRITE (SG_GDAL_IO_READ|IO_WRITE) //--------------------------------------------------------- class io_gdal_EXPORT CSG_GDAL_DataSet { public: CSG_GDAL_DataSet(void); CSG_GDAL_DataSet(const CSG_String &File_Name); virtual ~CSG_GDAL_DataSet(void); bool Open_Read (const CSG_String &File_Name); bool Open_Read (const CSG_String &File_Name, const CSG_Grid_System &System); bool Open_Write (const CSG_String &File_Name, const CSG_String &Driver, const CSG_String &Options, TSG_Data_Type Type, int NBands, const CSG_Grid_System &System, const CSG_Projection &Projection); bool Close (void); bool is_Okay (void) const { return( m_pDataSet != NULL ); } bool is_Reading (void) const { return( m_pDataSet != NULL && m_Access & SG_GDAL_IO_READ ); } bool is_Writing (void) const { return( m_pDataSet != NULL && m_Access & SG_GDAL_IO_WRITE ); } int Get_NX (void) const { return( m_NX ); } int Get_NY (void) const { return( m_NY ); } double Get_Cellsize (void) const { return( m_Cellsize ); } double Get_xMin (void) const { return( m_xMin ); } double Get_yMin (void) const { return( m_yMin ); } double Get_xMax (void) const { return( m_xMin + m_NX * m_Cellsize ); } double Get_yMax (void) const { return( m_yMin + m_NY * m_Cellsize ); } CSG_Rect Get_Extent (bool bTransform = true) const; CSG_Grid_System Get_System (void) const; bool Needs_Transformation(void) const { return( m_bTransform ); } void Get_Transformation (CSG_Vector &A, CSG_Matrix &B) const { A = m_TF_A; B = m_TF_B; } bool Get_Transformation (CSG_Grid_System &System, bool bVerbose) const; bool Get_Transformation (CSG_Grid **ppGrid, TSG_Grid_Resampling Interpolation, bool bVerbose) const; bool Get_Transformation (CSG_Grid **ppGrid, TSG_Grid_Resampling Interpolation, const CSG_Grid_System &System, bool bVerbose) const; class GDALDriver * Get_Driver (void) const; CSG_String Get_DriverID (void) const; CSG_String Get_Name (void) const; CSG_String Get_Description (void) const; CSG_String Get_File_Name (void) const; const char * Get_Projection (void) const; const char * Get_MetaData_Item (const char *pszName, const char *pszDomain = "") const; const char ** Get_MetaData (const char *pszDomain = "") const; bool Get_MetaData_Item (CSG_String &MetaData, const char *pszName, const char *pszDomain = "") const; bool Get_MetaData (CSG_MetaData &MetaData) const; bool Get_MetaData (CSG_MetaData &MetaData, const char *pszDomain) const; int Get_Count (void) const; CSG_String Get_Name (int i) const; CSG_String Get_Description (int i) const; bool Get_MetaData (int i, CSG_MetaData &MetaData) const; const char * Get_MetaData_Item (int i, const char *pszName) const; bool Get_MetaData_Item (int i, const char *pszName, CSG_String &MetaData) const; CSG_Grid * Read (int i); bool Write (int i, CSG_Grid *pGrid, double NoDataValue); bool Write (int i, CSG_Grid *pGrid); private: bool m_bTransform; int m_Access, m_NX, m_NY; double m_xMin, m_yMin, m_Cellsize; CSG_String m_File_Name; CSG_Vector m_TF_A; CSG_Matrix m_TF_B, m_TF_BInv; class GDALDataset *m_pDataSet, *m_pVrtSource; bool _Set_Transformation (void); public: bool to_World (double x, double y, double &xWorld, double &yWorld) { if( m_pDataSet ) { xWorld = m_TF_A[0] + x * m_TF_B[0][1] + y * m_TF_B[0][1]; yWorld = m_TF_A[1] + x * m_TF_B[1][0] + y * m_TF_B[1][1]; return( true ); } return( false ); } bool from_World (double xWorld, double yWorld, double &x, double &y) { if( m_pDataSet ) { xWorld -= m_TF_A[0]; yWorld -= m_TF_A[1]; x = xWorld * m_TF_BInv[0][0] + yWorld * m_TF_BInv[0][1]; y = xWorld * m_TF_BInv[1][0] + yWorld * m_TF_BInv[1][1]; return( true ); } return( false ); } }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- io_gdal_EXPORT TSG_Data_Type SG_Get_Grid_Type (CSG_Parameter_Grid_List *pGrids); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_driver_H saga-2.3.1/src/modules/io/io_gdal/gdal_catalogue.h0000744000175000017500000001237012737416172023152 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_catalogue.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_gdal // // // //-------------------------------------------------------// // // // gdal_catalogue.h // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_catalogue_H #define HEADER_INCLUDED__gdal_catalogue_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGDAL_Catalogue : public CSG_Module { public: CGDAL_Catalogue(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGDAL_Catalogues : public CSG_Module { public: CGDAL_Catalogues(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_String m_Directory; CSG_Strings m_Extensions; CSG_Parameter_Shapes_List *m_pCatalogues; CSG_Shapes * Get_Catalogue (const CSG_Projection &Projection, CSG_Shapes *pCatalogue, const CSG_String &Name); CSG_Shapes * Get_Catalogue (const CSG_Projection &Projection); int Add_Directory (const CSG_String &Directory); int Add_File (const CSG_String &File); bool Add_To_Geographic (CSG_Shapes *pCatalogue); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_catalogue_H saga-2.3.1/src/modules/io/io_gdal/ogr_driver.h0000744000175000017500000001732712737416172022370 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_driver.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_driver.h // // // // Copyright (C) 2008 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ogr_driver_H #define HEADER_INCLUDED__ogr_driver_H //--------------------------------------------------------- #include "MLB_Interface.h" #include #if defined(GDAL_VERSION_MAJOR) && GDAL_VERSION_MAJOR == 2 #define USE_GDAL_V2 #endif //--------------------------------------------------------- typedef enum ESG_Geom_Type_Choice_Key { AUTOMATIC = 0, WKBPOINT, WKBPOINT25D, WKBMULTIPOINT, WKBMULTIPOINT25D, WKBLINESTRING, WKBLINESTRING25D, WKBMULTILINESTRING, WKBMULTILINESTRING25D, WKBPOLYGON, WKBPOLYGON25D, WKBMULTIPOLYGON, WKBMULTIPOLYGON25D, WKBGEOMETRYCOLLECTION, WKBGEOMETRYCOLLECTION25D, GEOM_TYPE_KEY_Count } TSG_Geom_Type_Choice_Key; //--------------------------------------------------------- const SG_Char gSG_Geom_Type_Choice_Key_Name[GEOM_TYPE_KEY_Count][32] = { SG_T("automatic"), SG_T("wkbPoint"), SG_T("wkbPoint25D"), SG_T("wkbMultiPoint"), SG_T("wkbMultiPoint25D"), SG_T("wkbLineString"), SG_T("wkbLineString25D"), SG_T("wkbMultiLineString"), SG_T("wkbMultiLineString25D"), SG_T("wkbPolygon"), SG_T("wkbPolygon25D"), SG_T("wkbMultiPolygon"), SG_T("wkbMultiPolygon25D"), SG_T("wkbGeometryCollection"), SG_T("wkbGeometryCollection25D") }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSG_OGR_Drivers { public: CSG_OGR_Drivers(void); virtual ~CSG_OGR_Drivers(void); CSG_String Get_Version (void) const; int Get_Count (void) const; #ifdef USE_GDAL_V2 class GDALDriver * Get_Driver (const CSG_String &Name) const; class GDALDriver * Get_Driver (int Index) const; #else class OGRSFDriver * Get_Driver (const CSG_String &Name) const; class OGRSFDriver * Get_Driver (int Index) const; #endif CSG_String Get_Name (int Index) const; CSG_String Get_Description (int Index) const; CSG_String Get_Extension (int Index) const; bool is_Vector (int Index) const; bool Can_Read (int Index) const; bool Can_Write (int Index) const; static TSG_Vertex_Type Get_Vertex_Type (int Type); static TSG_Shape_Type Get_Shape_Type (int Type); static int Get_Shape_Type (TSG_Shape_Type Type, bool bZ); static TSG_Data_Type Get_Data_Type (int Type); static int Get_Data_Type (TSG_Data_Type Type); private: #ifdef USE_GDAL_V2 class GDALDriverManager *m_pDrivers; #else class OGRSFDriverRegistrar *m_pDrivers; #endif }; //--------------------------------------------------------- const CSG_OGR_Drivers & SG_Get_OGR_Drivers (void); /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSG_OGR_DataSet { public: CSG_OGR_DataSet(void); CSG_OGR_DataSet(const CSG_String &File); CSG_OGR_DataSet(const CSG_String &File, const CSG_String &DriverName); virtual ~CSG_OGR_DataSet(void); bool Create (const CSG_String &File); bool Create (const CSG_String &File, const CSG_String &DriverName); bool Destroy (void); CSG_String Get_DriverID (void) const; CSG_String Get_Description (void) const; CSG_String Get_Description (int iLayer) const; int Get_Count (void) const; class OGRLayer * Get_Layer (int iLayer) const; TSG_Shape_Type Get_Type (int iLayer) const; TSG_Vertex_Type Get_Coordinate_Type (int iLayer) const; CSG_Projection Get_Projection (int iLayer) const; CSG_Shapes * Read (int iLayer, int iGeomTypeChoice); bool Write (CSG_Shapes *pShapes); private: #ifdef USE_GDAL_V2 class GDALDataset *m_pDataSet; #else class OGRDataSource *m_pDataSet; #endif int _Get_GeomType_Choice(int iGeomTypeChoice); bool _Read_Geometry (CSG_Shape *pShape, class OGRGeometry *pGeometry); bool _Read_Line (CSG_Shape *pShape, class OGRLineString *pLine); bool _Read_Polygon (CSG_Shape *pShape, class OGRPolygon *pPolygon); bool _Write_Geometry (CSG_Shape *pShape, class OGRFeature *pFeature, bool bZ); bool _Write_Line (CSG_Shape *pShape, class OGRLineString *pLine, int iPart, bool bZ); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ogr_driver_H saga-2.3.1/src/modules/io/io_gdal/gdal_import_netcdf.h0000744000175000017500000001116012737416172024037 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_import_netcdf.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_import_netcdf.h // // // // Copyright (C) 2012 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_import_netcdf_H #define HEADER_INCLUDED__gdal_import_netcdf_H //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_gdal_EXPORT CGDAL_Import_NetCDF : public CSG_Module { public: CGDAL_Import_NetCDF(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid|Import") ); } protected: virtual bool On_Execute (void); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); private: bool m_bSaveFile; CSG_String m_SavePath; CSG_Parameter_Grid_List *m_pGrids; bool Load (CSG_GDAL_DataSet &DataSet, const CSG_String &Description); const char * Get_Variable (CSG_GDAL_DataSet &DataSet, int iBand); const char * Get_Time (CSG_GDAL_DataSet &DataSet, int iBand); const char * Get_Level (CSG_GDAL_DataSet &DataSet, int iBand); CSG_String Get_Time_String (const CSG_String &Time, int Format); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_import_netcdf_H saga-2.3.1/src/modules/io/io_gdal/ogr_export.cpp0000744000175000017500000001407012737416172022741 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_export.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_export.cpp // // // // Copyright (C) 2008 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ogr_export.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- COGR_Export::COGR_Export(void) { Set_Name (_TL("Export Shapes")); Set_Author ("O.Conrad (c) 2008"); CSG_String Description, Formats, Filter; Description = _TW( "The \"OGR Vector Data Export\" module exports vector data to various file formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format("\nGDAL %s:%s\n\n", _TL("Version"), SG_Get_OGR_Drivers().Get_Version().c_str()); Description += _TL("Following vector formats are currently supported:"); Description += CSG_String::Format("\n\n", _TL("ID"), _TL("Name"), _TL("Extension") ); Filter.Printf("%s|*.*", _TL("All Files")); for(int i=0; i"; Formats += "{" + ID + "}" + Name + "|"; if( !Ext.is_Empty() ) { Ext.Replace("/", ";"); Filter += "|" + Name + "|*." + Ext; } } } Description += "
    %s%s%s
    " + Name + "" + Ext + "
    "; Set_Description(Description); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), Filter, NULL, true ); Parameters.Add_Choice( NULL , "FORMAT" , _TL("Format"), _TL(""), Formats ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool COGR_Export::On_Execute(void) { CSG_OGR_DataSet DataSource; if( !DataSource.Create(Parameters("FILE")->asString(), Parameters("FORMAT")->asString()) ) { Error_Set(_TL("data set creation failed")); return( false ); } if( !DataSource.Write(Parameters("SHAPES")->asShapes()) ) { Error_Set(_TL("failed to write data")); return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/gdal_export_geotiff.cpp0000744000175000017500000001347112737416172024570 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_export_geotiff.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_export_geotiff.cpp // // // // Copyright (C) 2007 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_export_geotiff.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Export_GeoTIFF::CGDAL_Export_GeoTIFF(void) { Set_Name (_TL("Export GeoTIFF")); Set_Author ("O.Conrad (c) 2007"); Set_Description (_TW( "The \"GDAL GeoTIFF Export\" module exports one or more grids to a Geocoded Tagged Image File Format using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL, "GRIDS" , _TL("Grid(s)"), _TL("The SAGA grids to be exported."), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL, "FILE" , _TL("File"), _TL("The GeoTIFF File to be created."), CSG_String::Format( SG_T("%s|*.tif;*.tiff|%s|*.*"), _TL("TIFF files (*.tif)"), _TL("All Files") ), NULL, true ); Parameters.Add_String( NULL, "OPTIONS" , _TL("Creation Options"), _TL("A space separated list of key-value pairs (K=V)."), _TL("") ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Export_GeoTIFF::On_Execute(void) { CSG_String File_Name, Options; CSG_Projection Projection; CSG_Parameter_Grid_List *pGrids; CSG_GDAL_DataSet DataSet; //----------------------------------------------------- pGrids = Parameters("GRIDS") ->asGridList(); File_Name = Parameters("FILE") ->asString(); Options = Parameters("OPTIONS") ->asString(); Get_Projection(Projection); //----------------------------------------------------- if( !DataSet.Open_Write(File_Name, SG_T("GTiff"), Options, SG_Get_Grid_Type(pGrids), pGrids->Get_Count(), *Get_System(), Projection) ) { return( false ); } //----------------------------------------------------- for(int i=0; iGet_Count(); i++) { Process_Set_Text(CSG_String::Format(SG_T("%s %d"), _TL("Band"), i + 1)); DataSet.Write(i, pGrids->asGrid(i)); } if( !DataSet.Close() ) { return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/gdal_import.h0000744000175000017500000001077512737416172022527 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_import.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_import.h // // // // Copyright (C) 2007 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_import_H #define HEADER_INCLUDED__gdal_import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGDAL_Import : public CSG_Module { public: CGDAL_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid|Import") ); } protected: virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: CSG_Parameter_Grid_List *m_pGrids; static int On_Selection_Changed (CSG_Parameter *pParameter, int Flags); bool Load (const CSG_String &File); bool Load_Subset (CSG_GDAL_DataSet &DataSet); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_import_H saga-2.3.1/src/modules/io/io_gdal/gdal_import_wms.h0000744000175000017500000001103312737416172023401 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_import_wms.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_import_wms.h // // // // Copyright (C) 2016 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_import_wms_H #define HEADER_INCLUDED__gdal_import_wms_H //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGDAL_Import_WMS : public CSG_Module { public: CGDAL_Import_WMS(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid|Import") ); } protected: virtual int On_Parameter_Changed (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual int On_Parameters_Enable (CSG_Parameters *pParameters, CSG_Parameter *pParameter); virtual bool On_Execute (void); private: bool Set_Image (CSG_Grid *pBands[3]); bool Get_Projected (CSG_Grid *pBands[3], CSG_Grid *pTarget); bool Get_Bands (CSG_Grid *pBands[3], const CSG_Grid_System &System); CSG_String Get_Request (void); bool Get_System (CSG_Grid_System &System, CSG_Grid *pTarget); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_import_wms_H saga-2.3.1/src/modules/io/io_gdal/gdal_import.cpp0000744000175000017500000003541012737416172023053 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_import.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_import.cpp // // // // Copyright (C) 2007 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_import.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Import::CGDAL_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import Raster")); Set_Author ("O.Conrad (c) 2007 (A.Ringeler)"); CSG_String Description, Filter, Filter_All; Description = _TW( "The \"GDAL Raster Import\" module imports grid data from various file formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format("\nGDAL %s:%s\n\n", _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str()); Description += _TL("Following raster formats are currently supported:"); Description += CSG_String::Format("\n", _TL("ID"), _TL("Name"), _TL("Extension") ); for(int i=0; i"; if( !Ext.is_Empty() ) { Ext.Replace("/", ";"); Filter += Name + "|*." + Ext + "|"; Filter_All += (Filter_All.is_Empty() ? "*." : ";*.") + Ext; } } } Description += "
    %s%s%s
    " + Name + "" + Ext + "
    "; Set_Description(Description); Filter.Prepend(CSG_String::Format("%s|%s|" , _TL("All Recognized Files"), Filter_All.c_str())); Filter.Append (CSG_String::Format("%s|*.*" , _TL("All Files"))); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT, false ); Parameters.Add_FilePath( NULL , "FILES" , _TL("Files"), _TL(""), Filter, NULL, false, false, true ); //----------------------------------------------------- Parameters.Add_String( NULL , "SELECTION" , _TL("Select from Multiple Bands"), _TL("Semicolon separated list of band indexes. Do not set to select all bands for import."), "" )->Set_UseInGUI(false); Parameters.Add_Bool( NULL , "SELECT" , _TL("Select from Multiple Bands"), _TL(""), true )->Set_UseInCMD(false); pNode = SG_UI_Get_Window_Main() ? Parameters("SELECT") : NULL; Parameters.Add_Bool( pNode , "SELECT_SORT" , _TL("Alphanumeric Sorting"), _TL(""), true ); //----------------------------------------------------- pNode = Parameters.Add_Bool( NULL , "TRANSFORM" , _TL("Transformation"), _TL("align grid to coordinate system"), true ); Parameters.Add_Choice( NULL , "RESAMPLING" , _TL("Resampling"), _TL("interpolation method to use if grid needs to be aligned to coordinate system"), CSG_String::Format("%s|%s|%s|%s|", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 3 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGDAL_Import::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TRANSFORM") ) { pParameters->Set_Enabled("RESAMPLING" , pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "SELECT") ) { pParameters->Set_Enabled("SELECT_SORT", pParameter->asBool()); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } //--------------------------------------------------------- int CGDAL_Import::On_Selection_Changed(CSG_Parameter *pParameter, int Flags) { if( pParameter && pParameter->Get_Owner() && pParameter->Get_Owner()->Get_Owner() ) { if( Flags & PARAMETER_CHECK_ENABLE ) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "ALL") ) { pParameter->Get_Owner()->Set_Enabled("BANDS", pParameter->asBool() == false); } } return( 1 ); } return( 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import::On_Execute(void) { CSG_Strings Files; if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) ) { return( false ); } //----------------------------------------------------- (m_pGrids = Parameters("GRIDS")->asGridList())->Del_Items(); for(int i=0; iGet_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import::Load(const CSG_String &File) { //----------------------------------------------------- CSG_GDAL_DataSet DataSet; if( DataSet.Open_Read(File) == false ) { return( false ); } //----------------------------------------------------- if( DataSet.Get_Count() < 1 ) { return( Load_Subset(DataSet) ); } //----------------------------------------------------- CSG_Table Bands; Bands.Add_Field("NAME", SG_DATATYPE_String); { for(int i=0; iSet_Value(0, DataSet.Get_Name(i)); } } if( Parameters("SELECT_SORT")->asBool() ) { Bands.Set_Index(0, TABLE_INDEX_Ascending); } //----------------------------------------------------- if( DataSet.Get_Count() > 1 ) { if( !SG_UI_Get_Window_Main() ) { CSG_String_Tokenizer Indexes(Parameters("SELECTION")->asString(), ";,"); while( Indexes.Has_More_Tokens() ) { int i; if( Indexes.Get_Next_Token().asInt(i) && i >= 0 && i < Bands.Get_Count() ) { Bands.Select(Bands[i].Get_Index(), true); } } } else if( Parameters("SELECT")->asBool() ) { CSG_Parameters Selection(this, _TL("Select from Multiple Bands"), _TL(""), SG_T("SELECTION")); Selection.Set_Callback_On_Parameter_Changed(&On_Selection_Changed); Selection.Add_Bool(NULL, "ALL" , _TL("Load all bands"), _TL(""), false); Selection.Add_Node(NULL, "BANDS", _TL("Bands" ), _TL("")); for(int i=0; iasBool() || Selection(i + 2)->asBool() ) { Bands.Select(Bands[i].Get_Index(), true); } } } if( Bands.Get_Selection_Count() <= 0 ) { return( false ); } } } //----------------------------------------------------- TSG_Grid_Resampling Resampling; switch( Parameters("RESAMPLING")->asInt() ) { default: Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: Resampling = GRID_RESAMPLING_Bilinear; break; case 2: Resampling = GRID_RESAMPLING_BicubicSpline; break; case 3: Resampling = GRID_RESAMPLING_BSpline; break; } CSG_Vector A; CSG_Matrix B; DataSet.Get_Transformation(A, B); bool bTransform = Parameters("TRANSFORM")->asBool() && DataSet.Needs_Transformation(); //----------------------------------------------------- Message_Add("\n", false); Message_Add(CSG_String::Format("\n%s: %s", _TL("Driver" ), DataSet.Get_DriverID().c_str()), false); Message_Add(CSG_String::Format("\n%s: %d", _TL("Bands" ), DataSet.Get_Count () ), false); Message_Add(CSG_String::Format("\n%s: %d", _TL("Rows" ), DataSet.Get_NX () ), false); Message_Add(CSG_String::Format("\n%s: %d", _TL("Columns"), DataSet.Get_NY () ), false); Message_Add("\n", false); if( DataSet.Needs_Transformation() ) { Message_Add(CSG_String::Format("\n%s:", _TL("Transformation") ), false); Message_Add(CSG_String::Format("\n x' = %.6f + x * %.6f + y * %.6f", A[0], B[0][0], B[0][1]), false); Message_Add(CSG_String::Format("\n y' = %.6f + x * %.6f + y * %.6f", A[1], B[1][0], B[1][1]), false); Message_Add("\n", false); } //----------------------------------------------------- for(int i=0; i 1 ) Message += CSG_String::Format(" [%d/%d]", i + 1, DataSet.Get_Count()); Process_Set_Text(CSG_String::Format(Message.c_str(), _TL("loading"))); CSG_Grid *pGrid = DataSet.Read(Bands[i].Get_Index()); if( pGrid != NULL ) { if( bTransform ) { Process_Set_Text(CSG_String::Format(Message.c_str(), _TL("translation"))); DataSet.Get_Transformation(&pGrid, Resampling, true); } pGrid->Get_MetaData().Add_Child("GDAL_DRIVER", DataSet.Get_DriverID()); pGrid->Set_File_Name(DataSet.Get_File_Name()); pGrid->Set_Name(SG_File_Get_Name(File, false) + (DataSet.Get_Count() == 1 ? CSG_String("") : CSG_String::Format(" [%s]", Bands[i].asString(0)))); pGrid->Set_Description(DataSet.Get_Description(Bands[i].Get_Index())); m_pGrids->Add_Item(pGrid); DataObject_Add (pGrid); DataObject_Set_Colors(pGrid, CSG_Colors(11, SG_COLORS_RAINBOW, false)); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import::Load_Subset(CSG_GDAL_DataSet &DataSet) { CSG_MetaData MetaData; if( !DataSet.Get_MetaData(MetaData, "SUBDATASETS") ) { return( false ); } //----------------------------------------------------- int i; CSG_Parameters Subsets; for(i=0; ; i++) { CSG_String ID = CSG_String::Format("SUBDATASET_%d_", i + 1); if( MetaData(ID + "NAME") ) { Subsets.Add_Bool(NULL, MetaData.Get_Content(ID + "NAME"), MetaData.Get_Content(ID + "DESC"), "", SG_UI_Get_Window_Main() == NULL ); } else { break; } } //----------------------------------------------------- if( SG_UI_Get_Window_Main() && !Dlg_Parameters(&Subsets, _TL("Select from Subdatasets...")) ) // with gui { return( false ); } //----------------------------------------------------- for(i=0; iasBool() ) { if( Load(Subsets(i)->Get_Identifier()) == false ) { Error_Fmt("%s: %s", _TL("failed to import subset"), Subsets(i)->Get_Name()); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/ogr_export_kml.h0000744000175000017500000001001712737416172023246 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_export_kml.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_export_kml.h // // // // Copyright (C) 2012 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ogr_export_kml_H #define HEADER_INCLUDED__ogr_export_kml_H //--------------------------------------------------------- #include "ogr_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class COGR_Export_KML : public CSG_Module { public: COGR_Export_KML(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Shapes|Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ogr_export_kml_H saga-2.3.1/src/modules/io/io_gdal/ogr_import.h0000744000175000017500000001040312737416172022373 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_import.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_import.h // // // // Copyright (C) 2008 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ogr_import_H #define HEADER_INCLUDED__ogr_import_H //--------------------------------------------------------- #include "ogr_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class COGR_Import : public CSG_Module { public: COGR_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Shapes|Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- io_gdal_EXPORT bool SG_OGR_Import (const CSG_String &File_Name); /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ogr_import_H saga-2.3.1/src/modules/io/io_gdal/ogr_driver.cpp0000744000175000017500000007176512737416172022731 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_driver.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_driver.cpp // // // // Copyright (C) 2008 by O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ogr_driver.h" #include #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_OGR_Drivers gSG_OGR_Drivers; const CSG_OGR_Drivers & SG_Get_OGR_Drivers (void) { return( gSG_OGR_Drivers ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifdef USE_GDAL_V2 CSG_OGR_Drivers::CSG_OGR_Drivers(void) { GDALAllRegister(); m_pDrivers = GetGDALDriverManager(); } #else CSG_OGR_Drivers::CSG_OGR_Drivers(void) { OGRRegisterAll(); m_pDrivers = OGRSFDriverRegistrar::GetRegistrar(); } #endif //--------------------------------------------------------- CSG_OGR_Drivers::~CSG_OGR_Drivers(void) { // OGRCleanupAll(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Version(void) const { return( GDALVersionInfo("RELEASE_NAME") ); } //--------------------------------------------------------- int CSG_OGR_Drivers::Get_Count(void) const { return( m_pDrivers->GetDriverCount() ); } #ifdef USE_GDAL_V2 //--------------------------------------------------------- GDALDriver * CSG_OGR_Drivers::Get_Driver(int Index) const { return( m_pDrivers->GetDriver(Index) ); } GDALDriver * CSG_OGR_Drivers::Get_Driver(const CSG_String &Name) const { return( m_pDrivers ? m_pDrivers->GetDriverByName(Name) : NULL ); } //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Name(int Index) const { return( m_pDrivers->GetDriver(Index)->GetMetadataItem(GDAL_DMD_LONGNAME) ); } //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Description(int Index) const { return( m_pDrivers->GetDriver(Index)->GetDescription() ); } //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Extension(int Index) const { return( Get_Driver(Index)->GetMetadataItem(GDAL_DMD_EXTENSION) ); } //--------------------------------------------------------- bool CSG_OGR_Drivers::is_Vector(int Index) const { return( Get_Driver(Index) && CSLFetchBoolean(Get_Driver(Index)->GetMetadata(), GDAL_DCAP_VECTOR, false) ); } //--------------------------------------------------------- bool CSG_OGR_Drivers::Can_Read(int Index) const { return( Get_Driver(Index) != NULL ); } //--------------------------------------------------------- bool CSG_OGR_Drivers::Can_Write(int Index) const { return( Get_Driver(Index) && CSLFetchBoolean(Get_Driver(Index)->GetMetadata(), GDAL_DCAP_CREATE, false) ); } #else //--------------------------------------------------------- OGRSFDriver * CSG_OGR_Drivers::Get_Driver(int Index) const { return( m_pDrivers->GetDriver(Index) ); } OGRSFDriver * CSG_OGR_Drivers::Get_Driver(const CSG_String &Name) const { return( m_pDrivers ? m_pDrivers->GetDriverByName(Name) : NULL ); } //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Name(int Index) const { return( m_pDrivers->GetDriver(Index)->GetName() ); } //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Description(int Index) const { OGRSFDriver *pDriver = m_pDrivers->GetDriver(Index); CSG_String s; s += pDriver->TestCapability(ODrCCreateDataSource) ? SG_T("\n[x] ") : SG_T("\n[ ] "); s += _TL("create data source"); s += pDriver->TestCapability(ODrCDeleteDataSource) ? SG_T("\n[x] ") : SG_T("\n[ ] "); s += _TL("delete data source"); /* s += pDriver->TestCapability(ODsCCreateLayer) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("create layer"); s += pDriver->TestCapability(ODsCDeleteLayer) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("delete layer"); s += pDriver->TestCapability(OLCDeleteFeature) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("delete feature"); s += pDriver->TestCapability(OLCRandomRead) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("random read"); s += pDriver->TestCapability(OLCRandomWrite) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("random write"); s += pDriver->TestCapability(OLCSequentialWrite) ? SG_T("\n[x]") : SG_T("\n[ ]"); s += _TL("sequential write"); /**/ return( s ); } //--------------------------------------------------------- CSG_String CSG_OGR_Drivers::Get_Extension(int Index) const { return( "" ); } //--------------------------------------------------------- bool CSG_OGR_Drivers::is_Vector(int Index) const { return( true ); } //--------------------------------------------------------- bool CSG_OGR_Drivers::Can_Read(int Index) const { return( Get_Driver(Index) != NULL ); } //--------------------------------------------------------- bool CSG_OGR_Drivers::Can_Write(int Index) const { return( Get_Driver(Index) ); } #endif // #ifndef USE_GDAL_V2 /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- TSG_Vertex_Type CSG_OGR_Drivers::Get_Vertex_Type(int Type) { switch( Type ) { case wkbPoint25D: // 2.5D extension as per 99-402 case wkbMultiPoint25D: // 2.5D extension as per 99-402 case wkbLineString25D: // 2.5D extension as per 99-402 case wkbMultiLineString25D: // 2.5D extension as per 99-402 case wkbPolygon25D: // 2.5D extension as per 99-402 case wkbMultiPolygon25D: // 2.5D extension as per 99-402 case wkbGeometryCollection25D: // 2.5D extension as per 99-402 return( SG_VERTEX_TYPE_XYZ ); default: return( SG_VERTEX_TYPE_XY ); } } //--------------------------------------------------------- TSG_Shape_Type CSG_OGR_Drivers::Get_Shape_Type(int Type) { switch( Type ) { case wkbPoint: // 0-dimensional geometric object, standard WKB case wkbPoint25D: // 2.5D extension as per 99-402 return( SHAPE_TYPE_Point ); case wkbMultiPoint: // GeometryCollection of Points, standard WKB case wkbMultiPoint25D: // 2.5D extension as per 99-402 return( SHAPE_TYPE_Points ); case wkbLineString: // 1-dimensional geometric object with linear interpolation between Points, standard WKB case wkbMultiLineString: // GeometryCollection of LineStrings, standard WKB case wkbLineString25D: // 2.5D extension as per 99-402 case wkbMultiLineString25D: // 2.5D extension as per 99-402 return( SHAPE_TYPE_Line ); case wkbPolygon: // planar 2-dimensional geometric object defined by 1 exterior boundary and 0 or more interior boundaries, standard WKB case wkbMultiPolygon: // GeometryCollection of Polygons, standard WKB case wkbPolygon25D: // 2.5D extension as per 99-402 case wkbMultiPolygon25D: // 2.5D extension as per 99-402 return( SHAPE_TYPE_Polygon ); default: case wkbUnknown: // unknown type, non-standard case wkbNone: // non-standard, for pure attribute records case wkbLinearRing: // non-standard, just for createGeometry() case wkbGeometryCollection: // geometric object that is a collection of 1 or more geometric objects, standard WKB case wkbGeometryCollection25D: // 2.5D extension as per 99-402 return( SHAPE_TYPE_Undefined ); } } //--------------------------------------------------------- int CSG_OGR_Drivers::Get_Shape_Type(TSG_Shape_Type Type, bool bZ) { switch( Type ) { case SHAPE_TYPE_Point: return( bZ ? wkbPoint25D : wkbPoint ); // point case SHAPE_TYPE_Points: return( bZ ? wkbMultiPoint25D : wkbMultiPoint ); // points case SHAPE_TYPE_Line: return( bZ ? wkbMultiLineString25D : wkbMultiLineString ); // line case SHAPE_TYPE_Polygon: return( bZ ? wkbMultiPolygon25D : wkbMultiPolygon ); // polygon default: return( wkbUnknown ); } } //--------------------------------------------------------- TSG_Data_Type CSG_OGR_Drivers::Get_Data_Type(int Type) { switch( Type ) { case OFTInteger: // Simple 32bit integer return( SG_DATATYPE_Int ); case OFTReal: // Double Precision floating point return( SG_DATATYPE_Double ); case OFTString: // String of ASCII chars return( SG_DATATYPE_String ); case OFTDateTime: // Date and Time return( SG_DATATYPE_Date ); default: case OFTIntegerList: // List of 32bit integers case OFTRealList: // List of doubles case OFTStringList: // Array of strings case OFTWideString: // deprecated case OFTWideStringList: // deprecated case OFTBinary: // Raw Binary data case OFTDate: // Date case OFTTime: // Time return( SG_DATATYPE_String ); } } //--------------------------------------------------------- int CSG_OGR_Drivers::Get_Data_Type(TSG_Data_Type Type) { switch( Type ) { default: case SG_DATATYPE_String: case SG_DATATYPE_Date: return( OFTString ); case SG_DATATYPE_Byte: case SG_DATATYPE_Char: case SG_DATATYPE_Word: case SG_DATATYPE_Short: case SG_DATATYPE_DWord: case SG_DATATYPE_Int: case SG_DATATYPE_ULong: case SG_DATATYPE_Long: case SG_DATATYPE_Color: return( OFTInteger ); case SG_DATATYPE_Float: case SG_DATATYPE_Double: return( OFTReal ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_OGR_DataSet::CSG_OGR_DataSet(void) { m_pDataSet = NULL; } CSG_OGR_DataSet::CSG_OGR_DataSet(const CSG_String &File) { m_pDataSet = NULL; Create(File); } //--------------------------------------------------------- CSG_OGR_DataSet::~CSG_OGR_DataSet(void) { Destroy(); } #ifdef USE_GDAL_V2 //--------------------------------------------------------- bool CSG_OGR_DataSet::Create(const CSG_String &File) { Destroy(); m_pDataSet = (GDALDataset *)GDALOpenEx(File, GDAL_OF_VECTOR, NULL, NULL, NULL); return( m_pDataSet != NULL ); } bool CSG_OGR_DataSet::Create(const CSG_String &File, const CSG_String &DriverName) { GDALDriver *pDriver; Destroy(); if( (pDriver = gSG_OGR_Drivers.Get_Driver(DriverName)) != NULL ) { m_pDataSet = pDriver->Create(File, 0, 0, 0, GDT_Unknown, NULL); } return( m_pDataSet != NULL ); } //--------------------------------------------------------- bool CSG_OGR_DataSet::Destroy(void) { if( m_pDataSet ) { GDALClose(m_pDataSet); m_pDataSet = NULL; } return( true ); } //--------------------------------------------------------- CSG_String CSG_OGR_DataSet::Get_DriverID(void) const { return( m_pDataSet && m_pDataSet->GetDriver() && m_pDataSet->GetDriver()->GetDescription() ? m_pDataSet->GetDriver()->GetDescription() : "" ); } //--------------------------------------------------------- CSG_String CSG_OGR_DataSet::Get_Description(void) const { return( m_pDataSet ? m_pDataSet->GetDescription() : "" ); } //--------------------------------------------------------- CSG_String CSG_OGR_DataSet::Get_Description(int i) const { CSG_String Description; OGRLayer *pLayer = Get_Layer(i); if( pLayer != NULL ) { char **pMetaData = pLayer->GetMetadata() + 0; if( pMetaData ) { while( *pMetaData ) { CSG_String s(*pMetaData); Description += s + "\n"; pMetaData++; } } } return( Description ); } #else //--------------------------------------------------------- bool CSG_OGR_DataSet::Create(const CSG_String &File) { Destroy(); m_pDataSet = OGRSFDriverRegistrar::Open(File); return( m_pDataSet != NULL ); } bool CSG_OGR_DataSet::Create(const CSG_String &File, const CSG_String &DriverName) { OGRSFDriver *pDriver; Destroy(); if( (pDriver = gSG_OGR_Drivers.Get_Driver(DriverName)) != NULL ) { m_pDataSet = pDriver->CreateDataSource(File, NULL); } return( m_pDataSet != NULL ); } //--------------------------------------------------------- bool CSG_OGR_DataSet::Destroy(void) { if( m_pDataSet ) { OGRDataSource::DestroyDataSource(m_pDataSet); m_pDataSet = NULL; } return( true ); } //--------------------------------------------------------- CSG_String CSG_OGR_DataSet::Get_DriverID (void) const { return( "" ); } CSG_String CSG_OGR_DataSet::Get_Description(void) const { return( "" ); } CSG_String CSG_OGR_DataSet::Get_Description(int i) const { return( "" ); } #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSG_OGR_DataSet::Get_Count(void) const { if( m_pDataSet ) { return( m_pDataSet->GetLayerCount() ); } return( 0 ); } //--------------------------------------------------------- OGRLayer * CSG_OGR_DataSet::Get_Layer(int iLayer) const { if( m_pDataSet && iLayer >= 0 && iLayer < m_pDataSet->GetLayerCount() ) { return( m_pDataSet->GetLayer(iLayer) ); } return( NULL ); } //--------------------------------------------------------- TSG_Shape_Type CSG_OGR_DataSet::Get_Type(int iLayer) const { if( Get_Layer(iLayer) ) { return( CSG_OGR_Drivers::Get_Shape_Type(Get_Layer(iLayer)->GetLayerDefn()->GetGeomType()) ); } return( SHAPE_TYPE_Undefined ); } //--------------------------------------------------------- TSG_Vertex_Type CSG_OGR_DataSet::Get_Coordinate_Type(int iLayer) const { if( Get_Layer(iLayer) ) { return( CSG_OGR_Drivers::Get_Vertex_Type(Get_Layer(iLayer)->GetLayerDefn()->GetGeomType()) ); } return( SG_VERTEX_TYPE_XY ); } //--------------------------------------------------------- CSG_Projection CSG_OGR_DataSet::Get_Projection(int iLayer) const { CSG_Projection Projection; if( Get_Layer(iLayer) && Get_Layer(iLayer)->GetSpatialRef() ) { char *p = NULL; //------------------------------------------------- if( !Projection.is_Okay() && Get_Layer(iLayer)->GetSpatialRef()->exportToWkt (&p) == OGRERR_NONE && p && *p ) { Projection.Create(p, SG_PROJ_FMT_WKT); } if( p ) { OGRFree(p); p = NULL; } //------------------------------------------------- if( !Projection.is_Okay() && Get_Layer(iLayer)->GetSpatialRef()->exportToProj4(&p) == OGRERR_NONE && p && *p ) { Projection.Create(p, SG_PROJ_FMT_Proj4); } if( p ) { OGRFree(p); p = NULL; } } return( Projection ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shapes * CSG_OGR_DataSet::Read(int iLayer, int iGeomTypeChoice) { //----------------------------------------------------- OGRLayer *pLayer = Get_Layer(iLayer); if( !pLayer ) { return( NULL ); } if( iGeomTypeChoice != 0 ) { pLayer->GetLayerDefn()->SetGeomType((OGRwkbGeometryType)_Get_GeomType_Choice(iGeomTypeChoice)); } if( Get_Type(iLayer) == SHAPE_TYPE_Undefined ) { return( NULL ); } //----------------------------------------------------- OGRFeatureDefn *pDef = pLayer->GetLayerDefn(); CSG_Shapes *pShapes = SG_Create_Shapes(Get_Type(iLayer), CSG_String(pDef->GetName()), NULL, Get_Coordinate_Type(iLayer)); pShapes->Get_Projection() = Get_Projection(iLayer); //----------------------------------------------------- int iField; for(iField=0; iFieldGetFieldCount(); iField++) { OGRFieldDefn *pDefField = pDef->GetFieldDefn(iField); pShapes->Add_Field(pDefField->GetNameRef(), CSG_OGR_Drivers::Get_Data_Type(pDefField->GetType())); } //----------------------------------------------------- OGRFeature *pFeature; pLayer->ResetReading(); while( (pFeature = pLayer->GetNextFeature()) != NULL && SG_UI_Process_Get_Okay(false) ) { OGRGeometry *pGeometry = pFeature->GetGeometryRef(); if( pGeometry != NULL ) { CSG_Shape *pShape = pShapes->Add_Shape(); for(iField=0; iFieldGetFieldCount(); iField++) { OGRFieldDefn *pDefField = pDef->GetFieldDefn(iField); switch( pDefField->GetType() ) { default: pShape->Set_Value(iField, pFeature->GetFieldAsString (iField)); break; case OFTString: pShape->Set_Value(iField, pFeature->GetFieldAsString (iField)); break; case OFTInteger: pShape->Set_Value(iField, pFeature->GetFieldAsInteger(iField)); break; case OFTReal: pShape->Set_Value(iField, pFeature->GetFieldAsDouble (iField)); break; } } //--------------------------------------------- if( _Read_Geometry(pShape, pGeometry) == false ) { pShapes->Del_Shape(pShape); } } OGRFeature::DestroyFeature(pFeature); } return( pShapes ); } //--------------------------------------------------------- int CSG_OGR_DataSet::_Get_GeomType_Choice(int iGeomTypeChoice) { switch( iGeomTypeChoice ) { default: case AUTOMATIC: return( wkbUnknown ); case WKBPOINT: return( wkbPoint ); case WKBPOINT25D: return( wkbPoint25D ); case WKBMULTIPOINT: return( wkbMultiPoint ); case WKBMULTIPOINT25D: return( wkbMultiPoint25D ); case WKBLINESTRING: return( wkbLineString ); case WKBLINESTRING25D: return( wkbLineString25D ); case WKBMULTILINESTRING: return( wkbMultiLineString ); case WKBMULTILINESTRING25D: return( wkbMultiLineString25D ); case WKBPOLYGON: return( wkbPolygon ); case WKBPOLYGON25D: return( wkbPolygon25D ); case WKBMULTIPOLYGON: return( wkbMultiPolygon ); case WKBMULTIPOLYGON25D: return( wkbMultiPolygon25D ); case WKBGEOMETRYCOLLECTION: return( wkbGeometryCollection ); case WKBGEOMETRYCOLLECTION25D: return( wkbGeometryCollection25D ); } } //--------------------------------------------------------- bool CSG_OGR_DataSet::_Read_Geometry(CSG_Shape *pShape, OGRGeometry *pGeometry) { if( pShape && pGeometry ) { switch( pGeometry->getGeometryType() ) { //------------------------------------------------- case wkbPoint: // 0-dimensional geometric object, standard WKB case wkbPoint25D: // 2.5D extension as per 99-402 pShape->Add_Point(((OGRPoint *)pGeometry)->getX(), ((OGRPoint *)pGeometry)->getY()); pShape->Set_Z(((OGRPoint *)pGeometry)->getZ(), 0); return( true ); //------------------------------------------------- case wkbLineString: // 1-dimensional geometric object with linear interpolation between Points, standard WKB case wkbLineString25D: // 2.5D extension as per 99-402 return( _Read_Line(pShape, (OGRLineString *)pGeometry) ); //------------------------------------------------- case wkbPolygon: // planar 2-dimensional geometric object defined by 1 exterior boundary and 0 or more interior boundaries, standard WKB case wkbPolygon25D: // 2.5D extension as per 99-402 return( _Read_Polygon(pShape, (OGRPolygon *)pGeometry) ); //------------------------------------------------- case wkbMultiPoint: // GeometryCollection of Points, standard WKB case wkbMultiPoint25D: // 2.5D extension as per 99-402 case wkbMultiLineString: // GeometryCollection of LineStrings, standard WKB case wkbMultiLineString25D: // 2.5D extension as per 99-402 case wkbMultiPolygon: // GeometryCollection of Polygons, standard WKB case wkbMultiPolygon25D: // 2.5D extension as per 99-402 { for(int i=0; i<((OGRGeometryCollection *)pGeometry)->getNumGeometries(); i++) { if( _Read_Geometry(pShape, ((OGRGeometryCollection *)pGeometry)->getGeometryRef(i)) == false ) { return( false ); } } } return( true ); //------------------------------------------------- default: break; } } return( false ); } //--------------------------------------------------------- bool CSG_OGR_DataSet::_Read_Line(CSG_Shape *pShape, OGRLineString *pLine) { if( pShape && pLine && pLine->getNumPoints() > 0 ) { int iPart = pShape->Get_Part_Count(); for(int iPoint=0; iPointgetNumPoints(); iPoint++) { pShape->Add_Point(pLine->getX(iPoint), pLine->getY(iPoint), iPart); pShape->Set_Z(pLine->getZ(iPoint), iPoint, iPart); } return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_OGR_DataSet::_Read_Polygon(CSG_Shape *pShape, OGRPolygon *pPolygon) { if( pShape && pPolygon ) { _Read_Line(pShape, pPolygon->getExteriorRing()); for(int i=0; igetNumInteriorRings(); i++) { pPolygon->getInteriorRing(i); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_OGR_DataSet::Write(CSG_Shapes *pShapes) { if( !m_pDataSet || !pShapes || !pShapes->is_Valid() ) { return( false ); } //----------------------------------------------------- OGRSpatialReference *pSRS = NULL; if( pShapes->Get_Projection().is_Okay() ) { pSRS = new OGRSpatialReference(pShapes->Get_Projection().Get_WKT()); // pSRS = new OGRSpatialReference(); // pSRS ->importFromProj4(pShapes->Get_Projection().Get_Proj4()); } OGRLayer *pLayer = m_pDataSet->CreateLayer(CSG_String(pShapes->Get_Name()), pSRS, (OGRwkbGeometryType)gSG_OGR_Drivers.Get_Shape_Type(pShapes->Get_Type(), pShapes->Get_Vertex_Type() != SG_VERTEX_TYPE_XY) ); if( !pLayer ) { return( false ); } //------------------------------------------------- #ifdef USE_GDAL_V2 if( SG_STR_CMP(m_pDataSet->GetDriver()->GetDescription(), "DXF") ) { // the dxf driver does not support arbitrary field creation and returns OGRERR_FAILURE; // it seems like there is no method in OGR to check whether a driver supports field creation or not; // another issue with the dxf driver: 3D polygon data is not supported (would require e.g. "3DFACE" // entity implementation in GDAL/OGR), so we would need to treat them as polylines (not implemented, // currently it is necessary to convert to a line shapefile a priori) for(int iField=0; iFieldGet_Field_Count(); iField++) { OGRFieldDefn DefField(CSG_String(pShapes->Get_Field_Name(iField)), (OGRFieldType)gSG_OGR_Drivers.Get_Data_Type(pShapes->Get_Field_Type(iField))); if( pLayer->CreateField(&DefField) != OGRERR_NONE ) { return( false ); } } } #endif //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && SG_UI_Process_Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); OGRFeature *pFeature = OGRFeature::CreateFeature(pLayer->GetLayerDefn()); if( _Write_Geometry(pShape, pFeature, pShapes->Get_Vertex_Type() != SG_VERTEX_TYPE_XY) ) { // no need for a special treatment of DXF here, as pFeature->SetField() just silently ignores iFields out of range for(int iField=0; iFieldGet_Field_Count(); iField++) { switch( pShapes->Get_Field_Type(iField) ) { default: case SG_DATATYPE_Char: case SG_DATATYPE_String: case SG_DATATYPE_Date: pFeature->SetField(iField, CSG_String(pShape->asString(iField))); break; case SG_DATATYPE_Short: case SG_DATATYPE_Int: case SG_DATATYPE_Long: case SG_DATATYPE_Color: pFeature->SetField(iField, pShape->asInt(iField)); break; case SG_DATATYPE_Float: case SG_DATATYPE_Double: pFeature->SetField(iField, pShape->asDouble(iField)); break; } } pLayer->CreateFeature(pFeature); } OGRFeature::DestroyFeature(pFeature); } //----------------------------------------------------- return( true ); } //--------------------------------------------------------- bool CSG_OGR_DataSet::_Write_Geometry(CSG_Shape *pShape, OGRFeature *pFeature, bool bZ) { if( !pShape || !pFeature ) { return( false ); } switch( pShape->Get_Type() ) { //----------------------------------------------------- case SHAPE_TYPE_Point: { TSG_Point p = pShape->Get_Point(0); OGRPoint Point(p.x, p.y, pShape->Get_Z(0)); return( pFeature->SetGeometry(&Point) == OGRERR_NONE ); } //----------------------------------------------------- case SHAPE_TYPE_Points: { OGRMultiPoint Points; for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); OGRPoint Point(p.x, p.y, pShape->Get_Z(0)); Points.addGeometry(&Point); } } return( pFeature->SetGeometry(&Points) == OGRERR_NONE ); } //----------------------------------------------------- case SHAPE_TYPE_Line: if( pShape->Get_Part_Count() == 1 ) { OGRLineString Line; _Write_Line(pShape, &Line, 0, bZ); return( pFeature->SetGeometry(&Line) == OGRERR_NONE ); } else { OGRMultiLineString Lines; for(int iPart=0; iPartGet_Part_Count(); iPart++) { OGRLineString Line; if( _Write_Line(pShape, &Line, iPart, bZ) ) { Lines.addGeometry(&Line); } } return( pFeature->SetGeometry(&Lines) == OGRERR_NONE ); } //----------------------------------------------------- case SHAPE_TYPE_Polygon: { OGRPolygon Polygon; for(int iPart=0; iPartGet_Part_Count(); iPart++) { OGRLinearRing Ring; if( _Write_Line(pShape, &Ring, iPart, bZ) ) { Polygon.addRing(&Ring); } } return( pFeature->SetGeometry(&Polygon) == OGRERR_NONE ); } //------------------------------------------------- default: return( false ); } } //--------------------------------------------------------- bool CSG_OGR_DataSet::_Write_Line(CSG_Shape *pShape, OGRLineString *pLine, int iPart, bool bZ) { if( pLine && pShape && iPart >= 0 && iPart < pShape->Get_Part_Count() ) { pLine->empty(); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); pLine->addPoint(p.x, p.y, pShape->Get_Z(iPoint, iPart)); } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/ogr_export_kml.cpp0000744000175000017500000001430312737416172023603 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_export_kml.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_export_kml.cpp // // // // Copyright (C) 2012 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ogr_export_kml.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- COGR_Export_KML::COGR_Export_KML(void) { Set_Name (_TL("Export Shapes to KML")); Set_Author ("O.Conrad (c) 2012"); Set_Description (_TW( "This module exports a vector layer to a Google Earth KML Format using " "Frank Warmerdam's \"Geospatial Data Abstraction Library\" (GDAL/OGR). " "Output file will automatically re-projected to geographic coordinates " "if necessary and possible. " "For more information on GDAL/OGR have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format( "%s|*.kml;*.kml|%s|*.*", _TL("KML files (*.kml)"), _TL("All Files") ), NULL, true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool COGR_Export_KML::On_Execute(void) { CSG_Shapes Shapes, *pShapes = Parameters("SHAPES")->asShapes(); //----------------------------------------------------- if( pShapes->Get_Projection().Get_Type() == SG_PROJ_TYPE_CS_Undefined ) { Message_Add(_TL("layer uses undefined coordinate system, assuming geographic coordinates")); } else if( pShapes->Get_Projection().Get_Type() != SG_PROJ_TYPE_CS_Geographic ) { Message_Add(CSG_String::Format("\n%s (%s: %s)\n", _TL("re-projection to geographic coordinates"), _TL("original"), pShapes->Get_Projection().Get_Name().c_str()), false); bool bResult; SG_RUN_MODULE(bResult, "pj_proj4", 2, SG_MODULE_PARAMETER_SET("SOURCE" , pShapes) && SG_MODULE_PARAMETER_SET("TARGET" , &Shapes) && SG_MODULE_PARAMETER_SET("CRS_PROJ4", SG_T("+proj=longlat +ellps=WGS84 +datum=WGS84")) ); if( bResult ) { pShapes = &Shapes; Message_Add(CSG_String::Format("\n%s: %s\n", _TL("re-projection"), _TL("success")), false); } else { Message_Add(CSG_String::Format("\n%s: %s\n", _TL("re-projection"), _TL("failed" )), false); } } //----------------------------------------------------- CSG_OGR_DataSet DataSource; if( !DataSource.Create(Parameters("FILE")->asString(), "KML") ) { Error_Set(_TL("KML file creation failed")); return( false ); } if( !DataSource.Write(pShapes) ) { Error_Set(_TL("failed to store data")); return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/Makefile.in0000664000175000017500000005761212737447616022133 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/io/io_gdal ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_gdal_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libio_gdal_la_OBJECTS = gdal_catalogue.lo gdal_driver.lo \ gdal_export.lo gdal_export_geotiff.lo gdal_import.lo \ gdal_import_netcdf.lo gdal_import_wms.lo MLB_Interface.lo \ ogr_driver.lo ogr_export.lo ogr_export_kml.lo ogr_import.lo libio_gdal_la_OBJECTS = $(am_libio_gdal_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_gdal_la_SOURCES) DIST_SOURCES = $(libio_gdal_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1465 2012-08-23 09:20:00Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEP_LIBS = $(GDAL_LDFLAGS) DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core $(GDAL_CFLAGS) $(GDAL2FLAGS) AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) pkglib_LTLIBRARIES = libio_gdal.la libio_gdal_la_SOURCES = \ gdal_catalogue.cpp\ gdal_driver.cpp\ gdal_export.cpp\ gdal_export_geotiff.cpp\ gdal_import.cpp\ gdal_import_netcdf.cpp\ gdal_import_wms.cpp\ MLB_Interface.cpp\ ogr_driver.cpp\ ogr_export.cpp\ ogr_export_kml.cpp\ ogr_import.cpp\ gdal_catalogue.h\ gdal_driver.h\ gdal_export.h\ gdal_export_geotiff.h\ gdal_import.h\ gdal_import_netcdf.h\ gdal_import_wms.h\ MLB_Interface.h\ ogr_driver.h\ ogr_export.h\ ogr_export_kml.h\ ogr_import.h libio_gdal_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/io/io_gdal/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_gdal/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_gdal.la: $(libio_gdal_la_OBJECTS) $(libio_gdal_la_DEPENDENCIES) $(EXTRA_libio_gdal_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_gdal_la_OBJECTS) $(libio_gdal_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_catalogue.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_driver.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_export.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_export_geotiff.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_import_netcdf.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gdal_import_wms.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ogr_driver.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ogr_export.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ogr_export_kml.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ogr_import.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/io/io_gdal/ogr_export.h0000744000175000017500000000776712737416172022425 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_export.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_export.h // // // // Copyright (C) 2008 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__ogr_export_H #define HEADER_INCLUDED__ogr_export_H //--------------------------------------------------------- #include "ogr_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class COGR_Export : public CSG_Module { public: COGR_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Shapes|Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__ogr_export_H saga-2.3.1/src/modules/io/io_gdal/gdal_import_netcdf.cpp0000744000175000017500000003462412737416172024404 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_import_netcdf.cpp 1379 2012-04-26 11:58:47Z manfred-e $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_import_netcdf.cpp // // // // Copyright (C) 2012 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_import_netcdf.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Import_NetCDF::CGDAL_Import_NetCDF(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import NetCDF")); Set_Author (SG_T("O.Conrad (c) 2012")); Set_Description (_TW( "This module imports grids NetCDF Format using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" )); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grids"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format( SG_T("%s|*.nc|%s|*.*"), _TL("NetCDF Files (*.nc)"), _TL("All Files") ), NULL, false ); pNode = Parameters.Add_Value( NULL , "SAVE_FILE" , _TL("Save to File"), _TL("save output to file instead of memory"), PARAMETER_TYPE_Bool, false ); Parameters.Add_FilePath( pNode , "SAVE_PATH" , _TL("Save to Path"), _TL(""), NULL, NULL, true, true ); //----------------------------------------------------- pNode = Parameters.Add_Value( NULL , "TRANSFORM" , _TL("Transformation"), _TL("apply coordinate transformation if appropriate"), PARAMETER_TYPE_Bool, true ); Parameters.Add_Choice( NULL , "RESAMPLING" , _TL("Resampling"), _TL("interpolation method to use if grid needs to be aligned to coordinate system"), CSG_String::Format("%s|%s|%s|%s|", _TL("Nearest Neighbour"), _TL("Bilinear Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 3 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGDAL_Import_NetCDF::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "SAVE_FILE") ) { pParameters->Get_Parameter("SAVE_PATH" )->Set_Enabled(pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "VARS_ALL" ) && pParameters->Get_Parameter("VARS") ) { pParameters->Get_Parameter("VARS" )->Set_Enabled(!pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "TIME_ALL" ) && pParameters->Get_Parameter("TIME") ) { pParameters->Get_Parameter("TIME" )->Set_Enabled(!pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "LEVEL_ALL") && pParameters->Get_Parameter("LEVEL") ) { pParameters->Get_Parameter("LEVEL" )->Set_Enabled(!pParameter->asBool()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "TRANSFORM") ) { pParameters->Get_Parameter("RESAMPLING")->Set_Enabled(pParameter->asBool()); } return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- const char * CGDAL_Import_NetCDF::Get_Variable(CSG_GDAL_DataSet &DataSet, int iBand) { const char *s = DataSet.Get_MetaData_Item(iBand, "NETCDF_VARNAME"); return( s ); } //--------------------------------------------------------- const char * CGDAL_Import_NetCDF::Get_Time(CSG_GDAL_DataSet &DataSet, int iBand) { const char *s = DataSet.Get_MetaData_Item(iBand, "NETCDF_DIMENSION_time"); if( !s ) s = DataSet.Get_MetaData_Item(iBand, "NETCDF_DIM_time"); return( s ); } //--------------------------------------------------------- const char * CGDAL_Import_NetCDF::Get_Level(CSG_GDAL_DataSet &DataSet, int iBand) { const char *s = DataSet.Get_MetaData_Item(iBand, "NETCDF_DIMENSION_level"); if( !s ) s = DataSet.Get_MetaData_Item(iBand, "NETCDF_DIM_level"); if( !s ) s = DataSet.Get_MetaData_Item(iBand, "NETCDF_DIM_lev"); return( s ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CGDAL_Import_NetCDF::Get_Time_String(const CSG_String &Time, int Format) { switch( Format ) { case 0: return( CSG_Time_Converter::Get_String(Time.asInt(), SG_TIME_FMT_Hours_AD) ); default: return( Time ); } } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import_NetCDF::On_Execute(void) { //----------------------------------------------------- m_pGrids = Parameters("GRIDS")->asGridList(); m_pGrids ->Del_Items(); if( (m_bSaveFile = Parameters("SAVE_FILE")->asBool()) == true ) { m_SavePath = Parameters("SAVE_PATH")->asString(); if( !SG_Dir_Exists(m_SavePath) ) { m_SavePath = SG_File_Get_Path(Parameters("FILE")->asString()); } } //----------------------------------------------------- CSG_GDAL_DataSet DataSet; if( !DataSet.Open_Read(Parameters("FILE")->asString()) ) { Error_Set(CSG_String::Format(SG_T("%s [%s]"), _TL("could not open file"), Parameters("FILE")->asString())); return( false ); } if( DataSet.Get_DriverID().Cmp("netCDF") ) { Error_Set(CSG_String::Format(SG_T("%s [%s]"), _TL("invalid NetCDF file"), Parameters("FILE")->asString())); return( false ); } //----------------------------------------------------- CSG_MetaData MetaData; if( DataSet.Get_Count() <= 0 && DataSet.Get_MetaData(MetaData, "SUBDATASETS") ) { int i, n; for(i=0, n=0; i==n; i++) { CSG_MetaData *pEntry = MetaData.Get_Child(CSG_String::Format(SG_T("SUBDATASET_%d_NAME"), i + 1)); if( pEntry && DataSet.Open_Read(pEntry->Get_Content()) ) { CSG_String Desc = _TL("unknown"); if( (pEntry = MetaData.Get_Child(CSG_String::Format(SG_T("SUBDATASET_%d_DESC"), i + 1))) != NULL ) { Desc = pEntry->Get_Content(); } if( Load(DataSet, Desc) ) { n++; } } } return( n > 0 ); } return( Load(DataSet, SG_File_Get_Name(Parameters("FILE")->asString(), false)) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import_NetCDF::Load(CSG_GDAL_DataSet &DataSet, const CSG_String &Description) { const char *s; int i; //----------------------------------------------------- CSG_MetaData MetaData, *pChild; DataSet.Get_MetaData(MetaData); //----------------------------------------------------- int tFmt = -1; if( (pChild = MetaData.Get_Child("time#units")) != NULL ) { if( pChild->Get_Content().Find("hours since 1-1-1 00:00:0.0") >= 0 ) { tFmt = 0; } } //----------------------------------------------------- CSG_Parameters P, *pVars = NULL, *pTime = NULL, *pLevel = NULL; //----------------------------------------------------- if( SG_UI_Get_Window_Main() ) { CSG_Parameter *pNode; P.Create(this, _TL("Import NetCDF"), _TL("")); P.Set_Callback_On_Parameter_Changed(Get_Parameter_Changed()); P.Add_Info_String(NULL , "METADATA", _TL("Metadata"), _TL(""), MetaData.asText(), true); pNode = P.Add_Value (NULL , "VARS_ALL" , _TL("All Variables"), _TL(""), PARAMETER_TYPE_Bool, true); pVars = P.Add_Parameters(pNode, "VARS" , _TL("Selection") , _TL(""))->asParameters(); pNode = P.Add_Value (NULL , "TIME_ALL" , _TL("All Times") , _TL(""), PARAMETER_TYPE_Bool, true); pTime = P.Add_Parameters(pNode, "TIME" , _TL("Selection") , _TL(""))->asParameters(); pNode = P.Add_Value (NULL , "LEVEL_ALL" , _TL("All Levels") , _TL(""), PARAMETER_TYPE_Bool, true); pLevel = P.Add_Parameters(pNode, "LEVEL" , _TL("Selection") , _TL(""))->asParameters(); for(i=0; iGet_Parameter(s) ) pVars ->Add_Value(NULL, s, s, _TL(""), PARAMETER_TYPE_Bool, false); if( (s = Get_Time (DataSet, i)) != NULL && !pTime ->Get_Parameter(s) ) pTime ->Add_Value(NULL, s, Get_Time_String(s, tFmt), _TL(""), PARAMETER_TYPE_Bool, false); if( (s = Get_Level (DataSet, i)) != NULL && !pLevel->Get_Parameter(s) ) pLevel ->Add_Value(NULL, s, s, _TL(""), PARAMETER_TYPE_Bool, false); } P("VARS_ALL" )->Set_Enabled(pVars ->Get_Count() > 1); P("TIME_ALL" )->Set_Enabled(pTime ->Get_Count() > 1); P("LEVEL_ALL")->Set_Enabled(pLevel->Get_Count() > 1); //------------------------------------------------- if( !Dlg_Parameters(&P, CSG_String::Format(SG_T("%s: %s"), _TL("Import NetCDF"), Description.c_str())) ) { return( false ); } //------------------------------------------------- if( !P("VARS_ALL" )->is_Enabled() || P("VARS_ALL" )->asBool() ) pVars = NULL; if( !P("TIME_ALL" )->is_Enabled() || P("TIME_ALL" )->asBool() ) pTime = NULL; if( !P("LEVEL_ALL")->is_Enabled() || P("LEVEL_ALL")->asBool() ) pLevel = NULL; } //----------------------------------------------------- TSG_Grid_Resampling Resampling; switch( Parameters("RESAMPLING")->asInt() ) { default: Resampling = GRID_RESAMPLING_NearestNeighbour; break; case 1: Resampling = GRID_RESAMPLING_Bilinear; break; case 2: Resampling = GRID_RESAMPLING_BicubicSpline; break; case 3: Resampling = GRID_RESAMPLING_BSpline; break; } bool bTransform = Parameters("TRANSFORM")->asBool() && DataSet.Needs_Transformation(); //----------------------------------------------------- for(i=0; iasBool())) && (!pTime || (!!(pLoad = (*pTime )(Get_Time (DataSet, i))) && pLoad->asBool())) && (!pLevel || (!!(pLoad = (*pLevel)(Get_Level (DataSet, i))) && pLoad->asBool())) ) { SG_UI_Progress_Lock(true); if( (pGrid = DataSet.Read(i)) != NULL ) { if( bTransform ) { Process_Set_Text(CSG_String::Format(SG_T("%s [%d/%d]"), _TL("band transformation"), i + 1, DataSet.Get_Count())); DataSet.Get_Transformation(&pGrid, Resampling, true); } CSG_String Name(_TL("unknown")); if( (s = Get_Variable(DataSet, i)) != NULL && *s ) Name = s; if( (s = Get_Time (DataSet, i)) != NULL && *s ) Name += " [" + Get_Time_String(s, tFmt) + "]"; if( (s = Get_Level (DataSet, i)) != NULL && *s ) Name += " [" + CSG_String(s) + "]"; pGrid->Set_Name(Name); if( m_bSaveFile ) { Name.Replace(".", "_"); Name.Replace(":", "-"); pGrid->Save(SG_File_Make_Path(m_SavePath, Name)); delete(pGrid); } else { m_pGrids->Add_Item(pGrid); } } SG_UI_Progress_Lock(false); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/gdal_driver.cpp0000744000175000017500000007537712737416172023054 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_driver.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_driver.cpp // // // // Copyright (C) 2007 by O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_driver.h" #include #include #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_GDAL_Drivers gSG_GDAL_Drivers; const CSG_GDAL_Drivers & SG_Get_GDAL_Drivers (void) { return( gSG_GDAL_Drivers ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_GDAL_Drivers::CSG_GDAL_Drivers(void) { GDALAllRegister(); // affects Windows only, might be appropriate for applications // that treat filenames as being in the local encoding. // for more info see: http://trac.osgeo.org/gdal/wiki/ConfigOptions CPLSetConfigOption("GDAL_FILENAME_IS_UTF8", "NO"); m_pDrivers = GetGDALDriverManager(); } //--------------------------------------------------------- CSG_GDAL_Drivers::~CSG_GDAL_Drivers(void) { GDALDestroyDriverManager(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CSG_GDAL_Drivers::Get_Version(void) const { return( GDALVersionInfo("RELEASE_NAME") ); } //--------------------------------------------------------- int CSG_GDAL_Drivers::Get_Count(void) const { return( m_pDrivers->GetDriverCount() ); } //--------------------------------------------------------- GDALDriver * CSG_GDAL_Drivers::Get_Driver(const CSG_String &Name) const { return( (GDALDriver *)GDALGetDriverByName(Name) ); } //--------------------------------------------------------- GDALDriver * CSG_GDAL_Drivers::Get_Driver(int Index) const { return( (GDALDriver *)GDALGetDriver(Index) ); } //--------------------------------------------------------- CSG_String CSG_GDAL_Drivers::Get_Name(int Index) const { return( Get_Driver(Index)->GetMetadataItem(GDAL_DMD_LONGNAME) ); } //--------------------------------------------------------- CSG_String CSG_GDAL_Drivers::Get_Description(int Index) const { return( Get_Driver(Index)->GetDescription() ); } //--------------------------------------------------------- CSG_String CSG_GDAL_Drivers::Get_Extension(int Index) const { return( Get_Driver(Index)->GetMetadataItem(GDAL_DMD_EXTENSION) ); } //--------------------------------------------------------- bool CSG_GDAL_Drivers::is_Raster(int Index) const { #ifdef USE_GDAL_V2 return( Get_Driver(Index) && CSLFetchBoolean(Get_Driver(Index)->GetMetadata(), GDAL_DCAP_RASTER, false) ); #else return( true ); #endif } //--------------------------------------------------------- bool CSG_GDAL_Drivers::Can_Read(int Index) const { return( Get_Driver(Index) != NULL ); // ? CSLFetchBoolean(Get_Driver(Index)->GetMetadata(), GDAL_DCAP_CREATE, false) != 0 : false ); } //--------------------------------------------------------- bool CSG_GDAL_Drivers::Can_Write(int Index) const { return( Get_Driver(Index) && CSLFetchBoolean(Get_Driver(Index)->GetMetadata(), GDAL_DCAP_CREATE, false) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSG_GDAL_Drivers::Get_GDAL_Type(TSG_Data_Type Type) { switch( Type ) { case SG_DATATYPE_Bit: return( GDT_Byte ); // Eight bit unsigned integer case SG_DATATYPE_Byte: return( GDT_Byte ); // Eight bit unsigned integer case SG_DATATYPE_Char: return( GDT_Byte ); // Eight bit unsigned integer case SG_DATATYPE_Word: return( GDT_UInt16 ); // Sixteen bit unsigned integer case SG_DATATYPE_Short: return( GDT_Int16 ); // Sixteen bit signed integer case SG_DATATYPE_DWord: return( GDT_UInt32 ); // Thirty two bit unsigned integer case SG_DATATYPE_Int: return( GDT_Int32 ); // Thirty two bit signed integer case SG_DATATYPE_Float: return( GDT_Float32 ); // Thirty two bit floating point case SG_DATATYPE_Double: return( GDT_Float64 ); // Sixty four bit floating point default: return( GDT_Float64 ); } } //--------------------------------------------------------- TSG_Data_Type CSG_GDAL_Drivers::Get_SAGA_Type(int Type) { switch( Type ) { case GDT_Byte: return( SG_DATATYPE_Byte ); // Eight bit unsigned integer case GDT_UInt16: return( SG_DATATYPE_Word ); // Sixteen bit unsigned integer case GDT_Int16: return( SG_DATATYPE_Short ); // Sixteen bit signed integer case GDT_UInt32: return( SG_DATATYPE_DWord ); // Thirty two bit unsigned integer case GDT_Int32: return( SG_DATATYPE_Int ); // Thirty two bit signed integer case GDT_Float32: return( SG_DATATYPE_Float ); // Thirty two bit floating point case GDT_Float64: return( SG_DATATYPE_Double ); // Sixty four bit floating point case GDT_CInt16: return( SG_DATATYPE_Undefined ); // Complex Int16 case GDT_CInt32: return( SG_DATATYPE_Undefined ); // Complex Int32 case GDT_CFloat32: return( SG_DATATYPE_Undefined ); // Complex Float32 case GDT_CFloat64: return( SG_DATATYPE_Undefined ); // Complex Float64 default: return( SG_DATATYPE_Undefined ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_GDAL_DataSet::CSG_GDAL_DataSet(void) { m_pDataSet = m_pVrtSource = NULL; m_TF_A.Create(2); m_TF_B.Create(2, 2); } //--------------------------------------------------------- CSG_GDAL_DataSet::CSG_GDAL_DataSet(const CSG_String &File_Name) { m_pDataSet = m_pVrtSource = NULL; m_TF_A.Create(2); m_TF_B.Create(2, 2); Open_Read(File_Name); } //--------------------------------------------------------- CSG_GDAL_DataSet::~CSG_GDAL_DataSet(void) { Close(); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_GDAL_DataSet::Open_Read(const CSG_String &File_Name) { Close(); if( (m_pDataSet = (GDALDataset *)GDALOpen(File_Name, GA_ReadOnly)) == NULL ) { return( false ); } //----------------------------------------------------- m_File_Name = File_Name; m_Access = SG_GDAL_IO_READ; return( _Set_Transformation() ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Open_Read(const CSG_String &File_Name, const CSG_Grid_System &System) { Close(); if( (m_pVrtSource = (GDALDataset *)GDALOpen(File_Name, GA_ReadOnly)) == NULL ) { return( false ); } //----------------------------------------------------- if( (m_pDataSet = (VRTDataset *)VRTCreate(System.Get_NX(), System.Get_NY())) == NULL ) { Close(); return( false ); } m_pDataSet->SetProjection(m_pVrtSource->GetProjectionRef()); double Transform[6] = { System.Get_XMin(true), System.Get_Cellsize(), 0.0, System.Get_YMax(true), 0.0, -System.Get_Cellsize() }; m_pDataSet->SetGeoTransform(Transform); //----------------------------------------------------- m_pVrtSource->GetGeoTransform(Transform); if( Transform[2] != 0.0 || Transform[4] != 0.0 ) { return( false ); // geotransform is rotated, this configuration is not supported... } int xOff = (int)floor((System.Get_XMin (true) - Transform[0]) / Transform[1] + 0.001); int yOff = (int)floor((System.Get_YMax (true) - Transform[3]) / Transform[5] + 0.001); int xSize = (int) ( System.Get_XRange(true) / Transform[1] + 0.5 ); int ySize = (int) ( System.Get_YRange(true) / fabs(Transform[5]) + 0.5 ); //----------------------------------------------------- for(int i=0; iGetRasterCount(); i++) { GDALRasterBand *pSrcBand = m_pVrtSource->GetRasterBand(i + 1); m_pDataSet->AddBand(pSrcBand->GetRasterDataType(), NULL); VRTSourcedRasterBand *pVrtBand = (VRTSourcedRasterBand *)m_pDataSet->GetRasterBand(i + 1); pVrtBand->AddSimpleSource(pSrcBand, xOff, yOff, xSize, ySize, 0, 0, System.Get_NX(), System.Get_NY() ); //#if GDAL_VERSION_MAJOR >= 2 // instead of pVrtBand->AddSimpleSource(...) // VRTSimpleSource *pSrcSimple = new VRTSimpleSource(); // // // pSrcSimple->SetResampling(pszResampling); // // pVrtBand->ConfigureSource(pSrcSimple, pSrcBand, 0, // xOff, yOff, xSize, ySize, 0, 0, System.Get_NX(), System.Get_NY() // ); // // pVrtBand->AddSource(pSrcSimple); //#endif } //----------------------------------------------------- m_File_Name = File_Name; m_Access = SG_GDAL_IO_READ; return( _Set_Transformation() ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::_Set_Transformation(void) { if( !m_pDataSet ) { return( false ); } double Transform[6]; m_NX = m_pDataSet->GetRasterXSize(); m_NY = m_pDataSet->GetRasterYSize(); if( m_pDataSet->GetGeoTransform(Transform) != CE_None ) { m_bTransform = false; m_Cellsize = 1.0; m_xMin = 0.5; m_yMin = 0.5; } else if( Transform[1] == -Transform[5] && Transform[2] == 0.0 && Transform[4] == 0.0 ) // nothing to transform { m_bTransform = false; m_Cellsize = Transform[1]; // pixel width (== pixel height) m_xMin = Transform[0] + m_Cellsize * 0.5; // center (x) of left edge pixels m_yMin = Transform[3] + m_Cellsize * (0.5 - m_NY); // center (y) of lower edge pixels } else { m_bTransform = true; m_Cellsize = 1.0; m_xMin = 0.0; m_yMin = 0.0; } m_TF_A[0] = Transform[0]; m_TF_A[1] = Transform[3]; m_TF_B[0][0] = Transform[1]; m_TF_B[0][1] = Transform[2]; m_TF_B[1][0] = Transform[4]; m_TF_B[1][1] = Transform[5]; m_TF_BInv = m_TF_B.Get_Inverse(); return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_GDAL_DataSet::Open_Write(const CSG_String &File_Name, const CSG_String &Driver, const CSG_String &Options, TSG_Data_Type Type, int NBands, const CSG_Grid_System &System, const CSG_Projection &Projection) { Close(); //-------------------------------------------------------- char **pOptions = NULL; if( !Options.is_Empty() ) { char **pTokens = CSLTokenizeString2(Options, " ", CSLT_STRIPLEADSPACES); for(int i=0; pTokens && pTokens[i]; i++) { pOptions = CSLAddString(pOptions, pTokens[i]); } } //-------------------------------------------------------- GDALDriver *pDriver; if( (pDriver = gSG_GDAL_Drivers.Get_Driver(Driver)) == NULL ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("%s: %s"), _TL("driver not found."), Driver.c_str())); return( false ); } if( !GDALValidateCreationOptions(pDriver, pOptions) ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("%s: %s"), _TL("Creation option(s) not supported by the driver"), Options.c_str())); return( false ); } if( CSLFetchBoolean(pDriver->GetMetadata(), GDAL_DCAP_CREATE, false) == false ) { SG_UI_Msg_Add_Error(_TL("Driver does not support file creation.")); return( false ); } if( (m_pDataSet = pDriver->Create(File_Name, System.Get_NX(), System.Get_NY(), NBands, (GDALDataType)gSG_GDAL_Drivers.Get_GDAL_Type(Type), pOptions)) == NULL ) { SG_UI_Msg_Add_Error(_TL("Could not create dataset.")); return( false ); } //-------------------------------------------------------- m_File_Name = File_Name; m_Access = SG_GDAL_IO_WRITE; if( Projection.is_Okay() ) { m_pDataSet->SetProjection(Projection.Get_WKT()); } double Transform[6] = { System.Get_XMin() - 0.5 * System.Get_Cellsize(), System.Get_Cellsize(), 0.0, System.Get_YMax() + 0.5 * System.Get_Cellsize(), 0.0, -System.Get_Cellsize() }; m_pDataSet->SetGeoTransform(Transform); m_NX = m_pDataSet->GetRasterXSize(); m_NY = m_pDataSet->GetRasterYSize(); m_bTransform = false; m_Cellsize = 1.0; m_xMin = 0.5; m_yMin = 0.5; return( true ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Close(void) { if( m_pVrtSource ) { GDALClose(m_pVrtSource); m_pVrtSource = NULL; if( m_pDataSet ) { // GDALClose(m_pDataSet); // this crashes in debug mode, gdal2.0dev!!!(???) m_pDataSet = NULL; } } if( m_pDataSet ) { GDALClose(m_pDataSet); m_pDataSet = NULL; } m_File_Name.Clear(); m_Access = SG_GDAL_IO_CLOSED; if( strlen(CPLGetLastErrorMsg()) > 3 ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("%s: %s"), _TL("Dataset creation failed"), SG_STR_MBTOSG(CPLGetLastErrorMsg()))); CPLErrorReset(); return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- GDALDriver * CSG_GDAL_DataSet::Get_Driver(void) const { return( m_pDataSet ? m_pDataSet->GetDriver() : NULL ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_DriverID(void) const { return( m_pDataSet && m_pDataSet->GetDriver() && m_pDataSet->GetDriver()->GetDescription() ? m_pDataSet->GetDriver()->GetDescription() : "" ); } //--------------------------------------------------------- const char * CSG_GDAL_DataSet::Get_Projection(void) const { return( m_pDataSet && m_pDataSet->GetProjectionRef() ? m_pDataSet->GetProjectionRef() : "" ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_Name(void) const { return( m_pDataSet ? m_pDataSet->GetMetadataItem(GDAL_DMD_LONGNAME) : "" ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_Description(void) const { return( m_pDataSet ? m_pDataSet->GetDescription() : "" ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_File_Name(void) const { return( m_File_Name ); } //--------------------------------------------------------- const char * CSG_GDAL_DataSet::Get_MetaData_Item(const char *pszName, const char *pszDomain) const { return( m_pDataSet ? m_pDataSet->GetMetadataItem(pszName, pszDomain) : "" ); } //--------------------------------------------------------- const char ** CSG_GDAL_DataSet::Get_MetaData(const char *pszDomain) const { return( m_pDataSet ? (const char **)m_pDataSet->GetMetadata(pszDomain) : NULL ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_MetaData_Item(CSG_String &MetaData, const char *pszName, const char *pszDomain) const { const char *Item = Get_MetaData_Item(pszName, pszDomain); if( Item && *Item ) { MetaData = Item; return( true ); } return( false ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_MetaData(CSG_MetaData &MetaData) const { if( m_pDataSet && is_Reading() ) { char **pMetaData = m_pDataSet->GetMetadata() + 0; if( pMetaData ) { while( *pMetaData ) { CSG_String s(*pMetaData); MetaData.Add_Child(s.BeforeFirst(SG_T('=')), s.AfterFirst(SG_T('='))); pMetaData++; } return( true ); } } return( false ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_MetaData(CSG_MetaData &MetaData, const char *pszDomain) const { if( m_pDataSet && is_Reading() ) { char **pMetaData = m_pDataSet->GetMetadata(pszDomain) + 0; if( pMetaData ) { while( *pMetaData ) { CSG_String s(*pMetaData); MetaData.Add_Child(s.BeforeFirst(SG_T('=')), s.AfterFirst(SG_T('='))); pMetaData++; } return( true ); } } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CSG_GDAL_DataSet::Get_Count(void) const { return( m_pDataSet ? m_pDataSet->GetRasterCount() : 0 ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_Name(int i) const { CSG_String Name; GDALRasterBand *pBand; if( is_Reading() && (pBand = m_pDataSet->GetRasterBand(i + 1)) != NULL ) { const char *s; //------------------------------------------------- if( !SG_STR_CMP(m_pDataSet->GetDriver()->GetDescription(), "GRIB") ) { if( (s = pBand->GetMetadataItem("GRIB_COMMENT")) != NULL && *s ) { Name = s; if( (s = pBand->GetMetadataItem("GRIB_ELEMENT" )) != NULL && *s ) { Name += "["; Name += s; Name += "]"; } if( (s = pBand->GetMetadataItem("GRIB_SHORT_NAME")) != NULL && *s ) { Name += "["; Name += s; Name += "]"; } if( (s = pBand->GetMetadataItem("GRIB_VALID_TIME")) != NULL && *s ) { Name += CSG_String::Format(SG_T("[%s]"), CSG_Time_Converter::Get_String(atoi(s), SG_TIME_FMT_Seconds_Unix).c_str()); } } } //------------------------------------------------- if( !SG_STR_CMP(m_pDataSet->GetDriver()->GetDescription(), "netCDF") ) { if( (s = pBand->GetMetadataItem("NETCDF_VARNAME" )) != NULL && *s ) { Name += "["; Name += s; Name += "]"; } if( (s = pBand->GetMetadataItem("NETCDF_DIMENSION_time" )) != NULL && *s ) { Name += "["; Name += s; Name += "]"; } if( (s = pBand->GetMetadataItem("NETCDF_DIMENSION_level")) != NULL && *s ) { Name += "["; Name += s; Name += "]"; } } //------------------------------------------------- if( Name.is_Empty() ) { Name = Get_Name(); if( Name.is_Empty() ) { Name = _TL("Band"); } Name += CSG_String::Format(SG_T(" %0*d"), SG_Get_Digit_Count(Get_Count() + 1), i + 1); } } return( Name ); } //--------------------------------------------------------- CSG_String CSG_GDAL_DataSet::Get_Description(int i) const { CSG_String Description; GDALRasterBand *pBand; if( is_Reading() && (pBand = m_pDataSet->GetRasterBand(i + 1)) != NULL ) { char **pMetaData = pBand->GetMetadata() + 0; if( pMetaData ) { while( *pMetaData ) { CSG_String s(*pMetaData); Description += s + SG_T("\n"); pMetaData++; } } } return( Description ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_MetaData(int i, CSG_MetaData &MetaData) const { GDALRasterBand *pBand; if( is_Reading() && (pBand = m_pDataSet->GetRasterBand(i + 1)) != NULL ) { char **pMetaData = pBand->GetMetadata() + 0; if( pMetaData ) { while( *pMetaData ) { CSG_String s(*pMetaData); MetaData.Add_Child(s.BeforeFirst(SG_T('=')), s.AfterFirst(SG_T('='))); pMetaData++; } return( true ); } } return( false ); } //--------------------------------------------------------- const char * CSG_GDAL_DataSet::Get_MetaData_Item(int i, const char *pszName) const { GDALRasterBand *pBand = m_pDataSet->GetRasterBand(i + 1); return( pBand ? pBand->GetMetadataItem(pszName) : "" ); } bool CSG_GDAL_DataSet::Get_MetaData_Item(int i, const char *pszName, CSG_String &MetaData) const { GDALRasterBand *pBand; if( (pBand = m_pDataSet->GetRasterBand(i + 1)) != NULL ) { const char *pMetaData = pBand->GetMetadataItem(pszName); if( pMetaData && *pMetaData ) { MetaData = pMetaData; return( true ); } } return( false ); } //--------------------------------------------------------- CSG_Grid * CSG_GDAL_DataSet::Read(int i) { //------------------------------------------------- if( !is_Reading() ) { return( NULL ); } //------------------------------------------------- GDALRasterBand *pBand = m_pDataSet->GetRasterBand(i + 1); if( !pBand ) { return( NULL ); } //------------------------------------------------- TSG_Data_Type Type = gSG_GDAL_Drivers.Get_SAGA_Type(pBand->GetRasterDataType()); CSG_Grid *pGrid = SG_Create_Grid(Type, Get_NX(), Get_NY(), Get_Cellsize(), Get_xMin(), Get_yMin()); if( !pGrid ) { return( NULL ); } //------------------------------------------------- int bSuccess; double zScale = pBand->GetScale (&bSuccess); if( !bSuccess || !zScale ) zScale = 1.0; double zOffset = pBand->GetOffset(&bSuccess); if( !bSuccess ) zOffset = 0.0; pGrid->Set_Name (Get_Name (i)); pGrid->Set_Description (Get_Description(i)); pGrid->Set_Unit (CSG_String(pBand->GetUnitType())); pGrid->Set_Scaling (zScale, zOffset); pBand->GetNoDataValue(&bSuccess); if( bSuccess ) { pGrid->Set_NoData_Value(pBand->GetNoDataValue(&bSuccess)); } pGrid->Get_Projection().Create(Get_Projection(), SG_PROJ_FMT_WKT); Get_MetaData(i, pGrid->Get_MetaData()); //------------------------------------------------- double *zLine = (double *)SG_Malloc(Get_NX() * sizeof(double)); for(int y=0; yRasterIO(GF_Read, 0, y, Get_NX(), 1, zLine, Get_NX(), 1, GDT_Float64, 0, 0) == CE_None ) { for(int x=0; xSet_NoData(x, yy); else pGrid->Set_Value(x, yy, zLine[x], false); } } } SG_Free(zLine); return( pGrid ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Write(int i, CSG_Grid *pGrid, double noDataValue) { if( !m_pDataSet || !pGrid || pGrid->Get_NX() != Get_NX() || pGrid->Get_NY() != Get_NY() || i < 0 || i >= Get_Count() ) { return( false ); } GDALRasterBand *pBand = m_pDataSet->GetRasterBand(i + 1); //----------------------------------------------------- CPLErr Error = CE_None; double *zLine = (double *)SG_Malloc(Get_NX() * sizeof(double)); for(int y=0, yy=Get_NY()-1; Error==CE_None && yis_NoData(x, yy) ? noDataValue : pGrid->asDouble(x, yy); } Error = pBand->RasterIO(GF_Write, 0, y, Get_NX(), 1, zLine, Get_NX(), 1, GDT_Float64, 0, 0); } SG_Free(zLine); //----------------------------------------------------- if( Error != CE_None ) { SG_UI_Msg_Add_Error(CSG_String::Format(SG_T("%s"), _TL("Writing dataset failed."))); return( false ); } //----------------------------------------------------- pBand->SetNoDataValue (noDataValue); pBand->SetStatistics (pGrid->Get_ZMin(), pGrid->Get_ZMax(), pGrid->Get_Mean(), pGrid->Get_StdDev()); return( true ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Write(int i, CSG_Grid *pGrid) { return (CSG_GDAL_DataSet::Write (i, pGrid, pGrid->Get_NoData_Value())); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Rect CSG_GDAL_DataSet::Get_Extent(bool bTransform) const { if( bTransform && Needs_Transformation() ) { CSG_Grid_System System; if( Get_Transformation(System, false) ) { return( System.Get_Extent() ); } } return( CSG_Rect(Get_xMin(), Get_yMin(), Get_xMax(), Get_yMax()) ); } //--------------------------------------------------------- CSG_Grid_System CSG_GDAL_DataSet::Get_System(void) const { CSG_Grid_System System; if( !Needs_Transformation() || !Get_Transformation(System, false) ) { System.Assign(Get_Cellsize(), Get_xMin(), Get_yMin(), Get_NX(), Get_NY()); } return( System ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_Transformation(CSG_Grid_System &System, bool bVerbose) const { CSG_Vector A; CSG_Matrix B; Get_Transformation(A, B); //----------------------------------------------------- if( Needs_Transformation() ) { CSG_Vector v(2); CSG_Rect r; v[0] = Get_xMin() + 0.5; v[1] = Get_yMin() + 0.5; v = B * v + A; r.Assign(v[0], v[1], v[0], v[1]); v[0] = Get_xMin() + 0.5; v[1] = Get_yMax() - 0.5; v = B * v + A; r.Union(CSG_Point(v[0], v[1])); v[0] = Get_xMax() - 0.5; v[1] = Get_yMax() - 0.5; v = B * v + A; r.Union(CSG_Point(v[0], v[1])); v[0] = Get_xMax() - 0.5; v[1] = Get_yMin() + 0.5; v = B * v + A; r.Union(CSG_Point(v[0], v[1])); v[0] = 1; v[1] = 0; v = B * v; double dx = v.Get_Length(); v[0] = 0; v[1] = 1; v = B * v; double dy = v.Get_Length(); if( dx != dy ) { if( bVerbose ) { SG_UI_Msg_Add_Execution(CSG_String::Format("\n%s: %s\n\t%s: %f", _TL("warning"), _TL("top-to-bottom and left-to-right cell sizes differ."), _TL("Difference"), fabs(dy - dx)), false ); } if( dx > dy ) { dx = dy; } if( bVerbose ) { SG_UI_Msg_Add_Execution(CSG_String::Format("\n\t%s: %f\n", _TL("using cellsize"), dx), false); } } return( System.Assign(dx, r) ); } //----------------------------------------------------- return( false ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_Transformation(CSG_Grid **ppGrid, TSG_Grid_Resampling Interpolation, bool bVerbose) const { CSG_Grid_System System; if( Get_Transformation(System, bVerbose) ) { return( Get_Transformation(ppGrid, Interpolation, System, bVerbose) ); } return( false ); } //--------------------------------------------------------- bool CSG_GDAL_DataSet::Get_Transformation(CSG_Grid **ppGrid, TSG_Grid_Resampling Interpolation, const CSG_Grid_System &System, bool bVerbose) const { if( !System.is_Valid() ) { return( false ); } //----------------------------------------------------- CSG_Vector A; CSG_Matrix B, BInv; Get_Transformation(A, B); BInv = B.Get_Inverse(); //----------------------------------------------------- CSG_Grid *pImage = *ppGrid; CSG_Grid *pWorld = SG_Create_Grid(System, pImage->Get_Type()); if( !pWorld ) { return( false ); } *ppGrid = pWorld; pWorld->Set_Name (pImage->Get_Name ()); pWorld->Set_Description (pImage->Get_Description ()); pWorld->Set_Unit (pImage->Get_Unit ()); pWorld->Set_Scaling (pImage->Get_Scaling (), pImage->Get_Offset()); pWorld->Set_NoData_Value_Range(pImage->Get_NoData_Value(), pImage->Get_NoData_hiValue()); pWorld->Get_MetaData() = pImage->Get_MetaData (); pWorld->Get_Projection() = pImage->Get_Projection (); //----------------------------------------------------- // #pragma omp parallel for // for(int y=0; yGet_NY(); y++) // { // Process_Get_Okay(); for(int y=0; yGet_NY() && SG_UI_Process_Set_Progress(y, pWorld->Get_NY()); y++) { #pragma omp parallel for for(int x=0; xGet_NX(); x++) { double z; CSG_Vector vWorld(2), vImage; vWorld[0] = pWorld->Get_XMin() + (x - 0.5) * pWorld->Get_Cellsize(); vWorld[1] = pWorld->Get_YMin() + (y + 0.5) * pWorld->Get_Cellsize(); vImage = BInv * (vWorld - A); if( pImage->Get_Value(vImage[0], vImage[1], z, Interpolation, false, true) ) { pWorld->Set_Value(x, y, z); } else { pWorld->Set_NoData(x, y); } } } delete(pImage); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- TSG_Data_Type SG_Get_Grid_Type (CSG_Parameter_Grid_List *pGrids) { TSG_Data_Type Type = SG_DATATYPE_Byte; if( pGrids ) { for(int i=0; iGet_Count(); i++) { if( SG_Data_Type_Get_Size(Type) <= SG_Data_Type_Get_Size(pGrids->asGrid(i)->Get_Type()) ) { Type = pGrids->asGrid(i)->Get_Type(); } } } return( Type ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/Makefile.am0000744000175000017500000000174112737416172022102 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1465 2012-08-23 09:20:00Z oconrad $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEP_LIBS = $(GDAL_LDFLAGS) DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core $(GDAL_CFLAGS) $(GDAL2FLAGS) AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LIBS) pkglib_LTLIBRARIES = libio_gdal.la libio_gdal_la_SOURCES =\ gdal_catalogue.cpp\ gdal_driver.cpp\ gdal_export.cpp\ gdal_export_geotiff.cpp\ gdal_import.cpp\ gdal_import_netcdf.cpp\ gdal_import_wms.cpp\ MLB_Interface.cpp\ ogr_driver.cpp\ ogr_export.cpp\ ogr_export_kml.cpp\ ogr_import.cpp\ gdal_catalogue.h\ gdal_driver.h\ gdal_export.h\ gdal_export_geotiff.h\ gdal_import.h\ gdal_import_netcdf.h\ gdal_import_wms.h\ MLB_Interface.h\ ogr_driver.h\ ogr_export.h\ ogr_export_kml.h\ ogr_import.h libio_gdal_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la saga-2.3.1/src/modules/io/io_gdal/ogr_import.cpp0000744000175000017500000002045012737416172022731 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: ogr_import.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // ogr_import.cpp // // // // Copyright (C) 2008 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "ogr_import.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- COGR_Import::COGR_Import(void) { Set_Name (_TL("Import Shapes")); Set_Author ("O.Conrad (c) 2008"); CSG_String Description, Filter, Filter_All; Description = _TW( "The \"OGR Vector Data Import\" module imports vector data from various file/database formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format("\nGDAL %s:%s\n\n", _TL("Version"), SG_Get_OGR_Drivers().Get_Version().c_str()); Description += _TL("Following raster formats are currently supported:"); Description += CSG_String::Format("\n", _TL("ID"), _TL("Name"), _TL("Extension") ); for(int i=0; i"; if( !Ext.is_Empty() ) { Ext.Replace("/", ";"); Filter += Name + "|*." + Ext + "|"; Filter_All += (Filter_All.is_Empty() ? "*." : ";*.") + Ext; } } } Description += "
    %s%s%s
    " + Name + "" + Ext + "
    "; Set_Description(Description); Filter.Prepend(CSG_String::Format("%s|%s|" , _TL("All Recognized Files"), Filter_All.c_str())); Filter.Append (CSG_String::Format("%s|*.*" , _TL("All Files"))); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_FilePath( NULL , "FILES" , _TL("Files"), _TL(""), Filter, NULL, false, false, true ); CSG_String sChoices; for(int i=0; iasFilePath()->Get_FilePaths(Files) ) { return( false ); } //----------------------------------------------------- Parameters("SHAPES")->asShapesList()->Del_Items(); for(int iFile=0; iFileasInt()); if( pShapes ) { Parameters("SHAPES")->asShapesList()->Add_Item(pShapes); CSG_String Name = pShapes->Get_Name(); pShapes->Get_MetaData().Add_Child("GDAL_DRIVER", DataSource.Get_DriverID()); pShapes->Set_File_Name(Files[iFile]); pShapes->Set_Description(DataSource.Get_Description(iLayer)); if( Name.is_Empty() ) { pShapes->Set_Name(SG_File_Get_Name(Files[iFile], false) + (DataSource.Get_Count() == 1 ? CSG_String("") : CSG_String::Format(" [%d]", 1 + iLayer))); } else { pShapes->Set_Name(Name); } } } } } return( Parameters("SHAPES")->asShapesList()->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool SG_OGR_Import (const CSG_String &File_Name) { COGR_Import Import; if( !Import.Get_Parameters()->Set_Parameter(SG_T("FILES"), File_Name, PARAMETER_TYPE_FilePath) ) { return( false ); } if( !Import.Execute() ) { return( false ); } CSG_Parameter_Shapes_List *pShapes = Import.Get_Parameters()->Get_Parameter(SG_T("SHAPES"))->asShapesList(); for(int i=0; iGet_Count(); i++) { SG_UI_DataObject_Add(pShapes->asShapes(i), SG_UI_DATAOBJECT_UPDATE_ONLY); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/gdal_export.cpp0000744000175000017500000002066612737416172023071 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_export.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_export.cpp // // // // Copyright (C) 2007 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_export.h" #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Export::CGDAL_Export(void) { Set_Name (_TL("Export Raster")); Set_Author ("O.Conrad (c) 2007"); CSG_String Description, Formats, Filter; Description = _TW( "The \"GDAL Raster Export\" module exports one or more grids to various file formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format("\nGDAL %s:%s\n\n", _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str()); Description += _TL("Following raster formats are currently supported:"); Description += CSG_String::Format("\n\n", _TL("ID"), _TL("Name"), _TL("Extension") ); Filter.Printf("%s|*.*", _TL("All Files")); for(int i=0; i"; Formats += "{" + ID + "}" + Name + "|"; if( !Ext.is_Empty() ) { Ext.Replace("/", ";"); Filter += "|" + Name + "|*." + Ext; } } } Description += "
    %s%s%s
    " + Name + "" + Ext + "
    "; Set_Description(Description); //----------------------------------------------------- Parameters.Add_Grid_List( NULL , "GRIDS" , _TL("Grid(s)"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL("The GDAL dataset to be created."), Filter, NULL, true ); Parameters.Add_Choice( NULL , "FORMAT" , _TL("Format"), _TL("The GDAL raster format (driver) to be used."), Formats ); Parameters.Add_Choice( NULL , "TYPE" , _TL("Data Type"), _TL("The GDAL datatype of the created dataset."), CSG_String::Format("%s|%s|%s|%s|%s|%s|%s|%s|", _TL("match input data"), _TL("8 bit unsigned integer"), _TL("16 bit unsigned integer"), _TL("16 bit signed integer"), _TL("32 bit unsigned integer"), _TL("32 bit signed integer"), _TL("32 bit floating point"), _TL("64 bit floating point") ), 0 ); Parameters.Add_Bool( NULL , "SET_NODATA" , _TL("Set Custom NoData"), _TL(""), false ); Parameters.Add_Double( NULL , "NODATA" , _TL("NoData Value"), _TL(""), PARAMETER_TYPE_Double, 0.0 ); Parameters.Add_String( NULL , "OPTIONS" , _TL("Creation Options"), _TL("A space separated list of key-value pairs (K=V)."), _TL("") ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Export::On_Execute(void) { TSG_Data_Type Type; CSG_String File_Name, Driver, Options; CSG_Projection Projection; CSG_Parameter_Grid_List *pGrids; CSG_GDAL_DataSet DataSet; //----------------------------------------------------- pGrids = Parameters("GRIDS") ->asGridList(); File_Name = Parameters("FILE") ->asString(); Options = Parameters("OPTIONS") ->asString(); Get_Projection(Projection); //----------------------------------------------------- switch( Parameters("TYPE")->asInt() ) { default: case 0: Type = SG_Get_Grid_Type(pGrids); break; // match input data case 1: Type = SG_DATATYPE_Byte; break; // Eight bit unsigned integer case 2: Type = SG_DATATYPE_Word; break; // Sixteen bit unsigned integer case 3: Type = SG_DATATYPE_Short; break; // Sixteen bit signed integer case 4: Type = SG_DATATYPE_DWord; break; // Thirty two bit unsigned integer case 5: Type = SG_DATATYPE_Int; break; // Thirty two bit signed integer case 6: Type = SG_DATATYPE_Float; break; // Thirty two bit floating point case 7: Type = SG_DATATYPE_Double; break; // Sixty four bit floating point } //----------------------------------------------------- if( !Parameters("FORMAT")->asChoice()->Get_Data(Driver) ) { return( false ); } //----------------------------------------------------- if( !DataSet.Open_Write(File_Name, Driver, Options, Type, pGrids->Get_Count(), *Get_System(), Projection) ) { return( false ); } //----------------------------------------------------- for(int i=0; iGet_Count(); i++) { Process_Set_Text(CSG_String::Format(SG_T("%s %d"), _TL("Band"), i + 1)); if ( Parameters("SET_NODATA")->asBool() ) { DataSet.Write(i, pGrids->asGrid(i), Parameters("NODATA")->asDouble()); } else { DataSet.Write(i, pGrids->asGrid(i)); } } if( !DataSet.Close() ) { return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/gdal_export_geotiff.h0000744000175000017500000001006112737416172024225 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_export_geotiff.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_export_geotiff.h // // // // Copyright (C) 2007 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_export_geotiff_H #define HEADER_INCLUDED__gdal_export_geotiff_H //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGDAL_Export_GeoTIFF : public CSG_Module_Grid { public: CGDAL_Export_GeoTIFF(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid|Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_export_geotiff_H saga-2.3.1/src/modules/io/io_gdal/MLB_Interface.h0000744000175000017500000000740112737416172022610 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // MLB_Interface.h // // // // Copyright (C) 2007 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Include the SAGA-API here // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__io_gdal_H #define HEADER_INCLUDED__io_gdal_H //--------------------------------------------------------- #include //--------------------------------------------------------- #ifdef io_gdal_EXPORTS #define io_gdal_EXPORT _SAGA_DLL_EXPORT #else #define io_gdal_EXPORT _SAGA_DLL_IMPORT #endif /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__io_gdal_H saga-2.3.1/src/modules/io/io_gdal/gdal_catalogue.cpp0000744000175000017500000004510112737416172023503 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_catalogue.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_gdal // // // //-------------------------------------------------------// // // // gdal_catalogue.cpp // // // // Copyright (C) 2015 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_catalogue.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Catalogue::CGDAL_Catalogue(void) { //----------------------------------------------------- Set_Name (_TL("Create Raster Catalogue from Files")); Set_Author ("O.Conrad (c) 2015"); CSG_String Description; Description = _TW( "Create a raster catalogue from selected files. Output is a polygon layer " "that shows the extent for each valid raster file. Each extent is attributed with " "the original file path and raster system properties.\n" "\n" "The \"GDAL Raster Import\" module imports grid data from various file formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format("\nGDAL %s:%s\n\n", _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str()); Description += _TW( "Following raster formats are currently supported:\n" "\n" ); for(int i=0; i\n", SG_Get_GDAL_Drivers().Get_Description(i).c_str(), SG_Get_GDAL_Drivers().Get_Name (i).c_str() ); } Description += "
    IDName
    %s%s
    "; Set_Description(Description); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "CATALOGUE" , _TL("Raster Catalogue"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_FilePath( NULL , "FILES" , _TL("Files"), _TL(""), NULL, NULL, false, false, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGDAL_Catalogue::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Catalogue::On_Execute(void) { //----------------------------------------------------- CSG_Strings Files; if( !Parameters("FILES")->asFilePath()->Get_FilePaths(Files) ) { return( false ); } //----------------------------------------------------- CSG_Shapes *pCatalogue = Parameters("CATALOGUE")->asShapes(); pCatalogue->Create(SHAPE_TYPE_Polygon, _TL("Raster Catalogue")); pCatalogue->Add_Field("ID" , SG_DATATYPE_Int ); pCatalogue->Add_Field("NAME" , SG_DATATYPE_String); pCatalogue->Add_Field("FILE" , SG_DATATYPE_String); pCatalogue->Add_Field("CRS" , SG_DATATYPE_String); pCatalogue->Add_Field("BANDS" , SG_DATATYPE_Int ); pCatalogue->Add_Field("CELLSIZE", SG_DATATYPE_Double); pCatalogue->Add_Field("ROWS" , SG_DATATYPE_Int ); pCatalogue->Add_Field("COLUMNS" , SG_DATATYPE_Int ); //----------------------------------------------------- for(int i=0; iAdd_Shape(); pEntry->Set_Value(0, pCatalogue->Get_Count ()); pEntry->Set_Value(1, Name ); pEntry->Set_Value(2, DataSet.Get_File_Name ()); pEntry->Set_Value(3, DataSet.Get_Projection()); pEntry->Set_Value(4, DataSet.Get_Count ()); pEntry->Set_Value(5, System.Get_Cellsize ()); pEntry->Set_Value(6, System.Get_NX ()); pEntry->Set_Value(7, System.Get_NY ()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMin()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMax()); pEntry->Add_Point(System.Get_XMax(), System.Get_YMax()); pEntry->Add_Point(System.Get_XMax(), System.Get_YMin()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMin()); if( !pCatalogue->Get_Projection().is_Okay() ) { pCatalogue->Get_Projection().Create(DataSet.Get_Projection(), SG_PROJ_FMT_WKT); } } } //----------------------------------------------------- return( pCatalogue->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Catalogues::CGDAL_Catalogues(void) { //----------------------------------------------------- Set_Name (_TL("Create Raster Catalogues from Directory")); Set_Author ("O.Conrad (c) 2015"); CSG_String Description; Description = _TW( "Creates raster catalogues from all raster files found in the selected directory. " "Catalogues are split according to the coordinate reference system used by the " "different raster files. Output are polygon layers that show the extent for each " "raster file in it. Each extent is attributed with the original file path and " "raster system properties.\n" "\n" "The \"GDAL Raster Import\" module imports grid data from various file formats using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format("\nGDAL %s:%s\n\n", _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str()); Description += _TW( "Following raster formats are currently supported:\n" "\n" ); for(int i=0; i\n", SG_Get_GDAL_Drivers().Get_Description(i).c_str(), SG_Get_GDAL_Drivers().Get_Name (i).c_str() ); } Description += "
    IDName
    %s%s
    "; Set_Description(Description); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL , "CATALOGUES" , _TL("Raster Catalogues"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "CATALOGUE_GCS" , _TL("Raster Catalogue"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Polygon ); Parameters.Add_Shapes( NULL , "CATALOGUE_UKN" , _TL("Raster Catalogue (unknown CRS)"), _TL(""), PARAMETER_OUTPUT_OPTIONAL, SHAPE_TYPE_Polygon ); Parameters.Add_FilePath( NULL , "DIRECTORY" , _TL("Directory"), _TL(""), NULL, NULL, false, true ); Parameters.Add_String( NULL , "EXTENSIONS" , _TL("Extensions"), _TL(""), "sgrd; tif" ); Parameters.Add_Choice( NULL , "OUTPUT" , _TL("Output"), _TL(""), CSG_String::Format("%s|%s|", _TL("one catalogue for each coordinate system"), _TL("one catalogue using geographic coordinates") ), 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGDAL_Catalogues::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "OUTPUT") ) { pParameters->Set_Enabled("CATALOGUES" , pParameter->asInt() == 0); pParameters->Set_Enabled("CATALOGUE_GCS", pParameter->asInt() == 1); pParameters->Set_Enabled("CATALOGUE_UKN", pParameter->asInt() == 1); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Catalogues::On_Execute(void) { //----------------------------------------------------- m_Directory = Parameters("DIRECTORY")->asString(); if( !SG_Dir_Exists(m_Directory) ) { return( false ); } //----------------------------------------------------- m_pCatalogues = Parameters("CATALOGUES")->asShapesList(); m_pCatalogues ->Del_Items(); //----------------------------------------------------- CSG_String_Tokenizer Extensions(Parameters("EXTENSIONS")->asString(), ";"); while( Extensions.Has_More_Tokens() ) { CSG_String Extension = Extensions.Get_Next_Token(); Extension.Trim(true); Extension.Trim(false); if( Extension.CmpNoCase("sgrd") == 0 ) // gdal ignores saga's grid header file, use grid data file instead! { Extension = "sdat"; } if( !Extension.is_Empty() ) { m_Extensions += Extension; } } if( m_Extensions.Get_Count() == 0 ) { m_Extensions += ""; } //----------------------------------------------------- int n = Add_Directory(m_Directory); m_Extensions.Clear(); if( n <= 0 ) { Message_Add(CSG_String::Format("\n%s\n", _TL("No raster files have been found in directory."))); return( false ); } Message_Add(CSG_String::Format("\n%s: %d\n", _TL("Number of raster files found in directory"), n), false); //----------------------------------------------------- if( Parameters("OUTPUT")->asInt() == 1 ) // one catalogue using geographic coordinates { Get_Catalogue(CSG_Projection("+proj=longlat +datum=WGS84", SG_PROJ_FMT_Proj4), Parameters("CATALOGUE_GCS")->asShapes(), _TL("Raster Catalogue") ); Get_Catalogue(CSG_Projection(), Parameters("CATALOGUE_UKN")->asShapes(), _TL("Raster Catalogue (unknown CRS)") ); for(int i=m_pCatalogues->Get_Count()-1; i>=0 && Process_Get_Okay(true); i--) { CSG_Shapes *pCatalogue = m_pCatalogues->asShapes(i); Add_To_Geographic(pCatalogue); delete(pCatalogue); m_pCatalogues->Del_Item(i); } } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_Shapes * CGDAL_Catalogues::Get_Catalogue(const CSG_Projection &Projection, CSG_Shapes *pCatalogue, const CSG_String &Name) { if( pCatalogue ) { pCatalogue->Create(SHAPE_TYPE_Polygon, Name); pCatalogue->Add_Field("ID" , SG_DATATYPE_Int ); pCatalogue->Add_Field("NAME" , SG_DATATYPE_String); pCatalogue->Add_Field("FILE_ABS", SG_DATATYPE_String); pCatalogue->Add_Field("FILE_REL", SG_DATATYPE_String); pCatalogue->Add_Field("CRS" , SG_DATATYPE_String); pCatalogue->Add_Field("PROJ4" , SG_DATATYPE_String); pCatalogue->Add_Field("BANDS" , SG_DATATYPE_Int ); pCatalogue->Add_Field("CELLSIZE", SG_DATATYPE_Double); pCatalogue->Add_Field("ROWS" , SG_DATATYPE_Int ); pCatalogue->Add_Field("COLUMNS" , SG_DATATYPE_Int ); pCatalogue->Get_Projection().Create(Projection); } return( pCatalogue ); } //--------------------------------------------------------- CSG_Shapes * CGDAL_Catalogues::Get_Catalogue(const CSG_Projection &Projection) { for(int i=0; iGet_Count(); i++) { if( Projection.is_Equal(m_pCatalogues->asShapes(i)->Get_Projection()) ) { return( m_pCatalogues->asShapes(i) ); } } //----------------------------------------------------- CSG_Shapes *pCatalogue = Get_Catalogue(Projection, SG_Create_Shapes(), CSG_String::Format("%s No.%d", _TL("Raster Catalogue"), 1 + m_pCatalogues->Get_Count())); m_pCatalogues->Add_Item(pCatalogue); return( pCatalogue ); } //--------------------------------------------------------- int CGDAL_Catalogues::Add_Directory(const CSG_String &Directory) { int n = 0; CSG_Strings List; //----------------------------------------------------- for(int iExtension=0; iExtensionAdd_Shape(); CSG_String Filename_Absolute = DataSet.Get_File_Name(); if( SG_File_Cmp_Extension(Filename_Absolute, SG_T("sdat")) ) { SG_File_Set_Extension(Filename_Absolute, "sgrd"); } CSG_String Filename_Relative = SG_File_Get_Path_Relative(m_Directory, Filename_Absolute); pEntry->Set_Value(0, pCatalogue->Get_Count ()); pEntry->Set_Value(1, Name ); pEntry->Set_Value(2, Filename_Absolute ); pEntry->Set_Value(3, Filename_Relative ); pEntry->Set_Value(4, DataSet.Get_Projection()); pEntry->Set_Value(5, Projection.Get_Proj4 ()); pEntry->Set_Value(6, DataSet.Get_Count ()); pEntry->Set_Value(7, System.Get_Cellsize ()); pEntry->Set_Value(8, System.Get_NX ()); pEntry->Set_Value(9, System.Get_NY ()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMin()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMax()); pEntry->Add_Point(System.Get_XMax(), System.Get_YMax()); pEntry->Add_Point(System.Get_XMax(), System.Get_YMin()); pEntry->Add_Point(System.Get_XMin(), System.Get_YMin()); return( 1 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Catalogues::Add_To_Geographic(CSG_Shapes *pCatalogue) { CSG_Shapes Catalogue, *pTarget = Parameters("CATALOGUE_UKN")->asShapes(); if( pCatalogue->Get_Projection().is_Okay() ) { bool bResult; SG_RUN_MODULE(bResult, "pj_proj4", 2, SG_MODULE_PARAMETER_SET("SOURCE" , pCatalogue) && SG_MODULE_PARAMETER_SET("TARGET" , &Catalogue) && SG_MODULE_PARAMETER_SET("CRS_PROJ4", Parameters("CATALOGUE_GCS")->asShapes()->Get_Projection().Get_Proj4()) ); if( bResult ) { pCatalogue = &Catalogue; pTarget = Parameters("CATALOGUE_GCS")->asShapes(); } } //----------------------------------------------------- if( pTarget ) { for(int i=0; iGet_Count(); i++) { pTarget->Add_Shape(pCatalogue->Get_Shape(i)); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/gdal_import_wms.cpp0000744000175000017500000005320112737416172023737 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_import_wms.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_import_wms.cpp // // // // Copyright (C) 2016 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gdal_import_wms.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGDAL_Import_WMS::CGDAL_Import_WMS(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import TMS Image")); Set_Author ("O.Conrad (c) 2016"); CSG_String Description; Description = _TW( "The \"Import TMS Image\" tool imports a map image from a Tile Mapping Service (TMS) using the " "\"Geospatial Data Abstraction Library\" (GDAL) by Frank Warmerdam. " "For more information have a look at the GDAL homepage:\n" " " " http://www.gdal.org\n" ); Description += CSG_String::Format("\nGDAL %s:%s\n\n", _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str()); Set_Description(Description); //----------------------------------------------------- pNode = Parameters.Add_Grid( NULL , "TARGET" , _TL("Target System"), _TL(""), PARAMETER_INPUT_OPTIONAL )->Get_Parent(); Parameters.Add_Grid( pNode , "TARGET_MAP" , _TL("Target Map"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Grid_Output( NULL , "MAP" , _TL("Map"), _TL("") ); //----------------------------------------------------- pNode = Parameters.Add_Choice( NULL , "SERVER" , _TL("Server"), _TL(""), CSG_String::Format("%s|%s|%s|%s|%s|%s|%s|%s|%s|", _TL("Open Street Map"), _TL("MapQuest"), _TL("Google Map"), _TL("Google Satellite"), _TL("Google Hybrid"), _TL("Google Terrain"), _TL("Google Terrain, Streets and Water"), _TL("ArcGIS MapServer Tiles"), _TL("user defined") ), 0 ); Parameters.Add_Value( pNode , "BLOCKSIZE" , _TL("Block Size"), _TL(""), PARAMETER_TYPE_Int, 256, 32, true ); Parameters.Add_String( pNode , "SERVER_USER" , _TL("Server"), _TL(""), "tile.openstreetmap.org/${z}/${x}/${y}.png" ); pNode = Parameters.Add_Value( NULL , "CACHE" , _TL("Cache"), _TL("Enable local disk cache. Allows for offline operation."), PARAMETER_TYPE_Bool, false ); Parameters.Add_FilePath( pNode , "CACHE_DIR" , _TL("Cache Directory"), _TL("If not specified the cache will be created in the current user's temporary directory."), NULL, NULL, false, true ); Parameters.Add_Value( NULL , "GRAYSCALE" , _TL("Gray Scale Image"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- pNode = Parameters.Add_Node(NULL, "TARGET_NODE", _TL("Target Grid"), _TL("")); Parameters.Add_Value(pNode, "XMIN", _TL("West" ), _TL(""), PARAMETER_TYPE_Double, -20037508.34, -20037508.34, true, 20037508.34, true); Parameters.Add_Value(pNode, "YMIN", _TL("South" ), _TL(""), PARAMETER_TYPE_Double, -20037508.34, -20037508.34, true, 20037508.34, true); Parameters.Add_Value(pNode, "XMAX", _TL("East" ), _TL(""), PARAMETER_TYPE_Double, 20037508.34, -20037508.34, true, 20037508.34, true); Parameters.Add_Value(pNode, "YMAX", _TL("North" ), _TL(""), PARAMETER_TYPE_Double, 20037508.34, -20037508.34, true, 20037508.34, true); Parameters.Add_Value(pNode, "NX" , _TL("Columns"), _TL(""), PARAMETER_TYPE_Int, 600, 1, true); Parameters.Add_Value(pNode, "NY" , _TL("Rows" ), _TL(""), PARAMETER_TYPE_Int, 600, 1, true); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- int CGDAL_Import_WMS::On_Parameter_Changed(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { CSG_Parameter *pXMin = pParameters->Get_Parameter("XMIN"); CSG_Parameter *pYMin = pParameters->Get_Parameter("YMIN"); CSG_Parameter *pXMax = pParameters->Get_Parameter("XMAX"); CSG_Parameter *pYMax = pParameters->Get_Parameter("YMAX"); CSG_Parameter *pNX = pParameters->Get_Parameter("NX" ); CSG_Parameter *pNY = pParameters->Get_Parameter("NY" ); if( !SG_STR_CMP(pParameter->Get_Identifier(), "NX") ) { double d = fabs(pXMax->asDouble() - pXMin->asDouble()) / pNX->asDouble(); pNY ->Set_Value(fabs(pYMax->asDouble() - pYMin->asDouble()) / d); pYMax->Set_Value(pYMin->asDouble() + d * pNY->asDouble()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "NY") ) { double d = fabs(pYMax->asDouble() - pYMin->asDouble()) / pNY->asDouble(); pNX ->Set_Value(fabs(pXMax->asDouble() - pXMin->asDouble()) / d); pXMax->Set_Value(pXMin->asDouble() + d * pNX->asDouble()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "XMIN") ) { double d = fabs(pYMax->asDouble() - pYMin->asDouble()) / pNY->asDouble(); pNX ->Set_Value(fabs(pXMax->asDouble() - pXMin->asDouble()) / d); pXMax->Set_Value(pXMin->asDouble() + d * pNX->asDouble()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "YMIN") ) { double d = fabs(pXMax->asDouble() - pXMin->asDouble()) / pNX->asDouble(); pNY ->Set_Value(fabs(pYMax->asDouble() - pYMin->asDouble()) / d); pYMax->Set_Value(pYMin->asDouble() + d * pNY->asDouble()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "XMAX") ) { double d = fabs(pYMax->asDouble() - pYMin->asDouble()) / pNY->asDouble(); pNX ->Set_Value(fabs(pXMax->asDouble() - pXMin->asDouble()) / d); pYMax->Set_Value(pYMax->asDouble() - d * pNY->asDouble()); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "YMAX") ) { double d = fabs(pXMax->asDouble() - pXMin->asDouble()) / pNX->asDouble(); pNY ->Set_Value(fabs(pYMax->asDouble() - pYMin->asDouble()) / d); pXMax->Set_Value(pXMax->asDouble() - d * pNX->asDouble()); } return( CSG_Module::On_Parameter_Changed(pParameters, pParameter) ); } //--------------------------------------------------------- int CGDAL_Import_WMS::On_Parameters_Enable(CSG_Parameters *pParameters, CSG_Parameter *pParameter) { if( !SG_STR_CMP(pParameter->Get_Identifier(), "TARGET") ) { pParameters->Set_Enabled("TARGET_MAP" , pParameter->asGrid() != NULL); pParameters->Set_Enabled("TARGET_NODE", pParameter->asGrid() == NULL); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "SERVER") ) { pParameters->Set_Enabled("SERVER_USER", pParameter->asInt() == 2); } if( !SG_STR_CMP(pParameter->Get_Identifier(), "CACHE") ) { pParameters->Set_Enabled("CACHE_DIR", pParameter->asBool()); } return( CSG_Module::On_Parameters_Enable(pParameters, pParameter) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import_WMS::On_Execute(void) { //----------------------------------------------------- CSG_Grid_System System; if( !Get_System(System, Parameters("TARGET")->asGrid()) ) { return( false ); } //----------------------------------------------------- CSG_Grid *pBands[3]; if( !Get_Bands(pBands, System) ) { Error_Set(_TL("failed to retrieve map image data")); return( false ); } //----------------------------------------------------- if( Parameters("TARGET")->asGrid() ) { Get_Projected(pBands, Parameters("TARGET")->asGrid()); } //----------------------------------------------------- return( Set_Image(pBands) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import_WMS::Get_System(CSG_Grid_System &System, CSG_Grid *pTarget) { //----------------------------------------------------- if( !pTarget ) { CSG_Rect Extent( Parameters("XMIN")->asDouble(), Parameters("YMIN")->asDouble(), Parameters("XMAX")->asDouble(), Parameters("YMAX")->asDouble() ); double Cellsize = Extent.Get_XRange() / Parameters("NX")->asDouble(); return( System.Assign(Cellsize, Extent) ); } //----------------------------------------------------- if( !pTarget->Get_Projection().is_Okay() ) { return( false ); } CSG_Shapes rTarget(SHAPE_TYPE_Point), rSource; rTarget.Get_Projection() = pTarget->Get_Projection(); CSG_Rect Extent = pTarget->Get_Extent(true); rTarget.Add_Shape()->Add_Point(Extent.Get_XMin (), Extent.Get_YMin ()); rTarget.Add_Shape()->Add_Point(Extent.Get_XMin (), Extent.Get_YCenter()); rTarget.Add_Shape()->Add_Point(Extent.Get_XMin (), Extent.Get_YMax ()); rTarget.Add_Shape()->Add_Point(Extent.Get_XCenter(), Extent.Get_YMax ()); rTarget.Add_Shape()->Add_Point(Extent.Get_XMax (), Extent.Get_YMax ()); rTarget.Add_Shape()->Add_Point(Extent.Get_XMax (), Extent.Get_YCenter()); rTarget.Add_Shape()->Add_Point(Extent.Get_XMax (), Extent.Get_YMin ()); rTarget.Add_Shape()->Add_Point(Extent.Get_XCenter(), Extent.Get_YMin ()); //----------------------------------------------------- CSG_Module *pModule = SG_Get_Module_Library_Manager().Get_Module("pj_proj4", 2); // Coordinate Transformation (Shapes); if( !pModule ) { return( false ); } pModule->Settings_Push(); if( SG_MODULE_PARAMETER_SET("CRS_PROJ4" , SG_T("+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +k=1.0")) && SG_MODULE_PARAMETER_SET("SOURCE" , &rTarget) && SG_MODULE_PARAMETER_SET("TARGET" , &rSource) && SG_MODULE_PARAMETER_SET("PRECISE" , true) && pModule->Execute() ) { Extent = rSource.Get_Extent(); double Cellsize = Extent.Get_XRange() / pTarget->Get_NX() < Extent.Get_YRange() / pTarget->Get_NY() ? Extent.Get_XRange() / pTarget->Get_NX() : Extent.Get_YRange() / pTarget->Get_NY(); System.Assign(Cellsize, Extent); pModule->Settings_Pop(); return( true ); } pModule->Settings_Pop(); return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import_WMS::Get_Projected(CSG_Grid *pBands[3], CSG_Grid *pTarget) { CSG_Module *pModule = SG_Get_Module_Library_Manager().Get_Module("pj_proj4", 3); // Coordinate Transformation (Grid List); if( !pModule ) { return( false ); } //----------------------------------------------------- pModule->Settings_Push(); if( SG_MODULE_PARAMETER_SET("CRS_PROJ4" , pTarget->Get_Projection().Get_Proj4()) && SG_MODULE_PARAMETER_SET("RESAMPLING", 3) && SG_MODULE_PARAMLIST_ADD("SOURCE" , pBands[2]) && SG_MODULE_PARAMLIST_ADD("SOURCE" , pBands[1]) && SG_MODULE_PARAMLIST_ADD("SOURCE" , pBands[0]) && pModule->Get_Parameters("TARGET")->Get_Parameter("DEFINITION")->Set_Value(1) && pModule->Get_Parameters("TARGET")->Get_Parameter("SYSTEM")->asGrid_System()->Assign(pTarget->Get_System()) && pModule->Execute() ) { CSG_Parameter_Grid_List *pGrids = pModule->Get_Parameters()->Get_Parameter("GRIDS")->asGridList(); delete(pBands[0]); pBands[0] = pGrids->asGrid(0); delete(pBands[1]); pBands[1] = pGrids->asGrid(1); delete(pBands[2]); pBands[2] = pGrids->asGrid(2); pModule->Settings_Pop(); return( true ); } pModule->Settings_Pop(); return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import_WMS::Set_Image(CSG_Grid *pBands[3]) { //----------------------------------------------------- CSG_Grid *pMap = Parameters("TARGET_MAP")->asGrid(); if( !pMap ) { pMap = SG_Create_Grid(); } if( !pMap->Get_System().is_Equal(pBands[0]->Get_System()) ) { pMap->Create(pBands[0]->Get_System(), SG_DATATYPE_Int); } pMap->Set_Name(_TL("Open Street Map")); pMap->Get_Projection() = pBands[0]->Get_Projection(); //----------------------------------------------------- bool bGrayscale = Parameters("GRAYSCALE")->asBool(); #pragma omp parallel for for(int y=0; yGet_NY(); y++) for(int x=0; xGet_NX(); x++) { if( bGrayscale ) { double z = (pBands[0]->asInt(x, y) + pBands[1]->asInt(x, y) + pBands[2]->asInt(x, y)) / 3.0; pMap->Set_Value(x, y, SG_GET_RGB(z, z, z)); } else { pMap->Set_Value(x, y, SG_GET_RGB(pBands[0]->asInt(x, y), pBands[1]->asInt(x, y), pBands[2]->asInt(x, y))); } } delete(pBands[0]); delete(pBands[1]); delete(pBands[2]); Parameters("MAP")->Set_Value(pMap); DataObject_Add(pMap); DataObject_Set_Parameter(pMap, "COLORS_TYPE", 6); // RGB Coded Values return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGDAL_Import_WMS::Get_Bands(CSG_Grid *pBands[3], const CSG_Grid_System &System) { //----------------------------------------------------- CSG_GDAL_DataSet DataSet; if( DataSet.Open_Read(Get_Request(), System) == false || DataSet.Get_Count() != 3 ) { return( false ); } Message_Add("\n", false); Message_Add(CSG_String::Format("\n%s: %s", _TL("Driver" ), DataSet.Get_DriverID().c_str()), false); Message_Add(CSG_String::Format("\n%s: %d", _TL("Bands" ), DataSet.Get_Count() ), false); Message_Add(CSG_String::Format("\n%s: %d", _TL("Rows" ), DataSet.Get_NX() ), false); Message_Add(CSG_String::Format("\n%s: %d", _TL("Columns"), DataSet.Get_NY() ), false); Message_Add("\n", false); //----------------------------------------------------- SG_UI_Progress_Lock(true); pBands[0] = DataSet.Read(0); pBands[1] = DataSet.Read(1); pBands[2] = DataSet.Read(2); SG_UI_Progress_Lock(false); //----------------------------------------------------- if( !pBands[0] || !pBands[1] || !pBands[2] ) { if( pBands[0] ) delete(pBands[0]); if( pBands[1] ) delete(pBands[1]); if( pBands[2] ) delete(pBands[2]); return( false ); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSG_String CGDAL_Import_WMS::Get_Request(void) { CSG_String Server, Projection = "EPSG:3857"; switch( Parameters("SERVER")->asInt() ) { default: Server = "tile.openstreetmap.org/${z}/${x}/${y}.png" ; break; // Open Street Map case 1: Server = "otile1.mqcdn.com/tiles/1.0.0/osm/${z}/${x}/${y}.png" ; break; // MapQuest case 2: Server = "mt.google.com/vt/lyrs=m&x=${x}&y=${y}&z=${z}" ; break; // Google Map case 3: Server = "mt.google.com/vt/lyrs=s&x=${x}&y=${y}&z=${z}" ; break; // Google Satellite case 4: Server = "mt.google.com/vt/lyrs=y&x=${x}&y=${y}&z=${z}" ; break; // Google Hybrid case 5: Server = "mt.google.com/vt/lyrs=t&x=${x}&y=${y}&z=${z}" ; break; // Google Terrain case 6: Server = "mt.google.com/vt/lyrs=p&x=${x}&y=${y}&z=${z}" ; break; // Google Terrain, Streets and Water case 7: Server = "services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/${z}/${y}/${x}"; break; // ArcGIS MapServer Tiles case 8: Server = Parameters("SERVER_USER")->asString() ; break; // user defined // case x: Server = "s3.amazonaws.com/com.modestmaps.bluemarble/${z}-r${y}-c${x}.jpg" ; break; // Blue Marble } //----------------------------------------------------- CSG_MetaData XML, *pEntry; XML.Set_Name("GDAL_WMS"); //----------------------------------------------------- pEntry = XML.Add_Child("Service"); pEntry->Add_Property("name", "TMS"); pEntry->Add_Child("ServerUrl" , "http://" + Server); //----------------------------------------------------- pEntry = XML.Add_Child("DataWindow"); // Define size and extents of the data. (required, except for TiledWMS and VirtualEarth) pEntry->Add_Child("UpperLeftX" , -20037508.34); // X (longitude) coordinate of upper-left corner. (optional, defaults to -180.0, except for VirtualEarth) pEntry->Add_Child("UpperLeftY" , 20037508.34); // Y (latitude) coordinate of upper-left corner. (optional, defaults to 90.0, except for VirtualEarth) pEntry->Add_Child("LowerRightX", 20037508.34); // X (longitude) coordinate of lower-right corner. (optional, defaults to 180.0, except for VirtualEarth) pEntry->Add_Child("LowerRightY", -20037508.34); // Y (latitude) coordinate of lower-right corner. (optional, defaults to -90.0, except for VirtualEarth) pEntry->Add_Child("TileLevel" , 18); // Tile level at highest resolution. (tiled image sources only, optional, defaults to 0) pEntry->Add_Child("TileCountX" , 1); // Can be used to define image size, SizeX = TileCountX * BlockSizeX * 2TileLevel. (tiled image sources only, optional, defaults to 0) pEntry->Add_Child("TileCountY" , 1); // Can be used to define image size, SizeY = TileCountY * BlockSizeY * 2TileLevel. (tiled image sources only, optional, defaults to 0) pEntry->Add_Child("YOrigin" , "top"); // Can be used to define the position of the Y origin with respect to the tile grid. Possible values are 'top', 'bottom', and 'default', where the default behavior is mini-driver-specific. (TMS mini-driver only, optional, defaults to 'bottom' for TMS) //----------------------------------------------------- if( !Projection.is_Empty() ) { pEntry = XML.Add_Child("Projection", Projection); // Image projection (optional, defaults to value reported by mini-driver or EPSG:4326) } pEntry = XML.Add_Child("BandsCount", 3); // Number of bands/channels, 1 for grayscale data, 3 for RGB, 4 for RGBA. (optional, defaults to 3) int Blocksize = Parameters("BLOCKSIZE")->asInt(); pEntry = XML.Add_Child("BlockSizeX", Blocksize); // Block size in pixels. (optional, defaults to 1024, except for VirtualEarth) pEntry = XML.Add_Child("BlockSizeY", Blocksize); //----------------------------------------------------- if( Parameters("CACHE")->asBool() ) { pEntry = XML.Add_Child("Cache"); CSG_String Path = Parameters("CACHE_DIR")->asString(); if( !SG_Dir_Exists(Path) ) { Path = SG_Dir_Get_Temp(); } pEntry->Add_Child("Path", SG_File_Make_Path(Path, SG_T("gdalwmscache"))); } //----------------------------------------------------- return( XML.asText(2) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_gdal/MLB_Interface.cpp0000744000175000017500000001266412737416172023152 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: MLB_Interface.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Grid_IO_GDAL // // // //-------------------------------------------------------// // // // MLB_Interface.cpp // // // // Copyright (C) 2003 by // // Author // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: author@email.de // // // // contact: Author // // Sesame Street 7 // // 12345 Metropolis // // Nirwana // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // The Module Link Library Interface // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- // 1. Include the appropriate SAGA-API header... #include "gdal_driver.h" //--------------------------------------------------------- // 2. Place general module library informations here... CSG_String Get_Info(int i) { switch( i ) { case MLB_INFO_Name: default: return( _TL("GDAL/OGR") ); case MLB_INFO_Category: return( _TL("Import/Export") ); case MLB_INFO_Author: return( _TL("SAGA User Group Associaton (c) 2008" )); case MLB_INFO_Description: return( CSG_String::Format(SG_T("%s\n%s %s\n%s: %s"), _TL("Interface to Frank Warmerdam's Geospatial Data Abstraction Library (GDAL)."), _TL("Version"), SG_Get_GDAL_Drivers().Get_Version().c_str(), _TL("Homepage"), SG_T("www.gdal.org\n") )); case MLB_INFO_Version: return( SG_T("2.0") ); case MLB_INFO_Menu_Path: return( _TL("File") ); } } //--------------------------------------------------------- // 3. Include the headers of your modules here... #include "gdal_import.h" #include "gdal_export.h" #include "gdal_export_geotiff.h" #include "gdal_import_netcdf.h" #include "gdal_import_wms.h" #include "gdal_catalogue.h" #include "ogr_import.h" #include "ogr_export.h" #include "ogr_export_kml.h" //--------------------------------------------------------- // 4. Allow your modules to be created here... CSG_Module * Create_Module(int i) { switch( i ) { case 0: return( new CGDAL_Import ); case 1: return( new CGDAL_Export ); case 2: return( new CGDAL_Export_GeoTIFF ); case 7: return( new CGDAL_Catalogue ); case 8: return( new CGDAL_Catalogues ); case 3: return( new COGR_Import ); case 4: return( new COGR_Export ); case 5: return( new COGR_Export_KML ); case 6: return( SG_Get_GDAL_Drivers().Get_Driver("netCDF") ? new CGDAL_Import_NetCDF : MLB_INTERFACE_SKIP_MODULE ); case 9: return( new CGDAL_Import_WMS ); //----------------------------------------------------- case 10: return( NULL ); default: return( MLB_INTERFACE_SKIP_MODULE ); } return( NULL ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- //{{AFX_SAGA MLB_INTERFACE //}}AFX_SAGA saga-2.3.1/src/modules/io/io_gdal/gdal_export.h0000744000175000017500000001002112737416172022516 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gdal_export.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library // // // // io_gdal // // // //-------------------------------------------------------// // // // gdal_export.h // // // // Copyright (C) 2007 O. Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.de // // // // contact: Olaf Conrad // // Bundesstr. 55 // // D-20146 Hamburg // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__gdal_export_H #define HEADER_INCLUDED__gdal_export_H //--------------------------------------------------------- #include "gdal_driver.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class io_gdal_EXPORT CGDAL_Export : public CSG_Module_Grid { public: CGDAL_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Grid|Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__gdal_export_H saga-2.3.1/src/modules/io/io_shapes/0000775000175000017500000000000012737740005020413 5ustar00oconradoconrad00000000000000saga-2.3.1/src/modules/io/io_shapes/pointcloud_from_file.h0000744000175000017500000001025412737416174024776 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pointcloud_from_file.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // pointcloud_from_file.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__pointcloud_from_file_H #define HEADER_INCLUDED__pointcloud_from_file_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPointCloud_From_File : public CSG_Module { public: CPointCloud_From_File(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: bool Read_Shapefile (const CSG_String &fName); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__pointcloud_from_file_H saga-2.3.1/src/modules/io/io_shapes/surfer_bln.h0000744000175000017500000001140512737416174022734 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: surfer_bln.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // Surfer_BLN.h // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Surfer_BLN_H #define HEADER_INCLUDED__Surfer_BLN_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSurfer_BLN_Import : public CSG_Module { public: CSurfer_BLN_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSurfer_BLN_Export : public CSG_Module { public: CSurfer_BLN_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Surfer_BLN_H saga-2.3.1/src/modules/io/io_shapes/wasp_map.h0000744000175000017500000001101512737416174022377 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wasp_map.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // WASP_MAP.h // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__WASP_MAP_H #define HEADER_INCLUDED__WASP_MAP_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWASP_MAP_Export : public CSG_Module { public: CWASP_MAP_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWASP_MAP_Import : public CSG_Module { public: CWASP_MAP_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__WASP_MAP_H saga-2.3.1/src/modules/io/io_shapes/citygml_import.h0000744000175000017500000001252212737416174023636 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: citygml_import.h 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // citygml_import.h // // // // Copyright (C) 2014 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__citygml_import_H #define HEADER_INCLUDED__citygml_import_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CCityGML_Import : public CSG_Module { public: ////// public members and functions: ////////////// CCityGML_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: /// protected members and functions: /////////// virtual bool On_Execute (void); private: ///// private members and functions: ///////////// bool Get_Buildings (const CSG_String &File, CSG_Shapes *pPolygons, bool bParts); bool Get_Buildings (const CSG_String &File, CSG_Shapes *pPolygons); bool Add_Buildings (CSG_Shapes *pBuildings, CSG_Shapes *pAdd); bool Has_BuildingParts (const CSG_MetaData &GML); bool Add_BuildingParts (const CSG_MetaData &GML, CSG_MetaData &GML_Parts); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__citygml_import_H saga-2.3.1/src/modules/io/io_shapes/gstat.h0000744000175000017500000001120612737416174021714 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gstat.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO // // // //-------------------------------------------------------// // // // Gstat.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GSTAT_H #define HEADER_INCLUDED__GSTAT_H //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGStat_Export : public CSG_Module { public: CGStat_Export(void); virtual ~CGStat_Export(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Export") ); } protected: virtual bool On_Execute(void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGStat_Import : public CSG_Module { public: CGStat_Import(void); virtual ~CGStat_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Import") ); } protected: virtual bool On_Execute(void); private: bool Stream_Find_NextWhiteChar (FILE *Stream); bool Stream_Get_StringInQuota (FILE *Stream, CSG_String &String); }; #endif // #ifndef HEADER_INCLUDED__GSTAT_H saga-2.3.1/src/modules/io/io_shapes/generate.h0000744000175000017500000001070212737416174022364 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: generate.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO // // // //-------------------------------------------------------// // // // Generate.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GENERATE_H #define HEADER_INCLUDED__GENERATE_H //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGenerate_Export : public CSG_Module { public: CGenerate_Export(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Export") ); } protected: virtual bool On_Execute(void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GENERATE_H saga-2.3.1/src/modules/io/io_shapes/gstat.cpp0000744000175000017500000003164312737416174022256 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gstat.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO // // // //-------------------------------------------------------// // // // Gstat.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include #include "gstat.h" /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGStat_Export::CGStat_Export(void) { CSG_Parameter *pNode_0; //----------------------------------------------------- Set_Name(_TL("Export GStat Shapes")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description( _TL("GStat shapes format export.") ); //----------------------------------------------------- pNode_0 = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); pNode_0 = Parameters.Add_FilePath( NULL , "FILENAME", _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"), _TL("GStat Files (*.gstat)") , SG_T("*.gstat"), _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("All Files") , SG_T("*.*") ), NULL, true ); } //--------------------------------------------------------- CGStat_Export::~CGStat_Export(void) {} //--------------------------------------------------------- bool CGStat_Export::On_Execute(void) { int iShape, iPart, iPoint, iField; FILE *Stream; TSG_Point Point; CSG_Shape *pShape; CSG_Shapes *pShapes; CSG_String fName; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); fName = Parameters("FILENAME") ->asString(); //----------------------------------------------------- if( (Stream = fopen(fName.b_str(), "w")) != NULL ) { switch( pShapes->Get_Type() ) { //------------------------------------------------- case SHAPE_TYPE_Point: fprintf(Stream, "%s (created by DiGeM 2.0)\n%d\nX-Coordinate\nY-Coordinate", Parameters("FILENAME")->asString(), pShapes->Get_Field_Count() + 2 ); for(iField=0; iFieldGet_Field_Count(); iField++) { if( pShapes->Get_Field_Type(iField) == SG_DATATYPE_String ) { fprintf(Stream, "\n%%%s", pShapes->Get_Field_Name(iField) ); } else { fprintf(Stream, "\n%s", pShapes->Get_Field_Name(iField) ); } } for(iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { pShape = pShapes->Get_Shape(iShape); for(iPart=0; iPartGet_Part_Count(); iPart++) { for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Point = pShape->Get_Point(iPoint, iPart); fprintf(Stream, "\n%f\t%f", Point.x, Point.y); for(iField=0; iFieldGet_Field_Count(); iField++) { if( pShapes->Get_Field_Type(iField) == SG_DATATYPE_String ) { fprintf(Stream, "\t\"%s\"", pShape->asString(iField) ); } else { fprintf(Stream, "\t%f", pShape->asDouble(iField) ); } } } } } break; //------------------------------------------------- case SHAPE_TYPE_Line: fprintf(Stream, "EXP %s\nARC ", pShapes->Get_Name()); for(iShape=0; iShapeGet_Count() && Set_Progress(iShape,pShapes->Get_Count()); iShape++) { pShape = pShapes->Get_Shape(iShape); for(iPart=0; iPartGet_Part_Count(); iPart++) { //I_ok... fprintf(Stream, "%d ", iShape + 1); // dummy_I dummy_I dummy_I dummy_I dummy_I... fprintf(Stream, "1 2 3 4 5 "); // I_np... fprintf(Stream, "%d ", pShape->Get_Point_Count(iPart)); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Point = pShape->Get_Point(iPoint, iPart); fprintf(Stream, "%f %f ", Point.x, Point.y); } } } break; //------------------------------------------------- case SHAPE_TYPE_Polygon: fprintf(Stream, "EXP %s\nARC ", pShapes->Get_Name()); for(iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { pShape = pShapes->Get_Shape(iShape); for(iPart=0; iPartGet_Part_Count(); iPart++) { //I_ok... fprintf(Stream, "%d ", iShape + 1); // dummy_I dummy_I dummy_I dummy_I dummy_I... fprintf(Stream, "1 2 3 4 5 "); // I_np... fprintf(Stream, "%d ", pShape->Get_Point_Count(iPart)); for(iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { Point = pShape->Get_Point(iPoint, iPart); fprintf(Stream, "%f %f ", Point.x, Point.y); } } } break; } fclose(Stream); } return( true ); } /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGStat_Import::CGStat_Import(void) { CSG_Parameter *pNode_0; //----------------------------------------------------- Set_Name(_TL("Import GStat Shapes")); Set_Author (SG_T("(c) 2003 by O.Conrad")); Set_Description( _TL("GStat shapes format import.") ); //----------------------------------------------------- pNode_0 = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT ); pNode_0 = Parameters.Add_FilePath( NULL , "FILENAME", _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"), _TL("GStat Files (*.gstat)") , SG_T("*.gstat"), _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("All Files") , SG_T("*.*") ), NULL, false ); } //--------------------------------------------------------- CGStat_Import::~CGStat_Import(void) {} //--------------------------------------------------------- bool CGStat_Import::On_Execute(void) { char c[3]; int i, nFields, fLength; double x, y, Value; FILE *Stream; CSG_String s, fName; CSG_Shape *pShape; CSG_Shapes *pShapes; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); fName = Parameters("FILENAME") ->asString(); //----------------------------------------------------- if( (Stream = fopen(fName.b_str(), "rb")) != NULL ) { fseek(Stream, 0, SEEK_END); fLength = ftell(Stream); fseek(Stream, 0, SEEK_SET); if( fLength > 0 && SG_Read_Line(Stream, s) ) { //--------------------------------------------- // Point... if( s.CmpNoCase(SG_T("EXP")) ) { pShapes->Create(SHAPE_TYPE_Point, Parameters("FILENAME")->asString()); //----------------------------------------- // Load Header... // Field Count... fscanf(Stream, "%d", &nFields); SG_Read_Line(Stream, s); // zur naexten Zeile... // Fields... for(i=0; iAdd_Field(s, SG_DATATYPE_String); } else { pShapes->Add_Field(s, SG_DATATYPE_Double); } } } //----------------------------------------- if( nFields < 2 ) { Message_Dlg(_TL("Invalid File Format."), _TL("Loading GSTAT-File")); } else { while( !feof(Stream) && Set_Progress(ftell(Stream), fLength) ) { fscanf(Stream, "%lf%lf", &x, &y); if( !feof(Stream) ) { pShape = pShapes->Add_Shape(); pShape->Add_Point(x, y); pShape->Set_Value(0, x); pShape->Set_Value(1, y); for(i=2; iGet_Field_Name(i), SG_T("[ignore]")) ) { Stream_Find_NextWhiteChar(Stream); pShape->Set_Value(i, SG_T("NA")); } else if( pShapes->Get_Field_Name(i)[0] == '%' ) { Stream_Get_StringInQuota(Stream, s); pShape->Set_Value(i, s); } else { fscanf(Stream, "%lf", &Value); pShape->Set_Value(i, Value); } } SG_Read_Line(Stream, s); } } } } //--------------------------------------------- // Line, Polygon... else { fread(c, 3, sizeof(char), Stream); if( !strncmp(c, "ARC", 3) ) { pShapes->Create(SHAPE_TYPE_Line, Parameters("FILENAME")->asString()); pShapes->Add_Field("VALUE", SG_DATATYPE_Double); //--------------------------------------------- while( !feof(Stream) && Set_Progress(ftell(Stream), fLength) ) { fscanf(Stream, "%lf", &Value); // i_ok... fscanf(Stream, "%d%d%d%d%d", &i, &i, &i, &i, &i); // dummy 1..5 fscanf(Stream, "%d", &nFields); if( nFields > 0 ) { pShape = NULL; for(i=0; iAdd_Shape(); pShape->Set_Value(0, Value); } pShape->Add_Point(x, y); } else { break; } } } } } } } fclose(Stream); } return( pShapes->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // Import - Helper // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGStat_Import::Stream_Find_NextWhiteChar(FILE *Stream) { char c; if( Stream ) { do { c = fgetc(Stream); } while( !feof(Stream) && c > 32 ); return( true ); } return( false ); } //--------------------------------------------------------- bool CGStat_Import::Stream_Get_StringInQuota(FILE *Stream, CSG_String &String) { char c; String.Clear(); if( Stream ) { do { c = fgetc(Stream); } while( !feof(Stream) && c != '\"' ); while( !feof(Stream) && (c = fgetc(Stream)) != '\"' ) { String.Append(c); } return( true ); } return( false ); } saga-2.3.1/src/modules/io/io_shapes/surfer_bln.cpp0000744000175000017500000002644212737416174023276 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: surfer_bln.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // Surfer_BLN.cpp // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "surfer_bln.h" /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSurfer_BLN_Import::CSurfer_BLN_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import Surfer Blanking Files")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "Import polygons/polylines from Golden Software's Surfer Blanking File format.\n" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_Table( NULL , "TABLE" , _TL("Look up table (Points)"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), _TL("Surfer Blanking Files (*.bln)|*.bln|All Files|*.*") ); pNode = Parameters.Add_Choice( NULL , "TYPE" , _TL("Shape Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("points"), _TL("lines"), _TL("polygons") ), 1 ); } //--------------------------------------------------------- bool CSurfer_BLN_Import::On_Execute(void) { bool bOk; int ID, Flag, iPoint, nPoints; double x, y; FILE *Stream; TSG_Shape_Type Type; CSG_String FileName, sLine, sName, sDesc, sTemp; CSG_Table_Record *pRecord; CSG_Table *pTable; CSG_Shape *pShape; CSG_Shapes *pShapes; //----------------------------------------------------- pShapes = Parameters("SHAPES") ->asShapes(); pTable = Parameters("TABLE") ->asTable(); FileName = Parameters("FILE") ->asString(); switch( Parameters("TYPE")->asInt() ) { case 0: Type = SHAPE_TYPE_Point; break; case 1: default: Type = SHAPE_TYPE_Line; break; case 2: Type = SHAPE_TYPE_Polygon; break; } //----------------------------------------------------- if( (Stream = fopen(FileName.b_str(), "r")) != NULL ) { bOk = true; ID = 0; if( pShapes->Get_Type() != SHAPE_TYPE_Undefined && pShapes->Get_Type() != Type ) { pShapes = SG_Create_Shapes(Type, SG_File_Get_Name(FileName, false)); Parameters("SHAPES")->Set_Value(pShapes); DataObject_Add(pShapes); } else { pShapes->Create(Type, SG_File_Get_Name(FileName, false)); } if( Type == SHAPE_TYPE_Point ) { if( pTable == NULL ) { pTable = SG_Create_Table(); Parameters("TABLE")->Set_Value(pTable); } else { pTable->Destroy(); } pTable ->Add_Field("ID" , SG_DATATYPE_Int); pTable ->Add_Field("FLAG" , SG_DATATYPE_Int); pTable ->Add_Field("NAME" , SG_DATATYPE_String); pTable ->Add_Field("DESC" , SG_DATATYPE_String); pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("ID_LUT" , SG_DATATYPE_Int); pShapes->Add_Field("Z" , SG_DATATYPE_Double); } else { pShapes->Add_Field("ID" , SG_DATATYPE_Int); pShapes->Add_Field("FLAG" , SG_DATATYPE_Int); pShapes->Add_Field("NAME" , SG_DATATYPE_String); pShapes->Add_Field("DESC" , SG_DATATYPE_String); } //------------------------------------------------- while( bOk && SG_Read_Line(Stream, sLine) && sLine.BeforeFirst(',').asInt(nPoints) && nPoints > 0 && Process_Get_Okay(true) ) { Process_Set_Text(CSG_String::Format(SG_T("%d. %s"), ++ID, _TL("shape in process"))); sTemp = sLine.AfterFirst (','); sLine = sTemp; Flag = sLine.BeforeFirst(',').asInt(); sTemp = sLine.AfterFirst (','); sLine = sTemp; sTemp = sLine.BeforeFirst(','); sName = sTemp.AfterFirst('\"').BeforeLast('\"'); sTemp = sLine.AfterFirst (','); sLine = sTemp; sTemp = sLine.BeforeFirst(','); sDesc = sTemp.AfterFirst('\"').BeforeLast('\"'); if( Type == SHAPE_TYPE_Point ) { pRecord = pTable->Add_Record(); pRecord->Set_Value(0, ID); pRecord->Set_Value(1, Flag); pRecord->Set_Value(2, sName); pRecord->Set_Value(3, sDesc); for(iPoint=0; iPointAdd_Shape(); pShape->Set_Value(0, iPoint + 1); pShape->Set_Value(1, ID); pShape->Set_Value(2, sLine.AfterLast (',').asDouble()); x = sLine.BeforeFirst(',').asDouble(); y = sLine.AfterFirst (',').asDouble(); pShape->Add_Point(x, y); } } } else { pShape = pShapes->Add_Shape(); pShape->Set_Value(0, ID); pShape->Set_Value(1, Flag); pShape->Set_Value(2, sName); pShape->Set_Value(3, sDesc); for(iPoint=0; iPointAdd_Point(x, y); } } } } fclose(Stream); } //----------------------------------------------------- if( pShapes->is_Valid() && pShapes->Get_Count() > 0 ) { return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSurfer_BLN_Export::CSurfer_BLN_Export(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export Surfer Blanking File")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "Export shapes to Golden Software's Surfer Blanking File format.\n" )); //----------------------------------------------------- // 2. Parameters... CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field(pNode, "NAME", _TL("Name" ), _TL(""), true); Parameters.Add_Table_Field(pNode, "DESC", _TL("Description"), _TL(""), true); Parameters.Add_Table_Field(pNode, "ZVAL", _TL("z values" ), _TL(""), true); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|*bln|%s|*.*"), _TL("Surfer Blanking Files (*.bln)"), _TL("All Files") ), NULL, true ); } //--------------------------------------------------------- bool CSurfer_BLN_Export::On_Execute(void) { //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(Parameters("FILE")->asString(), SG_FILE_W) ) { return( false ); } CSG_Shapes *pShapes = Parameters("SHAPES")->asShapes(); if( !pShapes->is_Valid() || pShapes->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- int iName = Parameters("BNAME" )->asBool() ? Parameters("NAME")->asInt() : -1; int iDesc = Parameters("BDESC" )->asBool() ? Parameters("DESC")->asInt() : -1; int iZVal = Parameters("BZVAL" )->asBool() ? Parameters("ZVAL")->asInt() : -1; int Flag = 1; //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { Stream.Printf(SG_T("%d,%d"), pShape->Get_Point_Count(iPart), Flag); if( iName >= 0 ) { Stream.Printf(SG_T(",\"%s\""), pShape->asString(iName)); } if( iDesc >= 0 ) { Stream.Printf(SG_T(",\"%s\""), pShape->asString(iDesc)); } Stream.Printf(SG_T("\n")); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); if( iZVal >= 0 ) { Stream.Printf(SG_T("%f,%f,%f\n"), p.x, p.y, pShape->asDouble(iZVal)); } else { Stream.Printf(SG_T("%f,%f\n" ), p.x, p.y); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes/wktb.cpp0000744000175000017500000002502512737416174022100 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wktb.cpp 911 2011-02-14 16:38:15Z reklov_w $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // wktb.cpp // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "wktb.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define SEPARATOR SG_T('|') /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWKT_Import::CWKT_Import(void) { Set_Name (_TL("Import Simple Features from Well Known Text")); Set_Author (SG_T("O. Conrad (c) 2012")); Set_Description (_TW( "Imports vector data from 'well known text' (WKT) simple features format.\n" "This import tool assumes that all features in a file are of the same type.\n" "\n" "References:\n" "Open Geospatial Consortium\n" )); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("WKT Import"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("Well Known Text Format (*.wkt)") , SG_T("*.wkt"), _TL("All Files") , SG_T("*.*") ), NULL, false, false, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWKT_Import::On_Execute(void) { //----------------------------------------------------- CSG_Strings Files; if( !Parameters("FILE")->asFilePath()->Get_FilePaths(Files) || Files.Get_Count() == 0 ) { return( false ); } //----------------------------------------------------- CSG_Parameter_Shapes_List *pList = Parameters("SHAPES")->asShapesList(); pList->Del_Items(); //----------------------------------------------------- for(int iFile=0; iFile 0 ) { WKT = WKT.AfterFirst(SEPARATOR); CSG_Shape *pShape = Shapes.Add_Shape(); pShape->Set_Value(0, Shapes.Get_Count()); if( !CSG_Shapes_OGIS_Converter::from_WKText(WKT.BeforeFirst(SEPARATOR), pShape) ) { Shapes.Del_Shape(Shapes.Get_Count() - 1); } } if( Shapes.is_Valid() && Shapes.Get_Count() > 0 ) { Shapes.Set_Name(SG_File_Get_Name(Files[iFile], false)); pList->Add_Item(SG_Create_Shapes(Shapes)); } } } return( pList->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define IS_OF_TYPE(t, t_shape, t_vertex) { CSG_String Type(CSG_Shapes_OGIS_Converter::Type_asWKText(t)); Type.Make_Upper(); if( WKT.Find(Type) >= 0 ) {\ Shapes.Create(t_shape, NULL, NULL, t_vertex);\ Shapes.Add_Field("OID", SG_DATATYPE_Int);\ WKT.Replace(Type, SEPARATOR + Type);\ return( true );\ } } //--------------------------------------------------------- bool CWKT_Import::Get_Type(CSG_String &WKT, CSG_Shapes &Shapes) { Shapes.Destroy(); WKT.Make_Upper(); IS_OF_TYPE(SG_OGIS_TYPE_MultiPointZM , SHAPE_TYPE_Points , SG_VERTEX_TYPE_XYZM); IS_OF_TYPE(SG_OGIS_TYPE_MultiPointZ , SHAPE_TYPE_Points , SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_MultiPointM , SHAPE_TYPE_Points , SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_MultiPoint , SHAPE_TYPE_Points , SG_VERTEX_TYPE_XY ); IS_OF_TYPE(SG_OGIS_TYPE_MultiLineStringZM, SHAPE_TYPE_Line , SG_VERTEX_TYPE_XYZM); IS_OF_TYPE(SG_OGIS_TYPE_MultiLineStringZ , SHAPE_TYPE_Line , SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_MultiLineStringM , SHAPE_TYPE_Line , SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_MultiLineString , SHAPE_TYPE_Line , SG_VERTEX_TYPE_XY ); IS_OF_TYPE(SG_OGIS_TYPE_MultiPolygonZM , SHAPE_TYPE_Polygon, SG_VERTEX_TYPE_XYZM); IS_OF_TYPE(SG_OGIS_TYPE_MultiPolygonZ , SHAPE_TYPE_Polygon, SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_MultiPolygonM , SHAPE_TYPE_Polygon, SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_MultiPolygon , SHAPE_TYPE_Polygon, SG_VERTEX_TYPE_XY ); IS_OF_TYPE(SG_OGIS_TYPE_PointZM , SHAPE_TYPE_Point , SG_VERTEX_TYPE_XYZM); IS_OF_TYPE(SG_OGIS_TYPE_PointZ , SHAPE_TYPE_Point , SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_PointM , SHAPE_TYPE_Point , SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_Point , SHAPE_TYPE_Point , SG_VERTEX_TYPE_XY ); IS_OF_TYPE(SG_OGIS_TYPE_LineStringZM , SHAPE_TYPE_Line , SG_VERTEX_TYPE_XYZM); IS_OF_TYPE(SG_OGIS_TYPE_LineStringZ , SHAPE_TYPE_Line , SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_LineStringM , SHAPE_TYPE_Line , SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_LineString , SHAPE_TYPE_Line , SG_VERTEX_TYPE_XY ); IS_OF_TYPE(SG_OGIS_TYPE_PolygonZM , SHAPE_TYPE_Polygon, SG_VERTEX_TYPE_XYZM); IS_OF_TYPE(SG_OGIS_TYPE_PolygonZ , SHAPE_TYPE_Polygon, SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_PolygonM , SHAPE_TYPE_Polygon, SG_VERTEX_TYPE_XYZ ); IS_OF_TYPE(SG_OGIS_TYPE_Polygon , SHAPE_TYPE_Polygon, SG_VERTEX_TYPE_XY ); return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWKT_Export::CWKT_Export(void) { Set_Name (_TL("Export Simple Features to Well Known Text")); Set_Author (SG_T("O. Conrad (c) 2012")); Set_Description (_TW( "Exports vector data to 'well known text' (WKT) simple features format.\n" "\n" "References:\n" "Open Geospatial Consortium\n" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("Well Known Text Format (*.wkt)") , SG_T("*.wkt"), _TL("All Files") , SG_T("*.*") ), NULL, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CWKT_Export::On_Execute(void) { //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(Parameters("FILE")->asString(), SG_FILE_W, false) ) { return( false ); } //----------------------------------------------------- CSG_Shapes *pShapes = Parameters("SHAPES")->asShapes(); for(int iShape=0; iShapeGet_Count(); iShape++) { CSG_String WKT; if( CSG_Shapes_OGIS_Converter().to_WKText(pShapes->Get_Shape(iShape), WKT) ) { Stream.Write(WKT); Stream.Write("\n"); } } return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes/svg.h0000744000175000017500000001175112737416174021376 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: svg.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // svg.h // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__svg_H #define HEADER_INCLUDED__svg_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSVG_Export : public CSG_Module { public: CSVG_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); private: double m_dStroke; bool Get_Points (CSG_Shape *pShape, int iPart, CSG_String &Points); void Add_Points (CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color, double Size, int Symbol); void Add_Line (CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color, double Size); void Add_Polygon (CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSVG_Import : public CSG_Module { public: CSVG_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__svg_H saga-2.3.1/src/modules/io/io_shapes/wasp_map.cpp0000744000175000017500000002701212737416174022736 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wasp_map.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // shapes_tools // // // //-------------------------------------------------------// // // // WASP_MAP.cpp // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "wasp_map.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWASP_MAP_Export::CWASP_MAP_Export(void) { Set_Name (_TL("Export WASP terrain map file")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "Reference:\n" "" "http://www.risoe.dk/vea/projects/nimo/WAsPHelp/Wasp8.htm#FileFormatofMAP.htm" )); //----------------------------------------------------- CSG_Parameter *pShapes = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Contour Lines"), _TL(""), PARAMETER_INPUT , SHAPE_TYPE_Line ); Parameters.Add_Table_Field( pShapes , "ELEVATION" , _TL("Map File"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File Name"), _TL(""), CSG_String::Format(SG_T("%s|*.map|%s|*.*"), _TL("WASP Map Files (*.map)"), _TL("All Files") ), NULL, true ); } //--------------------------------------------------------- bool CWASP_MAP_Export::On_Execute(void) { //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(Parameters("FILE")->asString(), SG_FILE_W) ) { return( false ); } CSG_Shapes *pLines = Parameters("SHAPES")->asShapes(); if( !pLines->is_Valid() || pLines->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- // 1) Text string identifying the terrain map: + ... Stream.Printf(SG_T("+ %s\n"), pLines->Get_Name()); // 2) Fixed point #1 in user and metric [m] coordinates: // X1(user) Y1(user) X1(metric) Y1(metric) Stream.Printf(SG_T("%f %f %f %f\n"), 0.0, 0.0, 0.0, 0.0); // 3) Fixed point #2 in user and metric [m] coordinates: // X2(user) Y2(user) X2(metric) Y2(metric) Stream.Printf(SG_T("%f %f %f %f\n"), 1.0, 1.0, 1.0, 1.0); // 4) Scaling factor and offset for height scale (Z): // Zmetric = {scaling factor}(Zuser + {offset}) Stream.Printf(SG_T("%f %f\n"), 1.0, 0.0); int zField = Parameters("ELEVATION")->asInt(); //----------------------------------------------------- for(int iLine=0; iLineGet_Count() && Set_Progress(iLine, pLines->Get_Count()); iLine++) { CSG_Shape *pLine = pLines->Get_Shape(iLine); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( pLine->Get_Point_Count(iPart) > 1 ) { // 5a) Height contour: elevation (Z) and number of points (n) in line: // Z n Stream.Printf(SG_T("%f %d\n"), pLine->asDouble(zField), pLine->Get_Point_Count(iPart)); // 5b) Roughness change line: // roughness lengths to the left (z0l) and right (z0r) side of the line, // respectively, and number of points: // z0l z0r n // 5c) Roughness and contour line: // roughness lengths to the left and right of the line, // respectively, elevation and number of points: // z0l z0r Z n // 6–) Cartesian coordinates (X, Y) of line described in 5a, 5b or 5c: // X1 Y1 [... Xn Yn] // Xn+1 Yn+1 // ... where [] embrace optional numbers and n is > 0 for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pLine->Get_Point(iPoint, iPart); Stream.Printf(SG_T("%f\t%f\n"), p.x, p.y); } } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CWASP_MAP_Import::CWASP_MAP_Import(void) { Set_Name (_TL("Import WASP terrain map file")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "Reference:\n" "" "http://www.risoe.dk/vea/projects/nimo/WAsPHelp/Wasp8.htm#FileFormatofMAP.htm" )); //----------------------------------------------------- Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Contour Lines"), _TL(""), PARAMETER_OUTPUT , SHAPE_TYPE_Line ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File Name"), _TL(""), CSG_String::Format(SG_T("%s|*.map|%s|*.*"), _TL("WASP Map Files (*.map)"), _TL("All Files") ), NULL, false ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Input Specification"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("elevation"), _TL("roughness"), _TL("elevation and roughness") ), 0 ); } //--------------------------------------------------------- bool CWASP_MAP_Import::On_Execute(void) { int n, Method, nLength; double z, dz, zMin, rLeft, rRight; FILE *Stream; TSG_Point p, pu[2], pm[2]; CSG_String fName, sLine; CSG_Shape *pLine; CSG_Shapes *pLines; //----------------------------------------------------- pLines = Parameters("SHAPES")->asShapes(); fName = Parameters("FILE" )->asString(); Method = Parameters("METHOD")->asInt(); //----------------------------------------------------- if( (Stream = fopen(fName.b_str(), "r")) != NULL ) { fseek(Stream, 0, SEEK_END); nLength = ftell(Stream); fseek(Stream, 0, SEEK_SET); pLines->Create(SHAPE_TYPE_Line, SG_File_Get_Name(fName, false)); switch( Method ) { case 0: // elevation pLines->Add_Field("Z" , SG_DATATYPE_Double); break; case 1: // roughness pLines->Add_Field("RLEFT" , SG_DATATYPE_Double); pLines->Add_Field("RRIGHT" , SG_DATATYPE_Double); break; case 2: // elevation and roughness pLines->Add_Field("Z" , SG_DATATYPE_Double); pLines->Add_Field("RLEFT" , SG_DATATYPE_Double); pLines->Add_Field("RRIGHT" , SG_DATATYPE_Double); break; } // 1) Text string identifying the terrain map: + ... SG_Read_Line(Stream, sLine); // 2) Fixed point #1 in user and metric [m] coordinates: // X1(user) Y1(user) X1(metric) Y1(metric) fscanf(Stream, "%lf %lf %lf %lf", &pu[0].x, &pu[0].y, &pm[0].x, &pm[0].y); // 3) Fixed point #2 in user and metric [m] coordinates: // X2(user) Y2(user) X2(metric) Y2(metric) fscanf(Stream, "%lf %lf %lf %lf", &pu[1].x, &pu[1].y, &pm[1].x, &pm[1].y); // 4) Scaling factor and offset for height scale (Z): // Zmetric = {scaling factor}(Zuser + {offset}) fscanf(Stream, "%lf %lf", &dz, &zMin); while( !feof(Stream) && Set_Progress(ftell(Stream), nLength) ) { pLine = NULL; switch( Method ) { case 0: // elevation // 5a) Height contour: elevation (Z) and number of points (n) in line: // Z n fscanf(Stream, "%lf %d", &z, &n); if( !feof(Stream) && n > 1 ) { pLine = pLines->Add_Shape(); pLine->Set_Value(0, zMin + dz * z); } break; case 1: // roughness // 5b) Roughness change line: // roughness lengths to the left (z0l) and right (z0r) side of the line, // respectively, and number of points: // z0l z0r n fscanf(Stream, "%lf %lf %d", &rLeft, &rRight, &n); if( !feof(Stream) && n > 1 ) { pLine = pLines->Add_Shape(); pLine->Set_Value(0, rLeft); pLine->Set_Value(1, rRight); } break; case 2: // elevation and roughness // 5c) Roughness and contour line: // roughness lengths to the left and right of the line, // respectively, elevation and number of points: // z0l z0r Z n fscanf(Stream, "%lf %lf %lf %d", &rLeft, &rRight, &z, &n); if( !feof(Stream) && n > 1 ) { pLine = pLines->Add_Shape(); pLine->Set_Value(0, zMin + dz * z); pLine->Set_Value(1, rLeft); pLine->Set_Value(2, rRight); } break; } // 6–) Cartesian coordinates (X, Y) of line described in 5a, 5b or 5c: // X1 Y1 [... Xn Yn] // Xn+1 Yn+1 // ... where [] embrace optional numbers and n is > 0 for(int i=0; iAdd_Point(p); } } fclose(Stream); return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes/xyz.cpp0000744000175000017500000002360712737416174021767 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: xyz.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO // // // //-------------------------------------------------------// // // // Xyz.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "xyz.h" /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CXYZ_Export::CXYZ_Export(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Export Shapes to XYZ")); Set_Author (SG_T("O.Conrad (c) 2003")); Set_Description (_TW( "XYZ export filter for shapes. " )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL(""), true ); Parameters.Add_Value( NULL , "HEADER" , _TL("Save Table Header"), _TL(""), PARAMETER_TYPE_Bool , true ); Parameters.Add_Choice( NULL , "SEPARATE", _TL("Separate Line/Polygon Points"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("none"), _TL("*"), _TL("number of points") ), 0 ); Parameters.Add_FilePath( NULL , "FILENAME", _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"), _TL("XYZ Files (*.xyz)") , SG_T("*.xyz"), _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("All Files") , SG_T("*.*") ), NULL, true ); } //--------------------------------------------------------- bool CXYZ_Export::On_Execute(void) { bool bHeader; int Field, off_Field, Separate; CSG_File Stream; CSG_Shapes *pPoints; //----------------------------------------------------- pPoints = Parameters("POINTS" )->asShapes(); bHeader = Parameters("HEADER" )->asBool(); Field = Parameters("FIELD" )->asInt(); Separate = pPoints->Get_Type() == SHAPE_TYPE_Point ? 0 : Parameters("SEPARATE")->asInt(); off_Field = pPoints->Get_ObjectType() == DATAOBJECT_TYPE_PointCloud ? 2 : 0; //----------------------------------------------------- if( pPoints->Get_Field_Count() == 0 ) { Error_Set(_TL("data set has no attributes")); return( false ); } //----------------------------------------------------- if( !Stream.Open(Parameters("FILENAME")->asString(), SG_FILE_W, false) ) { Error_Set(_TL("could not open file")); return( false ); } //----------------------------------------------------- if( bHeader ) { Stream.Printf(SG_T("X\tY")); if( Field < 0 ) { for(int iField=off_Field; iFieldGet_Field_Count(); iField++) { Stream.Printf(SG_T("\t%s"), pPoints->Get_Field_Name(iField)); } } else { Stream.Printf(SG_T("\tZ")); } Stream.Printf(SG_T("\n")); } //------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pPoints->Get_Count()); iShape++) { CSG_Shape *pShape = pPoints->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { switch( Separate ) { case 1: // * Stream.Printf(SG_T("*\n")); break; case 2: // number of points Stream.Printf(SG_T("%d\n"), pShape->Get_Point_Count(iPart)); break; } for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point Point = pShape->Get_Point(iPoint, iPart); Stream.Printf(SG_T("%f\t%f"), Point.x, Point.y); if( Field < 0 ) { for(int iField=off_Field; iFieldGet_Field_Count(); iField++) { switch( pPoints->Get_Field_Type(iField) ) { case SG_DATATYPE_String: case SG_DATATYPE_Date: Stream.Printf(SG_T("\t\"%s\""), pShape->asString(iField)); break; default: Stream.Printf(SG_T("\t%f") , pShape->asDouble(iField)); break; } } } else switch( pPoints->Get_Field_Type(Field) ) { case SG_DATATYPE_String: case SG_DATATYPE_Date: Stream.Printf(SG_T("\t\"%s\""), pShape->asString(Field)); break; default: Stream.Printf(SG_T("\t%f") , pShape->asDouble(Field)); break; } Stream.Printf(SG_T("\n")); } } } //------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CXYZ_Import::CXYZ_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import Shapes from XYZ")); Set_Author ("O.Conrad (c) 2003"); Set_Description (_TW( "Imports points from a table with only list of x, y, z coordinates provided as simple text. " "If your table has a more complex structure, you should import it as table " "and then use the \'points from table\' conversion tool. " )); //----------------------------------------------------- pNode = Parameters.Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); Parameters.Add_Value( NULL , "HEADLINE" , "File contains headline", _TL(""), PARAMETER_TYPE_Bool , true ); Parameters.Add_FilePath( NULL , "FILENAME" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|%s"), _TL("XYZ Files (*.xyz)") , SG_T("*.xyz"), _TL("Text Files (*.txt)") , SG_T("*.txt"), _TL("All Files") , SG_T("*.*") ), NULL, false ); } //--------------------------------------------------------- bool CXYZ_Import::On_Execute(void) { CSG_File Stream; if( !Stream.Open(Parameters("FILENAME")->asString(), SG_FILE_R) ) { Error_Set(_TL("file could not be opened")); return( false ); } //----------------------------------------------------- CSG_Shapes *pPoints = Parameters("POINTS")->asShapes(); pPoints->Create(SHAPE_TYPE_Point, SG_File_Get_Name(Parameters("FILENAME")->asString(), false)); pPoints->Add_Field("Z", SG_DATATYPE_Double); //----------------------------------------------------- if( Parameters("HEADLINE")->asBool() ) { CSG_String sLine; if( !Stream.Read_Line(sLine) ) { Error_Set(_TL("could not read headline")); return( false ); } } //----------------------------------------------------- long Length = Stream.Length(); double x, y, z; while( Stream.Scan(x) && Stream.Scan(y) && Stream.Scan(z) && Set_Progress(Stream.Tell(), Length) ) { CSG_Shape *pPoint = pPoints->Add_Shape(); pPoint->Add_Point(x, y); pPoint->Set_Value(0, z); } return( pPoints->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes/stl.h0000744000175000017500000001215612737416174021401 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: stl.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // stl.h // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__stl_H #define HEADER_INCLUDED__stl_H //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSTL_Import : public CSG_Module { public: CSTL_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: typedef struct { float x, y, z; } TSTL_Point; double r_sin_x, r_cos_x, r_sin_y, r_cos_y, r_sin_z, r_cos_z; CSG_Grid *m_pGrid; bool Read_Facette (CSG_File &Stream, TSTL_Point p[3]); void Rotate (TSTL_Point &p); bool Get_Extent (CSG_File &Stream, CSG_Rect &Extent, int nFacettes); void Set_Triangle (TSG_Point_Z p[3]); void Set_Triangle_Line (int y, double xa, double za, double xb, double zb); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CSTL_Export : public CSG_Module { public: CSTL_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); private: bool Get_Normal (CSG_TIN_Triangle *pTriangle, int zField, float Normal[3]); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__stl_H saga-2.3.1/src/modules/io/io_shapes/pointcloud_from_text_file.cpp0000744000175000017500000004071212737416174026377 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pointcloud_from_text_file.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO // // // //-------------------------------------------------------// // // // pointcloud_from_text_file.cpp // // // // Copyright (C) 2009 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pointcloud_from_text_file.h" #include #include #include #include /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_From_Text_File::CPointCloud_From_Text_File(void) { //----------------------------------------------------- Set_Name (_TL("Import Point Cloud from Text File")); Set_Author (SG_T("V. Wichmann, LASERDATA GmbH (c) 2009")); Set_Description (_TW( "Creates a point cloud from a text file.\n" "The input file must have at least three columns holding the " "x, y, z coordinates of each point. You must specify the field " "numbers of these. In case you like to import additional attributes, " "you have to provide the number of attribute fields. After module " "execution, you will be prompted to provide their field numbers, " "names and datatypes.\n" "You have also to decide on which field separator to use and if " "the first line of the input file should be skipped (in case it " "contains column headings).\n" "The columns in the input file can be in any order, and you can " "omit columns, but you have to provide the correct field numbers " "of those you like to import.\n\n" "Module usage is different between SAGA GUI and SAGA CMD: With " "SAGA GUI you will get prompted to choose the fields to export, " "and to provide the field names and datatypes to use " "once you execute the module.\n" " With SAGA CMD you have to provide three strings with the " "-FIELDS, -FIELDNAMES and -FIELDTYPES parameters. The first one " "must contain the field numbers, the second one the field names " "and the third one the choices of the datatype (see the GUI which " "number equals which datatype). Each field entry has to be " "separated by semicolon. Field numbers start with 1, e.g. " "-FIELDS=\"5;6;8\" -FIELDNAMES=\"intensity;class;range\" " "-FIELDTYPES=\"2;2;3\".\n\n" )); //----------------------------------------------------- Parameters.Add_PointCloud_Output( NULL , "POINTS" , _TL("Point Cloud"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("Text File"), _TL("") ); Parameters.Add_Value( NULL , "XFIELD" , _TL("X is Column ..."), _TL("The column holding the X-coordinate."), PARAMETER_TYPE_Int, 1, 1, true ); Parameters.Add_Value( NULL , "YFIELD" , _TL("Y is Column ..."), _TL("The column holding the Y-coordinate."), PARAMETER_TYPE_Int, 2, 1, true ); Parameters.Add_Value( NULL , "ZFIELD" , _TL("Z is Column ..."), _TL("The column holding the Z-coordinate."), PARAMETER_TYPE_Int, 3, 1, true ); if (SG_UI_Get_Window_Main()) { Parameters.Add_Value( NULL , "ATTRIBS" , _TL("Number of Attributes"), _TL("Number of additional attributes to import."), PARAMETER_TYPE_Int, 0, 0, true ); } else { Parameters.Add_String( NULL , "FIELDS" , _TL("Fields"), _TL("The numbers (starting from 1) of the fields to import, separated by semicolon, e.g. \"5;6;8\""), SG_T("") ); Parameters.Add_String( NULL , "FIELDNAMES" , _TL("Field Names"), _TL("The name to use for each field, separated by semicolon, e.g. \"intensity;class;range\""), SG_T("") ); Parameters.Add_String( NULL , "FIELDTYPES" , _TL("Field Types"), _TL("The datatype to use for each field, separated by semicolon, e.g. \"2;2;3;\". The number equals the choice selection, see GUI version."), SG_T("") ); } Parameters.Add_Value( NULL , "SKIP_HEADER" , _TL("Skip first line"), _TL("Skip first line as it contains column names."), PARAMETER_TYPE_Bool, false ); Parameters.Add_Choice( NULL , "FIELDSEP" , _TL("Field Separator"), _TL("Field Separator"), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("tabulator"), _TL("space"), _TL("comma") ), 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPointCloud_From_Text_File::On_Execute(void) { CSG_String fileName; int iField, iType; CSG_String Name, Types, s; CSG_PointCloud *pPoints; CSG_Parameters P; CSG_Parameter *pNode; int xField, yField, zField, nAttribs; bool bSkipHeader; char fieldSep; std::vector vCol; std::vector vTypes; std::ifstream tabStream; std::string tabLine; double lines; long cntPt, cntInvalid; double x, y, z; //----------------------------------------------------- fileName = Parameters("FILE") ->asString(); xField = Parameters("XFIELD") ->asInt() - 1; yField = Parameters("YFIELD") ->asInt() - 1; zField = Parameters("ZFIELD") ->asInt() - 1; bSkipHeader = Parameters("SKIP_HEADER") ->asBool(); switch (Parameters("FIELDSEP")->asInt()) { default: case 0: fieldSep = '\t'; break; case 1: fieldSep = ' '; break; case 2: fieldSep = ','; break; } pPoints = SG_Create_PointCloud(); pPoints->Create(); pPoints->Set_Name(SG_File_Get_Name(fileName, false)); Parameters("POINTS")->Set_Value(pPoints); //----------------------------------------------------- if (SG_UI_Get_Window_Main()) { nAttribs = Parameters("ATTRIBS") ->asInt(); Types.Printf(SG_T("%s|%s|%s|%s|%s|%s|"), _TL("1 byte integer"), _TL("2 byte integer"), _TL("4 byte integer"), _TL("4 byte floating point"), _TL("8 byte floating point"), _TL("string") ); P.Set_Name(_TL("Attribute Field Properties")); for(iField=1; iField<=nAttribs; iField++) { s.Printf(SG_T("NODE_%03d") , iField); pNode = P.Add_Node(NULL, s, CSG_String::Format(SG_T("%d. %s"), iField, _TL("Field")), _TL("")); s.Printf(SG_T("FIELD_%03d"), iField); P.Add_String(pNode, s, _TL("Name"), _TL(""), s); s.Printf(SG_T("COLUMN_%03d"), iField); P.Add_Value(pNode, s, _TL("Attribute is Column ..."), _TL(""), PARAMETER_TYPE_Int, iField+3, 1, true); s.Printf(SG_T("TYPE_%03d") , iField); P.Add_Choice(pNode, s, _TL("Type"), _TL(""), Types, 3); } //----------------------------------------------------- if( nAttribs > 0 ) { if( Dlg_Parameters(&P, _TL("Field Properties")) ) { for(iField=0; iFieldasString(); iType = P(CSG_String::Format(SG_T("TYPE_%03d" ), iField + 1).c_str())->asInt(); vCol.push_back(P(CSG_String::Format(SG_T("COLUMN_%03d"), iField + 1).c_str())->asInt() - 1); vTypes.push_back(iType); pPoints->Add_Field(Name, Get_Data_Type(iType)); } } else return( false ); } } else // CMD { CSG_String sFields, sNames, sTypes; CSG_String token; int iValue; sFields = Parameters("FIELDS")->asString(); sNames = Parameters("FIELDNAMES")->asString(); sTypes = Parameters("FIELDTYPES")->asString(); CSG_String_Tokenizer tkz_fields(sFields, ";", SG_TOKEN_STRTOK); while( tkz_fields.Has_More_Tokens() ) { token = tkz_fields.Get_Next_Token(); if( token.Length() == 0 ) break; if( !token.asInt(iValue) ) { SG_UI_Msg_Add_Error(_TL("Error parsing attribute fields: can't convert to number")); return( false ); } iValue -= 1; if( iValue < 1) { SG_UI_Msg_Add_Error(_TL("Error parsing attribute fields: field index out of range")); return( false ); } else vCol.push_back(iValue); } CSG_String_Tokenizer tkz_datatypes(sTypes, ";", SG_TOKEN_STRTOK); while( tkz_datatypes.Has_More_Tokens() ) { token = tkz_datatypes.Get_Next_Token(); if( token.Length() == 0 ) break; if( !token.asInt(iValue) ) { SG_UI_Msg_Add_Error(_TL("Error parsing field type: can't convert to number")); return( false ); } vTypes.push_back(iValue); } CSG_String_Tokenizer tkz_datanames(sNames, ";", SG_TOKEN_STRTOK); int iter = 0; while( tkz_datanames.Has_More_Tokens() ) { token = tkz_datanames.Get_Next_Token(); if( token.Length() == 0 ) break; pPoints->Add_Field(token, Get_Data_Type(vTypes[iter])); iter++; } if( vCol.size() != vTypes.size() || (int)vCol.size() != iter ) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Number of arguments for attribute fields (%d), names (%d) and types (%d) do not match!"), vCol.size(), iter, vTypes.size())); return( false ); } } // open input stream //--------------------------------------------------------- tabStream.open(fileName.b_str(), std::ifstream::in); if( !tabStream ) { SG_UI_Msg_Add_Error(CSG_String::Format(_TL("Unable to open input file!"))); return (false); } tabStream.seekg(0, std::ios::end); // get length of file lines = (double)tabStream.tellg(); tabStream.seekg(0, std::ios::beg); std::getline(tabStream, tabLine); // as a workaround we assume the number of lines from the length of the first line lines = lines / (double)tabStream.tellg(); if( !bSkipHeader ) { tabStream.clear(); // let's forget we may have reached the EOF tabStream.seekg(0, std::ios::beg); // and rewind to the beginning } // import //--------------------------------------------------------- cntPt = cntInvalid = 0; SG_UI_Process_Set_Text(CSG_String::Format(_TL("Importing data ..."))); while( std::getline(tabStream, tabLine) ) { std::istringstream stream(tabLine); std::vector tabCols; std::string tabEntry; if( cntPt%10000 == 0 ) { SG_UI_Process_Set_Progress((double)cntPt, lines); } cntPt++; while( std::getline(stream, tabEntry, fieldSep) ) // read every column in this line and fill vector { if (tabEntry.length() == 0) continue; tabCols.push_back(tabEntry); } if ((int)tabCols.size() < (vCol.size() + 3) ) { SG_UI_Msg_Add(CSG_String::Format(_TL("WARNING: Skipping misformatted line: %d!"), cntPt), true); cntInvalid++; continue; } //parse line tokens x = strtod(tabCols[xField].c_str(), NULL); y = strtod(tabCols[yField].c_str(), NULL); z = strtod(tabCols[zField].c_str(), NULL); pPoints->Add_Point(x, y, z); for( int i=0; i<(int)vCol.size(); i++ ) { switch( Get_Data_Type(vTypes[i]) ) { case SG_DATATYPE_String: pPoints->Set_Attribute(i, SG_STR_MBTOSG(tabCols[vCol[i]].c_str())); break; default: pPoints->Set_Attribute(i, strtod(tabCols[vCol[i]].c_str(), NULL)); break; } } } // finalize //--------------------------------------------------------- tabStream.close(); CSG_Parameters sParms; DataObject_Get_Parameters(pPoints, 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); // highest z sParms("COLORS_TYPE")->Set_Value(2); // graduated color sParms("METRIC_COLORS")->asColors()->Set_Count(255); // number of colors sParms("METRIC_ATTRIB")->Set_Value(2); // z attrib sParms("METRIC_ZRANGE")->asRange()->Set_Range(pPoints->Get_Minimum(2),pPoints->Get_Maximum(2)); DataObject_Set_Parameters(pPoints, sParms); DataObject_Update(pPoints); } if (cntInvalid > 0) SG_UI_Msg_Add(CSG_String::Format(SG_T("%s: %d %s"), _TL("WARNING"), cntInvalid, _TL("invalid points have been skipped")), true); SG_UI_Msg_Add(CSG_String::Format(SG_T("%d %s"), (cntPt-cntInvalid), _TL("points have been imported with success")), true); return( true ); } //--------------------------------------------------------- TSG_Data_Type CPointCloud_From_Text_File::Get_Data_Type(int iType) { switch( iType ) { default: case 0: return( SG_DATATYPE_Char ); case 1: return( SG_DATATYPE_Short ); case 2: return( SG_DATATYPE_Int ); case 3: return( SG_DATATYPE_Float ); case 4: return( SG_DATATYPE_Double ); case 5: return( SG_DATATYPE_String ); } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes/pointcloud_from_file.cpp0000744000175000017500000001371112737416174025332 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pointcloud_from_file.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // pointcloud_from_file.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "pointcloud_from_file.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CPointCloud_From_File::CPointCloud_From_File(void) { //----------------------------------------------------- Set_Name (_TL("Import Point Cloud from Shape File")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "Allows one to import a point cloud from a point shapefile." )); //----------------------------------------------------- Parameters.Add_PointCloud_Output( NULL , "POINTS" , _TL("Point Cloud"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("ESRI Shapefiles") , SG_T("*.shp"), _TL("All Files") , SG_T("*.*") ) ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPointCloud_From_File::On_Execute(void) { CSG_String fName(Parameters("FILE")->asString()); if( Read_Shapefile(fName) ) { return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CPointCloud_From_File::Read_Shapefile(const CSG_String &fName) { int iField, iPoint; CSG_Shapes Shapes; if( !Shapes.Create(fName) || Shapes.Get_Count() == 0 ) { return( false ); } if( Shapes.Get_Type() != SHAPE_TYPE_Point ) { return( false ); } //----------------------------------------------------- CSG_PointCloud *pPoints = SG_Create_PointCloud(); pPoints->Set_Name(SG_File_Get_Name(fName, false)); Parameters("POINTS")->Set_Value(pPoints); for(iField=0; iFieldAdd_Field(Shapes.Get_Field_Name(iField), SG_DATATYPE_Double); } for(iPoint=0; iPointAdd_Point(pPoint->Get_Point(0).x, pPoint->Get_Point(0).y, 0.0); for(iField=0; iFieldSet_Value(3 + iField, pPoint->asDouble(iField)); } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes/pointcloud_to_text_file.h0000744000175000017500000001120512737416174025516 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: pointcloud_to_text_file.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO // // // //-------------------------------------------------------// // // // pointcloud_to_text_file.h // // // // Copyright (C) 2011 by // // Volker Wichmann // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: wichmann@laserdata.at // // // // contact: LASERDATA GmbH // // Management and Analysis of // // Laserscanning Data // // Technikerstr. 21a // // 6020 Innsbruck // // Austria // // www.laserdata.at // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Pointcloud_To_Text_File_H #define HEADER_INCLUDED__Pointcloud_To_Text_File_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CPointcloud_To_Text_File : public CSG_Module { public: CPointcloud_To_Text_File(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Pointcloud_To_Text_File_H saga-2.3.1/src/modules/io/io_shapes/Makefile.in0000664000175000017500000006036212737447616022503 0ustar00oconradoconrad00000000000000# Makefile.in generated by automake 1.15 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2014 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ am__is_gnu_make = { \ if test -z '$(MAKELEVEL)'; then \ false; \ elif test -n '$(MAKE_HOST)'; then \ true; \ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ true; \ else \ false; \ fi; \ } am__make_running_with_option = \ case $${target_option-} in \ ?) ;; \ *) echo "am__make_running_with_option: internal error: invalid" \ "target option '$${target_option-}' specified" >&2; \ exit 1;; \ esac; \ has_opt=no; \ sane_makeflags=$$MAKEFLAGS; \ if $(am__is_gnu_make); then \ sane_makeflags=$$MFLAGS; \ else \ case $$MAKEFLAGS in \ *\\[\ \ ]*) \ bs=\\; \ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ esac; \ fi; \ skip_next=no; \ strip_trailopt () \ { \ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ }; \ for flg in $$sane_makeflags; do \ test $$skip_next = yes && { skip_next=no; continue; }; \ case $$flg in \ *=*|--*) continue;; \ -*I) strip_trailopt 'I'; skip_next=yes;; \ -*I?*) strip_trailopt 'I';; \ -*O) strip_trailopt 'O'; skip_next=yes;; \ -*O?*) strip_trailopt 'O';; \ -*l) strip_trailopt 'l'; skip_next=yes;; \ -*l?*) strip_trailopt 'l';; \ -[dEDm]) skip_next=yes;; \ -[JT]) skip_next=yes;; \ esac; \ case $$flg in \ *$$target_option*) has_opt=yes; break;; \ esac; \ done; \ test $$has_opt = yes am__make_dryrun = (target_option=n; $(am__make_running_with_option)) am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = src/modules/io/io_shapes ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_lib_gdal.m4 \ $(top_srcdir)/m4/ax_lib_postgresql.m4 \ $(top_srcdir)/m4/ax_pkg_swig.m4 \ $(top_srcdir)/m4/ax_python_devel.m4 \ $(top_srcdir)/m4/ax_swig_enable_cxx.m4 \ $(top_srcdir)/m4/ax_swig_python.m4 $(top_srcdir)/m4/libtool.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) libio_shapes_la_DEPENDENCIES = \ $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la am_libio_shapes_la_OBJECTS = atlas_bna.lo citygml_import.lo \ generate.lo gpx.lo gstat.lo MLB_Interface.lo \ pointcloud_from_file.lo pointcloud_from_text_file.lo \ pointcloud_to_text_file.lo stl.lo surfer_bln.lo svg.lo \ wasp_map.lo wktb.lo xyz.lo libio_shapes_la_OBJECTS = $(am_libio_shapes_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ $(AM_CFLAGS) $(CFLAGS) AM_V_CC = $(am__v_CC_@AM_V@) am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) am__v_CC_0 = @echo " CC " $@; am__v_CC_1 = CCLD = $(CC) LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libio_shapes_la_SOURCES) DIST_SOURCES = $(libio_shapes_la_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. am__uniquify_input = $(AWK) '\ BEGIN { nonempty = 0; } \ { items[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in items) print i; }; } \ ' # Make sure the list of sources is unique. This is necessary because, # e.g., the same source file might be shared among _SOURCES variables # for different programs/libraries. am__define_uniq_tagged_files = \ list='$(am__tagged_files)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | $(am__uniquify_input)` ETAGS = etags CTAGS = ctags am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ AX_SWIG_PYTHON_CPPFLAGS = @AX_SWIG_PYTHON_CPPFLAGS@ AX_SWIG_PYTHON_OPT = @AX_SWIG_PYTHON_OPT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXCPP = @CXXCPP@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DISABLELIBHARU = @DISABLELIBHARU@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ GDAL2FLAGS = @GDAL2FLAGS@ GDAL_CFLAGS = @GDAL_CFLAGS@ GDAL_CONFIG = @GDAL_CONFIG@ GDAL_DEP_LDFLAGS = @GDAL_DEP_LDFLAGS@ GDAL_LDFLAGS = @GDAL_LDFLAGS@ GDAL_OGR_ENABLED = @GDAL_OGR_ENABLED@ GDAL_VERSION = @GDAL_VERSION@ GOMPFLAGS = @GOMPFLAGS@ GREP = @GREP@ HARU_LIB = @HARU_LIB@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ LN_S = @LN_S@ LOCAL_INCS = @LOCAL_INCS@ LOCAL_LIBS = @LOCAL_LIBS@ LTLIBOBJS = @LTLIBOBJS@ LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PG_CONFIG = @PG_CONFIG@ POSTGRESQL_CFLAGS = @POSTGRESQL_CFLAGS@ POSTGRESQL_LDFLAGS = @POSTGRESQL_LDFLAGS@ POSTGRESQL_VERSION = @POSTGRESQL_VERSION@ POW_LIB = @POW_LIB@ PYTHON = @PYTHON@ PYTHON_CPPFLAGS = @PYTHON_CPPFLAGS@ PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ PYTHON_EXTRA_LDFLAGS = @PYTHON_EXTRA_LDFLAGS@ PYTHON_EXTRA_LIBS = @PYTHON_EXTRA_LIBS@ PYTHON_LDFLAGS = @PYTHON_LDFLAGS@ PYTHON_PLATFORM = @PYTHON_PLATFORM@ PYTHON_PREFIX = @PYTHON_PREFIX@ PYTHON_SITE_PKG = @PYTHON_SITE_PKG@ PYTHON_VERSION = @PYTHON_VERSION@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ SWIG = @SWIG@ SWIG_LIB = @SWIG_LIB@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ pkgpyexecdir = @pkgpyexecdir@ pkgpythondir = @pkgpythondir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ pyexecdir = @pyexecdir@ pythondir = @pythondir@ runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # # $Id: Makefile.am 1373 2012-04-13 09:54:30Z oconrad $ # @DEBUG_TRUE@DBGFLAGS = -g -DDEBUG DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LFLG) pkglib_LTLIBRARIES = libio_shapes.la libio_shapes_la_SOURCES = \ atlas_bna.cpp\ citygml_import.cpp\ generate.cpp\ gpx.cpp\ gstat.cpp\ MLB_Interface.cpp\ pointcloud_from_file.cpp\ pointcloud_from_text_file.cpp\ pointcloud_to_text_file.cpp\ stl.cpp\ surfer_bln.cpp\ svg.cpp\ wasp_map.cpp\ wktb.cpp\ xyz.cpp\ atlas_bna.h\ citygml_import.h\ generate.h\ gpx.h\ gstat.h\ MLB_Interface.h\ pointcloud_from_file.h\ pointcloud_from_text_file.h\ pointcloud_to_text_file.h\ stl.h\ surfer_bln.h\ svg.h\ wasp_map.h\ wktb.h\ xyz.h libio_shapes_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) all: all-am .SUFFIXES: .SUFFIXES: .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/modules/io/io_shapes/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/modules/io/io_shapes/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(MKDIR_P) '$(DESTDIR)$(pkglibdir)'"; \ $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" || exit 1; \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; \ locs=`for p in $$list; do echo $$p; done | \ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ sort -u`; \ test -z "$$locs" || { \ echo rm -f $${locs}; \ rm -f $${locs}; \ } libio_shapes.la: $(libio_shapes_la_OBJECTS) $(libio_shapes_la_DEPENDENCIES) $(EXTRA_libio_shapes_la_DEPENDENCIES) $(AM_V_CXXLD)$(CXXLINK) -rpath $(pkglibdir) $(libio_shapes_la_OBJECTS) $(libio_shapes_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MLB_Interface.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atlas_bna.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/citygml_import.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/generate.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpx.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gstat.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pointcloud_from_file.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pointcloud_from_text_file.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pointcloud_to_text_file.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/surfer_bln.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/svg.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wasp_map.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wktb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xyz.Plo@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .cpp.lo: @am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ @am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ @am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(am__define_uniq_tagged_files); \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: ctags-am CTAGS: ctags ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) $(am__define_uniq_tagged_files); \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" cscopelist: cscopelist-am cscopelist-am: $(am__tagged_files) list='$(am__tagged_files)'; \ case "$(srcdir)" in \ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ *) sdir=$(subdir)/$(srcdir) ;; \ esac; \ for i in $$list; do \ if test -f "$$i"; then \ echo "$(subdir)/$$i"; \ else \ echo "$$sdir/$$i"; \ fi; \ done >> $(top_builddir)/cscope.files distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES cscopelist-am ctags \ ctags-am distclean distclean-compile distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-pkglibLTLIBRARIES install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ uninstall-pkglibLTLIBRARIES .PRECIOUS: Makefile # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: saga-2.3.1/src/modules/io/io_shapes/atlas_bna.h0000744000175000017500000001137512737416173022524 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: atlas_bna.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // Atlas_BNA.h // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__Atlas_BNA_H #define HEADER_INCLUDED__Atlas_BNA_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CAtlas_BNA_Import : public CSG_Module { public: CAtlas_BNA_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CAtlas_BNA_Export : public CSG_Module { public: CAtlas_BNA_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__Atlas_BNA_H saga-2.3.1/src/modules/io/io_shapes/svg.cpp0000744000175000017500000002723012737416174021730 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: svg.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // svg.cpp // // // // Copyright (C) 2010 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "svg.h" /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- enum { SYMBOL_POINT_CIRCLE = 0, SYMBOL_POINT_SQUARE }; /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSVG_Export::CSVG_Export(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export Scalable Vector Graphics (SVG) File")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "Export shapes to Scalable Vector Graphics (SVG) File.\n" "SVG specification at World Wide Web Consortium (W3C)\n" "Scalable Vector Graphics (SVG) 1.1" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|*.svg|%s|*.*"), _TL("Scalable Vector Graphics Files (*.svg)"), _TL("All Files") ), NULL, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSVG_Export::On_Execute(void) { //----------------------------------------------------- CSG_Parameter_Shapes_List *pList = Parameters("SHAPES")->asShapesList(); if( pList->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- int i, Width, Height; double Size_Point, Size_Line; CSG_Rect Extent; CSG_MetaData SVG, *pGroup; //----------------------------------------------------- Width = 800; Height = 800; Extent = pList->asShapes(0)->Get_Extent(); for(i=1; iGet_Count() && Process_Get_Okay(); i++) { Extent.Union(pList->asShapes(i)->Get_Extent()); } //----------------------------------------------------- SVG.Set_Name(SG_T("svg")); SVG.Add_Property(SG_T("xmlns") , SG_T("http://www.w3.org/2000/svg")); SVG.Add_Property(SG_T("xmlns:xlink"), SG_T("http://www.w3.org/1999/xlink")); SVG.Add_Property(SG_T("xmlns:ev") , SG_T("http://www.w3.org/2001/xml-events")); SVG.Add_Property(SG_T("version") , SG_T("1.1")); SVG.Add_Property(SG_T("baseProfile"), SG_T("tiny")); SVG.Add_Property(SG_T("width") , CSG_String::Format(SG_T("%d"), Width)); SVG.Add_Property(SG_T("height") , CSG_String::Format(SG_T("%d"), Height)); SVG.Add_Property(SG_T("viewBox") , CSG_String::Format(SG_T("%f %f %f %f"), Extent.Get_XMin(), -Extent.Get_YMax(), Extent.Get_XRange(), Extent.Get_YRange())); Size_Point = Extent.Get_XRange() / 200.0; Size_Line = Extent.Get_XRange() / 500.0; m_dStroke = Extent.Get_XRange() / 1000.0; //----------------------------------------------------- for(i=0; iGet_Count() && Process_Get_Okay(); i++) { CSG_Shapes *pShapes = pList->asShapes(i); pGroup = SVG.Add_Child(SG_T("g")); pGroup->Add_Property(SG_T("id") , pShapes->Get_Name()); pGroup->Add_Property(SG_T("transform") , SG_T("scale(1,-1)")); for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { switch( pShapes->Get_Type() ) { case SHAPE_TYPE_Point: case SHAPE_TYPE_Points: Add_Points (*pGroup, pShape, iPart, SG_COLOR_RED , Size_Point, SYMBOL_POINT_SQUARE); break; case SHAPE_TYPE_Line: Add_Line (*pGroup, pShape, iPart, SG_COLOR_BLUE_DARK , Size_Line); break; case SHAPE_TYPE_Polygon: Add_Polygon (*pGroup, pShape, iPart, SG_COLOR_GREEN ); break; } } } } //----------------------------------------------------- return( SVG.Save(Parameters("FILE")->asString()) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSVG_Export::Get_Points(CSG_Shape *pShape, int iPart, CSG_String &Points) { Points.Clear(); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point Point = pShape->Get_Point(iPoint, iPart); if( iPoint > 0 ) { Points += SG_T(" "); } Points += CSG_String::Format(SG_T("%f,%f"), Point.x, Point.y); } return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSVG_Export::Add_Points(CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color, double Size, int Symbol) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point Point = pShape->Get_Point(0, 0); CSG_MetaData *pSVG = SVG.Add_Child(); switch( Symbol ) { case SYMBOL_POINT_CIRCLE: default: pSVG->Set_Name(SG_T("circle")); pSVG->Add_Property(SG_T("cx") , Point.x); pSVG->Add_Property(SG_T("cy") , Point.y); pSVG->Add_Property(SG_T("length") , Size); break; case SYMBOL_POINT_SQUARE: pSVG->Set_Name(SG_T("rect")); pSVG->Add_Property(SG_T("x") , Point.x - Size / 2.0); pSVG->Add_Property(SG_T("y") , Point.y - Size / 2.0); pSVG->Add_Property(SG_T("width") , Size); pSVG->Add_Property(SG_T("height") , Size); break; } pSVG->Add_Property(SG_T("fill") , CSG_String::Format(SG_T("rgb(%d,%d,%d)"), SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color))); pSVG->Add_Property(SG_T("stroke") , SG_T("black")); pSVG->Add_Property(SG_T("stroke-width") , m_dStroke); } } //--------------------------------------------------------- void CSVG_Export::Add_Line(CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color, double Size) { CSG_String Points; if( Get_Points(pShape, iPart, Points) ) { CSG_MetaData *pSVG = SVG.Add_Child(SG_T("polyline")); pSVG->Add_Property(SG_T("points") , Points); pSVG->Add_Property(SG_T("fill") , SG_T("none")); pSVG->Add_Property(SG_T("stroke") , CSG_String::Format(SG_T("rgb(%d,%d,%d)"), SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color))); pSVG->Add_Property(SG_T("stroke-width") , Size); } } //--------------------------------------------------------- void CSVG_Export::Add_Polygon(CSG_MetaData &SVG, CSG_Shape *pShape, int iPart, long Color) { CSG_String Points; if( Get_Points(pShape, iPart, Points) ) { CSG_MetaData *pSVG = SVG.Add_Child(SG_T("polygon")); pSVG->Add_Property(SG_T("points") , Points); pSVG->Add_Property(SG_T("fill") , CSG_String::Format(SG_T("rgb(%d,%d,%d)"), SG_GET_R(Color), SG_GET_G(Color), SG_GET_B(Color))); pSVG->Add_Property(SG_T("stroke") , SG_T("black")); pSVG->Add_Property(SG_T("stroke-width") , m_dStroke); } } /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSVG_Import::CSVG_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import Scalable Vector Graphics (SVG) File")); Set_Author (SG_T("O.Conrad (c) 2010")); Set_Description (_TW( "" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_OUTPUT ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|*.svg|%s|*.*"), _TL("Scalable Vector Graphics Files (*.svg)"), _TL("All Files") ) ); } //--------------------------------------------------------- bool CSVG_Import::On_Execute(void) { CSG_MetaData SVG; //----------------------------------------------------- CSG_Parameter_Shapes_List *pList = Parameters("SHAPES")->asShapesList(); //----------------------------------------------------- if( SVG.Load(Parameters("FILE")->asString()) ) { } //----------------------------------------------------- return( pList->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes/xyz.h0000744000175000017500000001117212737416174021426 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: xyz.h 1922 2014-01-09 10:28:46Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO // // // //-------------------------------------------------------// // // // Xyz.h // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__XYZ_H #define HEADER_INCLUDED__XYZ_H //--------------------------------------------------------- //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CXYZ_Export : public CSG_Module { public: CXYZ_Export(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Export") ); } protected: virtual bool On_Execute(void); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CXYZ_Import : public CSG_Module { public: CXYZ_Import(void); virtual CSG_String Get_MenuPath(void) { return( _TL("Import") ); } protected: virtual bool On_Execute(void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__XYZ_H saga-2.3.1/src/modules/io/io_shapes/Makefile.am0000744000175000017500000000214412737416173022455 0ustar00oconradoconrad00000000000000# # $Id: Makefile.am 1373 2012-04-13 09:54:30Z oconrad $ # if DEBUG DBGFLAGS = -g -DDEBUG endif DEP_DEFS = -fPIC `wx-config --unicode=yes --static=no --cxxflags` DEP_LFLG = -fPIC -shared `wx-config --unicode=yes --static=no --libs` DEF_SAGA = -D_SAGA_LINUX -D_TYPEDEF_BYTE -D_TYPEDEF_WORD -D_SAGA_UNICODE CXX_INCS = -I$(top_srcdir)/src/saga_core AM_CXXFLAGS = -fPIC $(CXX_INCS) $(DEF_SAGA) $(DEP_DEFS) $(DBGFLAGS) $(GOMPFLAGS) AM_LDFLAGS = -fPIC -shared -avoid-version $(DEP_LFLG) pkglib_LTLIBRARIES = libio_shapes.la libio_shapes_la_SOURCES =\ atlas_bna.cpp\ citygml_import.cpp\ generate.cpp\ gpx.cpp\ gstat.cpp\ MLB_Interface.cpp\ pointcloud_from_file.cpp\ pointcloud_from_text_file.cpp\ pointcloud_to_text_file.cpp\ stl.cpp\ surfer_bln.cpp\ svg.cpp\ wasp_map.cpp\ wktb.cpp\ xyz.cpp\ atlas_bna.h\ citygml_import.h\ generate.h\ gpx.h\ gstat.h\ MLB_Interface.h\ pointcloud_from_file.h\ pointcloud_from_text_file.h\ pointcloud_to_text_file.h\ stl.h\ surfer_bln.h\ svg.h\ wasp_map.h\ wktb.h\ xyz.h libio_shapes_la_LIBADD = $(top_srcdir)/src/saga_core/saga_api/libsaga_api.la $(ADD_MLBS) saga-2.3.1/src/modules/io/io_shapes/stl.cpp0000744000175000017500000004641212737416174021736 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: stl.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // stl.cpp // // // // Copyright (C) 2008 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "stl.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSTL_Import::CSTL_Import(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Import Stereo Lithography File (STL)")); Set_Author (SG_T("O. Conrad (c) 2008")); Set_Description (_TW( "The StL Format" )); //----------------------------------------------------- Parameters.Add_PointCloud_Output( NULL , "POINTS" , _TL("Point Cloud"), _TL("") ); Parameters.Add_Shapes_Output( NULL , "SHAPES" , _TL("Shapes"), _TL("") ); Parameters.Add_Grid_Output( NULL , "GRID" , _TL("Grid"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("STL Files") , SG_T("*.stl"), _TL("All Files") , SG_T("*.*") ) ); Parameters.Add_Choice( NULL , "METHOD" , _TL("Target"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|"), _TL("point cloud"), _TL("point cloud (centered)"), _TL("points"), _TL("raster") ), 3 ); pNode = Parameters.Add_Choice( NULL , "METHOD_RASTER", _TL("Raster Dimension"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("Raster Resolution (Pixels X)"), _TL("Raster Resolution (Pixel Size)") ), 0 ); Parameters.Add_Value( pNode , "GRID_NX" , _TL("Raster Resolution (Pixels X)"), _TL(""), PARAMETER_TYPE_Int , 2000, 10, true ); Parameters.Add_Value( pNode , "GRID_CELL" , _TL("Raster Resolution (Pixels Size)"), _TL(""), PARAMETER_TYPE_Double , 1.0, 0.0, true ); pNode = Parameters.Add_Node( NULL , "NODE_ROTATE" , _TL("Rotation"), _TL("") ); Parameters.Add_Value( pNode , "ROT_X" , _TL("X Axis"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "ROT_Y" , _TL("Y Axis"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); Parameters.Add_Value( pNode , "ROT_Z" , _TL("Z Axis"), _TL(""), PARAMETER_TYPE_Double , 0.0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSTL_Import::On_Execute(void) { int Method; DWORD iFacette, nFacettes; TSTL_Point p[3]; CSG_String sFile, sHeader; CSG_File Stream; //----------------------------------------------------- sFile = Parameters("FILE") ->asString(); Method = Parameters("METHOD") ->asInt(); r_sin_x = sin(Parameters("ROT_X")->asDouble() * M_DEG_TO_RAD); r_sin_y = sin(Parameters("ROT_Y")->asDouble() * M_DEG_TO_RAD); r_sin_z = sin(Parameters("ROT_Z")->asDouble() * M_DEG_TO_RAD); r_cos_x = cos(Parameters("ROT_X")->asDouble() * M_DEG_TO_RAD); r_cos_y = cos(Parameters("ROT_Y")->asDouble() * M_DEG_TO_RAD); r_cos_z = cos(Parameters("ROT_Z")->asDouble() * M_DEG_TO_RAD); //----------------------------------------------------- if( !Stream.Open(sFile) ) { return( false ); } if( !Stream.Read(sHeader, 80) ) { return( false ); } Message_Add(sHeader); if( !Stream.Read(&nFacettes, sizeof(nFacettes)) ) { return( false ); } Message_Add(CSG_String::Format(SG_T("%s: %d"), _TL("Number of Facettes"), nFacettes)); //----------------------------------------------------- switch( Method ) { //----------------------------------------------------- case 0: { // Point Cloud CSG_Rect Extent; if( Get_Extent(Stream, Extent, nFacettes) ) { CSG_PRQuadTree Points(Extent); CSG_PointCloud *pPoints = SG_Create_PointCloud(); Parameters("POINTS")->Set_Value(pPoints); pPoints->Set_Name(SG_File_Get_Name(sFile, false)); pPoints->Add_Field((const char *)NULL, SG_DATATYPE_Undefined); for(iFacette=0; iFacetteAdd_Point(p[i].x, p[i].y, p[i].z); } } } } } break; } //----------------------------------------------------- case 1: { // Point Cloud (centered) CSG_PointCloud *pPoints = SG_Create_PointCloud(); Parameters("POINTS")->Set_Value(pPoints); pPoints->Set_Name(SG_File_Get_Name(sFile, false)); pPoints->Add_Field((const char *)NULL, SG_DATATYPE_Undefined); for(iFacette=0; iFacetteAdd_Point( (p[0].x + p[1].x + p[2].x) / 3.0, (p[0].y + p[1].y + p[2].y) / 3.0, (p[0].z + p[1].z + p[2].z) / 3.0 ); } } break; } //----------------------------------------------------- case 2: { // Points CSG_Shapes *pPoints = SG_Create_Shapes(SHAPE_TYPE_Point, SG_File_Get_Name(sFile, false)); pPoints->Add_Field(SG_T("Z"), SG_DATATYPE_Float); Parameters("SHAPES")->Set_Value(pPoints); for(iFacette=0; iFacetteAdd_Shape(); pPoint->Add_Point( (p[0].x + p[1].x + p[2].x) / 3.0, (p[0].y + p[1].y + p[2].y) / 3.0 ); pPoint->Set_Value(0, (p[0].z + p[1].z + p[2].z) / 3.0 ); } } break; } //----------------------------------------------------- case 3: { // Raster CSG_Rect Extent; if( Get_Extent(Stream, Extent, nFacettes) ) { int nx, ny; double d; switch( Parameters("METHOD_RASTER")->asInt() ) { case 1: // Pixel Size d = Parameters("GRID_CELL")->asDouble(); if( d > 0.0 ) { nx = 1 + (int)(Extent.Get_XRange() / d);; ny = 1 + (int)(Extent.Get_YRange() / d); break; } case 0: default: // Pixels in X Direction nx = Parameters("GRID_NX")->asInt(); d = Extent.Get_XRange() / nx; ny = 1 + (int)(Extent.Get_YRange() / d); break; } m_pGrid = SG_Create_Grid(SG_DATATYPE_Float, nx, ny, d, Extent.Get_XMin(), Extent.Get_YMin()); m_pGrid->Set_Name(SG_File_Get_Name(sFile, false)); m_pGrid->Set_NoData_Value(-99999); m_pGrid->Assign_NoData(); Parameters("GRID")->Set_Value(m_pGrid); //--------------------------------------------- for(iFacette=0; iFacetteGet_XMin()) / m_pGrid->Get_Cellsize(); Point[i].y = (p[i].y - m_pGrid->Get_YMin()) / m_pGrid->Get_Cellsize(); Point[i].z = p[i].z; } Set_Triangle(Point); } } } break; } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- inline bool CSTL_Import::Read_Facette(CSG_File &Stream, TSTL_Point p[3]) { WORD Attribute; if( Stream.Read(p + 0, sizeof(TSTL_Point)) && Stream.Read(p + 0, sizeof(TSTL_Point)) && Stream.Read(p + 1, sizeof(TSTL_Point)) && Stream.Read(p + 2, sizeof(TSTL_Point)) && Stream.Read(&Attribute, sizeof(Attribute)) ) { Rotate(p[0]); Rotate(p[1]); Rotate(p[2]); return( true ); } return( false ); } //--------------------------------------------------------- inline void CSTL_Import::Rotate(TSTL_Point &p) { float d; d = (float)(r_cos_z * p.x - r_sin_z * p.y); p.y = (float)(r_sin_z * p.x + r_cos_z * p.y); p.x = d; d = (float)(r_cos_y * p.z - r_sin_y * p.x); p.x = (float)(r_sin_y * p.z + r_cos_y * p.x); p.z = d; d = (float)(r_cos_x * p.z - r_sin_x * p.y); p.y = (float)(r_sin_x * p.z + r_cos_x * p.y); p.z = d; } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CSTL_Import::Get_Extent(CSG_File &Stream, CSG_Rect &Extent, int nFacettes) { float xMin = 1, xMax = 0, yMin, yMax; for(int iFacette=0; iFacette p[i].x ) { xMin = p[i].x; } else if( xMax < p[i].x ) { xMax = p[i].x; } if( yMin > p[i].y ) { yMin = p[i].y; } else if( yMax < p[i].y ) { yMax = p[i].y; } } } } Extent.Assign(xMin, yMin, xMax, yMax); return( xMin < xMax && yMin < yMax && Stream.Seek(80 + sizeof(nFacettes)) ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- void CSTL_Import::Set_Triangle(TSG_Point_Z p[3]) { //----------------------------------------------------- if( p[1].y < p[0].y ) { TSG_Point_Z pp = p[1]; p[1] = p[0]; p[0] = pp; } if( p[2].y < p[0].y ) { TSG_Point_Z pp = p[2]; p[2] = p[0]; p[0] = pp; } if( p[2].y < p[1].y ) { TSG_Point_Z pp = p[2]; p[2] = p[1]; p[1] = pp; } //----------------------------------------------------- TSG_Rect r; r.yMin = p[0].y; r.yMax = p[2].y; r.xMin = p[0].x < p[1].x ? (p[0].x < p[2].x ? p[0].x : p[2].x) : (p[1].x < p[2].x ? p[1].x : p[2].x); r.xMax = p[0].x > p[1].x ? (p[0].x > p[2].x ? p[0].x : p[2].x) : (p[1].x > p[2].x ? p[1].x : p[2].x); if( r.yMin >= r.yMax || r.xMin >= r.xMax ) { return; // no area } if( (r.yMin < 0.0 && r.yMax < 0.0) || (r.yMin >= m_pGrid->Get_NY() && r.yMax >= m_pGrid->Get_NY()) || (r.xMin < 0.0 && r.xMax < 0.0) || (r.xMin >= m_pGrid->Get_NX() && r.xMax >= m_pGrid->Get_NX()) ) { return; // completely outside grid } //----------------------------------------------------- TSG_Point_Z d[3]; if( (d[0].y = p[2].y - p[0].y) != 0.0 ) { d[0].x = (p[2].x - p[0].x) / d[0].y; d[0].z = (p[2].z - p[0].z) / d[0].y; } if( (d[1].y = p[1].y - p[0].y) != 0.0 ) { d[1].x = (p[1].x - p[0].x) / d[1].y; d[1].z = (p[1].z - p[0].z) / d[1].y; } if( (d[2].y = p[2].y - p[1].y) != 0.0 ) { d[2].x = (p[2].x - p[1].x) / d[2].y; d[2].z = (p[2].z - p[1].z) / d[2].y; } //----------------------------------------------------- int ay = (int)r.yMin; if( ay < 0 ) ay = 0; if( ay < r.yMin ) ay++; int by = (int)r.yMax; if( by >= m_pGrid->Get_NY() ) by = m_pGrid->Get_NY() - 1; for(int y=ay; y<=by; y++) { if( y <= p[1].y && d[1].y > 0.0 ) { Set_Triangle_Line(y, p[0].x + (y - p[0].y) * d[0].x, p[0].z + (y - p[0].y) * d[0].z, p[0].x + (y - p[0].y) * d[1].x, p[0].z + (y - p[0].y) * d[1].z ); } else if( d[2].y > 0.0 ) { Set_Triangle_Line(y, p[0].x + (y - p[0].y) * d[0].x, p[0].z + (y - p[0].y) * d[0].z, p[1].x + (y - p[1].y) * d[2].x, p[1].z + (y - p[1].y) * d[2].z ); } } } //--------------------------------------------------------- inline void CSTL_Import::Set_Triangle_Line(int y, double xa, double za, double xb, double zb) { if( xb < xa ) { double d; d = xa; xa = xb; xb = d; d = za; za = zb; zb = d; } if( xb > xa ) { double dz = (zb - za) / (xb - xa); int ax = (int)xa; if( ax < 0 ) ax = 0; if( ax < xa ) ax++; int bx = (int)xb; if( bx >= m_pGrid->Get_NX() ) bx = m_pGrid->Get_NX() - 1; for(int x=ax; x<=bx; x++) { double z = za + dz * (x - xa); if( m_pGrid->is_NoData(x, y) || m_pGrid->asDouble(x, y) < z ) { m_pGrid->Set_Value(x, y, z); } } } } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CSTL_Export::CSTL_Export(void) { CSG_Parameter *pNode; //----------------------------------------------------- Set_Name (_TL("Export TIN to Stereo Lithography File (STL)")); Set_Author (_TL("Navaladi, Schoeller, Conrad (c) 2009")); Set_Description (_TW( "The StL Format" )); //----------------------------------------------------- pNode = Parameters.Add_TIN( NULL , "TIN" , _TL("TIN"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "ZFIELD" , _TL("Z Attribute"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("STL Files") , SG_T("*.stl"), _TL("All Files") , SG_T("*.*") ), NULL, true ); Parameters.Add_Choice( pNode , "BINARY" , _TL("Output Type"), _TL(""), CSG_String::Format(SG_T("%s|%s|"), _TL("ASCII"), _TL("binary") ), 1 ); } //--------------------------------------------------------- bool CSTL_Export::On_Execute(void) { bool bBinary; int zField; float v[3]; CSG_String File; CSG_File Stream; CSG_TIN *pTIN; pTIN = Parameters("TIN") ->asTIN(); File = Parameters("FILE") ->asString(); zField = Parameters("ZFIELD") ->asInt(); bBinary = Parameters("BINARY") ->asInt() == 1; if( !Stream.Open(File, SG_FILE_W, bBinary) ) { return( false ); } //----------------------------------------------------- if( bBinary ) { char *sHeader = (char *)SG_Calloc(80, sizeof(char)); DWORD nFacets = pTIN->Get_Triangle_Count(); WORD nBytes = 0; Stream.Write(sHeader , sizeof(char), 80); Stream.Write(&nFacets, sizeof(DWORD)); SG_Free(sHeader); //------------------------------------------------- for(int iTriangle=0; iTriangleGet_Triangle_Count(); iTriangle++) { CSG_TIN_Triangle *pTriangle = pTIN->Get_Triangle(iTriangle); Get_Normal(pTriangle, zField, v); Stream.Write(v, sizeof(float), 3); // facet normal for(int iNode=0; iNode<3; iNode++) { CSG_TIN_Node *pNode = pTriangle->Get_Node(iNode); v[0] = (float)pNode->Get_X(); v[1] = (float)pNode->Get_Y(); v[2] = (float)pNode->asDouble(zField); Stream.Write(v, sizeof(float), 3); } Stream.Write(&nBytes, sizeof(WORD)); } } //----------------------------------------------------- else // ASCII { Stream.Printf(SG_T("solid %s\n"), SG_File_Get_Name(File, false).c_str()); for(int iTriangle=0; iTriangleGet_Triangle_Count(); iTriangle++) { CSG_TIN_Triangle *pTriangle = pTIN->Get_Triangle(iTriangle); Get_Normal(pTriangle, zField, v); Stream.Printf(SG_T(" facet normal %.4f %.4f %.4f\n"), v[0], v[1], v[2]); Stream.Printf(SG_T(" outer loop\n")); for(int iNode=0; iNode<3; iNode++) { CSG_TIN_Node *pNode = pTriangle->Get_Node(iNode); v[0] = (float)pNode->Get_X(); v[1] = (float)pNode->Get_Y(); v[2] = (float)pNode->asDouble(zField); Stream.Printf(SG_T(" vertex %.4f %.4f %.4f\n"), v[0], v[1], v[2]); } Stream.Printf(SG_T(" endloop\n")); Stream.Printf(SG_T(" endfacet\n")); } Stream.Printf(SG_T("endsolid %s\n"), SG_File_Get_Name(File, false).c_str()); } return( true ); } //--------------------------------------------------------- inline bool CSTL_Export::Get_Normal(CSG_TIN_Triangle *pTriangle, int zField, float Normal[3]) { double u[3], v[3]; CSG_TIN_Node *pA, *pB; pA = pTriangle->Get_Node(0); pB = pTriangle->Get_Node(1); u[0] = pB->Get_X() - pA->Get_X(); u[1] = pB->Get_Y() - pA->Get_Y(); u[2] = pB->asDouble(zField) - pA->asDouble(zField); pB = pTriangle->Get_Node(2); v[0] = pB->Get_X() - pA->Get_X(); v[1] = pB->Get_Y() - pA->Get_Y(); v[2] = pB->asDouble(zField) - pA->asDouble(zField); Normal[0] = (float)(u[1] * v[2] - u[2] * v[2]); Normal[1] = (float)(u[2] * v[0] - u[0] * v[1]); Normal[2] = (float)(u[0] * v[1] - u[1] * v[0]); return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes/gpx.h0000744000175000017500000001171212737416174021372 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gpx.h 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // gpx.h // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__GPX_H #define HEADER_INCLUDED__GPX_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGPX_Import : public CSG_Module { public: CGPX_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: bool m_bTime; CSG_String m_Name; CSG_Parameter_Shapes_List *m_pShapes; bool Add_Route (CSG_MetaData *pNode); bool Add_Track (CSG_MetaData *pNode); bool Add_Point (CSG_MetaData *pNode, CSG_Shapes *pPoints); bool Add_Fields (CSG_MetaData *pNode, CSG_Shapes *pPoints); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CGPX_Export : public CSG_Module { public: CGPX_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__GPX_H saga-2.3.1/src/modules/io/io_shapes/wktb.h0000744000175000017500000001125112737416174021541 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: wktb.h 1246 2011-11-25 13:42:38Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // wktb.h // // // // Copyright (C) 2012 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #ifndef HEADER_INCLUDED__wktb_H #define HEADER_INCLUDED__wktb_H /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "MLB_Interface.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWKT_Import : public CSG_Module { public: CWKT_Import(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Import") ); } protected: virtual bool On_Execute (void); private: bool Get_Type (CSG_String &WKT, CSG_Shapes &Shapes); }; /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- class CWKT_Export : public CSG_Module { public: CWKT_Export(void); virtual CSG_String Get_MenuPath (void) { return( _TL("Export") ); } protected: virtual bool On_Execute (void); }; /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #endif // #ifndef HEADER_INCLUDED__wktb_H saga-2.3.1/src/modules/io/io_shapes/generate.cpp0000744000175000017500000001356112737416174022725 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: generate.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // Shapes_IO // // // //-------------------------------------------------------// // // // Generate.cpp // // // // Copyright (C) 2003 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "generate.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGenerate_Export::CGenerate_Export(void) { Set_Name (_TL("Export Shapes to Generate")); Set_Author ("O.Conrad (c) 2003"); Set_Description (_TW( "Export generate shapes format." )); CSG_Parameter *pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "FIELD" , _TL("Attribute"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL("") ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGenerate_Export::On_Execute(void) { //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(Parameters("FILE")->asString(), SG_FILE_W) ) { return( false ); } CSG_Shapes *pShapes = Parameters("SHAPES")->asShapes(); if( !pShapes->is_Valid() || pShapes->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- int iField = Parameters("FIELD")->asInt(); if( pShapes->Get_Field_Type(iField) == SG_DATATYPE_String ) { iField = -1; } Stream.Printf(SG_T("EXP %s\nARC "), pShapes->Get_Name()); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); for(int iPart=0; iPartGet_Part_Count(); iPart++) { if( iField < 0 ) // Value... { Stream.Printf(SG_T("%d "), iShape + 1); } else { Stream.Printf(SG_T("%lf "), pShape->asDouble(iField)); } Stream.Printf(SG_T("1 2 3 4 5 ")); // dummy_I dummy_I dummy_I dummy_I dummy_I... Stream.Printf(SG_T("%d "), pShape->Get_Point_Count(iPart)); // I_np... for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); Stream.Printf(SG_T("%f %f "), p.x, p.y); } } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes/atlas_bna.cpp0000744000175000017500000002431112737416173023051 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: atlas_bna.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // Atlas_BNA.cpp // // // // Copyright (C) 2006 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Goettingen // // Goldschmidtstr. 5 // // 37077 Goettingen // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "atlas_bna.h" /////////////////////////////////////////////////////////// // // // Import // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CAtlas_BNA_Import::CAtlas_BNA_Import(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Import Atlas Boundary File")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "\n" )); //----------------------------------------------------- // 2. Parameters... Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|*.bna|%s|*.*"), _TL("Atlas Boundary Files (*.bna)"), _TL("All Files") ) ); } //--------------------------------------------------------- bool CAtlas_BNA_Import::On_Execute(void) { bool bOk; int iPoint, nPoints; double x, y; FILE *Stream; CSG_String FileName, sLine, sName1, sName2; CSG_Shape *pShape; CSG_Shapes *pPoints, *pLines, *pPolygons; //----------------------------------------------------- FileName = Parameters("FILE") ->asString(); //----------------------------------------------------- if( (Stream = fopen(FileName.b_str(), "r")) != NULL ) { pPoints = SG_Create_Shapes(SHAPE_TYPE_Point , SG_File_Get_Name(FileName, false)); pPoints ->Add_Field("NAME1" , SG_DATATYPE_String); pPoints ->Add_Field("NAME2" , SG_DATATYPE_String); pLines = SG_Create_Shapes(SHAPE_TYPE_Line , SG_File_Get_Name(FileName, false)); pLines ->Add_Field("NAME1" , SG_DATATYPE_String); pLines ->Add_Field("NAME2" , SG_DATATYPE_String); pPolygons = SG_Create_Shapes(SHAPE_TYPE_Polygon, SG_File_Get_Name(FileName, false)); pPolygons ->Add_Field("NAME1" , SG_DATATYPE_String); pPolygons ->Add_Field("NAME2" , SG_DATATYPE_String); //------------------------------------------------- bOk = true; while( bOk && SG_Read_Line(Stream, sLine) && Process_Get_Okay(true) ) { sName1 = sLine.AfterFirst('\"').BeforeFirst('\"'); sName2 = sLine.BeforeLast('\"').AfterLast('\"'); sLine = sLine.AfterLast('\"'); if( sLine.Find(',', true) >= 0 ) sLine = sLine.AfterLast(','); nPoints = sLine.asInt(); if( nPoints == 1 ) { pShape = pPoints ->Add_Shape(); } else if( nPoints < 0 ) { pShape = pLines ->Add_Shape(); nPoints = -nPoints; } else if( nPoints > 2 ) { pShape = pPolygons ->Add_Shape(); } else { bOk = false; } if( bOk ) { pShape->Set_Value(0, sName1); pShape->Set_Value(1, sName2); for(iPoint=0; iPointAdd_Point(x, y); } } } } fclose(Stream); //------------------------------------------------- bOk = false; if( pPoints->is_Valid() && pPoints->Get_Count() > 0 ) { bOk = true; DataObject_Add(pPoints); } else { delete(pPoints); } if( pLines->is_Valid() && pLines->Get_Count() > 0 ) { bOk = true; DataObject_Add(pLines); } else { delete(pLines); } if( pPolygons->is_Valid() && pPolygons->Get_Count() > 0 ) { bOk = true; DataObject_Add(pPolygons); } else { delete(pPolygons); } return( bOk ); } //----------------------------------------------------- return( false ); } /////////////////////////////////////////////////////////// // // // Export // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CAtlas_BNA_Export::CAtlas_BNA_Export(void) { //----------------------------------------------------- // 1. Info... Set_Name (_TL("Export Atlas Boundary File")); Set_Author ("O.Conrad (c) 2006"); Set_Description (_TW( "\n" )); //----------------------------------------------------- // 2. Parameters... CSG_Parameter *pNode; pNode = Parameters.Add_Shapes( NULL , "SHAPES" , _TL("Shapes"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Table_Field( pNode , "PNAME" , _TL("Primary Name"), _TL("") ); Parameters.Add_Table_Field( pNode , "SNAME" , _TL("Secondary Name"), _TL("") ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|*.bna|%s|*.*"), _TL("Atlas Boundary Files (*.bna)"), _TL("All Files") ), NULL, true ); } //--------------------------------------------------------- bool CAtlas_BNA_Export::On_Execute(void) { //----------------------------------------------------- CSG_File Stream; if( !Stream.Open(Parameters("FILE")->asString(), SG_FILE_W) ) { return( false ); } CSG_Shapes *pShapes = Parameters("SHAPES")->asShapes(); if( !pShapes->is_Valid() || pShapes->Get_Count() <= 0 ) { return( false ); } //----------------------------------------------------- int iName1 = Parameters("PNAME")->asInt(); int iName2 = Parameters("SNAME")->asInt(); //----------------------------------------------------- for(int iShape=0; iShapeGet_Count() && Set_Progress(iShape, pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = pShapes->Get_Shape(iShape); switch( pShapes->Get_Type() ) { default: break; //--------------------------------------------- case SHAPE_TYPE_Point: if( pShape->is_Valid() ) { Stream.Printf(SG_T("\"%s\",\"%s\",%d\n"), pShape->asString(iName1), pShape->asString(iName2), 1 ); TSG_Point p = pShape->Get_Point(0); Stream.Printf(SG_T("%f,%f\n"), p.x, p.y); } break; //--------------------------------------------- case SHAPE_TYPE_Line: if( pShape->is_Valid() ) { for(int iPart=0; iPartGet_Part_Count(); iPart++) { Stream.Printf(SG_T("\"%s\",\"%s\",%d\n"), pShape->asString(iName1), pShape->asString(iName2), pShape->Get_Point_Count(iPart) ); for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); Stream.Printf(SG_T("%f,%f\n"), p.x, p.y); } } } break; //--------------------------------------------- case SHAPE_TYPE_Polygon: if( pShape->is_Valid() ) { Stream.Printf(SG_T("\"%s\",\"%s\",%d\n"), pShape->asString(iName1), pShape->asString(iName2), pShape->Get_Point_Count() ); for(int iPart=0; iPartGet_Part_Count(); iPart++) { for(int iPoint=0; iPointGet_Point_Count(iPart); iPoint++) { TSG_Point p = pShape->Get_Point(iPoint, iPart); Stream.Printf(SG_T("%f,%f\n"), p.x, p.y); } } } break; } } //----------------------------------------------------- return( true ); } /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- saga-2.3.1/src/modules/io/io_shapes/gpx.cpp0000744000175000017500000003477212737416174021740 0ustar00oconradoconrad00000000000000/********************************************************** * Version $Id: gpx.cpp 1921 2014-01-09 10:24:11Z oconrad $ *********************************************************/ /////////////////////////////////////////////////////////// // // // SAGA // // // // System for Automated Geoscientific Analyses // // // // Module Library: // // io_shapes // // // //-------------------------------------------------------// // // // gpx.cpp // // // // Copyright (C) 2009 by // // Olaf Conrad // // // //-------------------------------------------------------// // // // This file is part of 'SAGA - System for Automated // // Geoscientific Analyses'. SAGA is free software; you // // can redistribute it and/or modify it under the terms // // of the GNU General Public License as published by the // // Free Software Foundation; version 2 of the License. // // // // SAGA is distributed in the hope that it will be // // useful, but WITHOUT ANY WARRANTY; without even the // // implied warranty of MERCHANTABILITY or FITNESS FOR A // // PARTICULAR PURPOSE. See the GNU General Public // // License for more details. // // // // You should have received a copy of the GNU General // // Public License along with this program; if not, // // write to the Free Software Foundation, Inc., // // 51 Franklin Street, 5th Floor, Boston, MA 02110-1301, // // USA. // // // //-------------------------------------------------------// // // // e-mail: oconrad@saga-gis.org // // // // contact: Olaf Conrad // // Institute of Geography // // University of Hamburg // // Germany // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #include "gpx.h" /////////////////////////////////////////////////////////// // // // // // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- CGPX_Import::CGPX_Import(void) { Set_Name (_TL("Import GPX")); Set_Author (SG_T("O. Conrad (c) 2009")); Set_Description (_TW( "Imports GPS data from GPS eXchange format GPX.\n" "\n" "References:\n" "The GPS Exchange Format" )); //----------------------------------------------------- Parameters.Add_Shapes_List( NULL , "SHAPES" , _TL("GPX Import"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); Parameters.Add_FilePath( NULL , "FILE" , _TL("File"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s"), _TL("GPS Exchange Format (*.gpx)") , SG_T("*.gpx"), _TL("All Files") , SG_T("*.*") ), NULL, false ); Parameters.Add_Value( NULL , "TIME" , _TL("Time Stamp without date"), _TL(""), PARAMETER_TYPE_Bool, true ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- bool CGPX_Import::On_Execute(void) { CSG_Shapes *pWay; CSG_MetaData GPX; //----------------------------------------------------- m_Name = Parameters("FILE") ->asString(); m_pShapes = Parameters("SHAPES") ->asShapesList(); m_bTime = Parameters("TIME") ->asBool(); //----------------------------------------------------- if( !GPX.Create(m_Name) || GPX.Get_Name().CmpNoCase(SG_T("gpx")) ) { return( false ); } //----------------------------------------------------- pWay = SG_Create_Shapes(SHAPE_TYPE_Point, m_Name); m_Name = SG_File_Get_Name(m_Name, false); m_pShapes->Del_Items(); //----------------------------------------------------- for(int i=0; iGet_Name().CmpNoCase(SG_T("wpt")) == 0 ) { Add_Point(pChild, pWay); } else if( pChild->Get_Name().CmpNoCase(SG_T("rte")) == 0 ) { Add_Route(pChild); } else if( pChild->Get_Name().CmpNoCase(SG_T("trk")) == 0 ) { Add_Track(pChild); } } //----------------------------------------------------- if( pWay->Get_Count() > 0 ) { m_pShapes->Add_Item(pWay); } else { delete(pWay); } return( m_pShapes->Get_Count() > 0 ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define GET_CONTENT(node, child, default) (node->Get_Child(SG_T(child)) ? node->Get_Child(SG_T(child))->Get_Content() : SG_T(default)) //--------------------------------------------------------- bool CGPX_Import::Add_Route(CSG_MetaData *pRoute) { // xsd:string // xsd:string // xsd:string // xsd:string // linkType // xsd:nonNegativeInteger // xsd:string CSG_String Name(GET_CONTENT(pRoute, "name", "Route")); CSG_Shapes *pPoints = SG_Create_Shapes(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), m_Name.c_str(), Name.c_str())); m_pShapes->Add_Item(pPoints); for(int i=0; iGet_Children_Count(); i++) { CSG_MetaData *pChild = pRoute->Get_Child(i); if( pChild->Get_Name().CmpNoCase(SG_T("rtept")) == 0 ) { Add_Point(pChild, pPoints); } } return( true ); } //--------------------------------------------------------- bool CGPX_Import::Add_Track(CSG_MetaData *pTrack) { // xsd:string // xsd:string // xsd:string // xsd:string // linkType // xsd:nonNegativeInteger // xsd:string CSG_MetaData *pSegment = pTrack->Get_Child(SG_T("trkseg")); if( pSegment ) { CSG_String Name(GET_CONTENT(pTrack, "name", "Track Segment")); CSG_Shapes *pPoints = SG_Create_Shapes(SHAPE_TYPE_Point, CSG_String::Format(SG_T("%s [%s]"), m_Name.c_str(), Name.c_str())); m_pShapes->Add_Item(pPoints); for(int i=0; iGet_Children_Count(); i++) { CSG_MetaData *pChild = pSegment->Get_Child(i); if( pChild->Get_Name().CmpNoCase(SG_T("trkpt")) == 0 ) { Add_Point(pChild, pPoints); } } return( true ); } return( false ); } /////////////////////////////////////////////////////////// // // /////////////////////////////////////////////////////////// //--------------------------------------------------------- #define ADD_FIELD(key, type) if( pNode->Get_Child(SG_T(key)) ) { pPoints->Add_Field(SG_T(key), type); } inline bool CGPX_Import::Add_Fields(CSG_MetaData *pNode, CSG_Shapes *pPoints) { if( pPoints->Get_Field_Count() == 0 ) { ADD_FIELD("ele" , SG_DATATYPE_Double); // xsd:decimal (Höhe) ADD_FIELD("time" , SG_DATATYPE_String); //