void TripSum::Read_Vehicle (void) { int id, num_out; Vehicle_File *file, *new_file; file = (Vehicle_File *) Demand_Db_Base (VEHICLE); new_file = (Vehicle_File *) Demand_Db_Base (NEW_VEHICLE); //---- process each vehicle ---- Show_Message ("Reading %s -- Record", file->File_Type ()); Set_Progress (10000); num_out = 0; while (file->Read ()) { Show_Progress (); id = file->Vehicle (); if (id == 0) continue; if (vehicle_list.Get_Index (id) == 0) continue; new_file->Copy_Fields (file); if (!new_file->Write ()) { Error ("Writing %s", new_file->File_Type ()); } num_out++; } End_Progress (); Print (2, "Number of Vehicle Records Read = %d", Progress_Count ()); Print (1, "Number of Vehicle Records Written = %d", num_out); file->Close (); new_file->Close (); }
//--------------------------------------------------------- bool CPoint_Trend_Surface::Set_Regression(CSG_Grid *pRegression) { int x, y, i, j, Field; double z; TSG_Point Point; CSG_Vector xPow(m_xOrder + 1), yPow(m_yOrder + 1); xPow[0] = 1.0; yPow[0] = 1.0; for(y=0, Point.y=pRegression->Get_YMin(); y<pRegression->Get_NY() && Set_Progress(y, pRegression->Get_NY()); y++, Point.y+=pRegression->Get_Cellsize()) { for(x=0, Point.x=pRegression->Get_XMin(); x<pRegression->Get_NX(); x++, Point.x+=pRegression->Get_Cellsize()) { z = m_Coefficients[0]; for(i=1, Field=1; i<=m_xOrder; i++) { z += m_Coefficients[Field++] * (xPow[i] = xPow[i - 1] * Point.x); } for(i=1; i<=m_yOrder; i++) { z += m_Coefficients[Field++] * (yPow[i] = yPow[i - 1] * Point.y); for(j=1; j<=m_xOrder && i<m_tOrder && j<m_tOrder; j++) { z += m_Coefficients[Field++] * xPow[j] * yPow[i]; } } pRegression->Set_Value(x, y, z); } } DataObject_Update(pRegression); return( true ); }
void PlanSum::Read_HHList (void) { int nfile, hhold; //---- read the household list files ---- for (nfile=0; ; nfile++) { if (!hhlist_file.Open (nfile)) break; if (hhlist_file.Extend ()) { Show_Message ("Reading %s %s -- Record", hhlist_file.File_Type (), hhlist_file.Extension ()); } else { Show_Message ("Reading %s -- Record", hhlist_file.File_Type ()); } Set_Progress (); //---- store the household list ---- while (hhlist_file.Read ()) { Show_Progress (); Get_Integer (hhlist_file.Record (), &hhold); if (hhold <= 0) continue; if (!hhold_list.Add (hhold)) { Error ("Adding Household %d", hhold); } } End_Progress (); hhlist_file.Close (); } hhold = hhold_list.Num_Records (); hhold_list.Max_Records (hhold); Print (2, "Number of Household List Records = %d", hhold); }
void LinkSum::Write_Activity (void) { Show_Message ("Writing Link Activity File -- Record"); Set_Progress (); link_db.Rewind (); while (link_db.Read_Record ()) { Show_Progress (); activity_file.Copy_Fields (&link_db); if (!activity_file.Write ()) { Error ("Writing the Link Activity File"); } } End_Progress (); Print (2, "Number of Link Activity Records = %d", Progress_Count ()); activity_file.Close (); }
//--------------------------------------------------------- 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; y<Get_NY() && Set_Progress(y); y++) { for(x=0; x<Get_NX(); x++) { if( (double)rand() / (double)RAND_MAX <= frequency ) { pShape = pShapes->Add_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 ); }
//--------------------------------------------------------- bool CGrid_Histogram_Surface::Get_Circle(void) { long i; int n; double r; CSG_Grid *pHist; r = sqrt(m_pGrid->Get_NCells() / M_PI); n = 1 + (int)(2.0 * r); //----------------------------------------------------- Parameters("HIST")->Set_Value(pHist = SG_Create_Grid(m_pGrid->Get_Type(), n, n, m_pGrid->Get_Cellsize(), -r * m_pGrid->Get_Cellsize(), -r * m_pGrid->Get_Cellsize())); pHist->Set_NoData_Value_Range( m_pGrid->Get_NoData_Value(), m_pGrid->Get_NoData_hiValue() ); //----------------------------------------------------- for(int y=0; y<n && Set_Progress(y, n); y++) { for(int x=0; x<n; x++) { double d = SG_Get_Distance(x, y, r, r); if( d < r && m_pGrid->Get_Sorted((long)(d*d*M_PI), i) ) { pHist->Set_Value(x, y, m_pGrid->asDouble(i)); } else { pHist->Set_NoData(x, y); } } } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- 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(); y<pTarget->Get_NY() && Set_Progress(y, pTarget->Get_NY()); y++, Pt_Target.y+=pTarget->Get_Cellsize()) { for(x=0, Pt_Target.x=pTarget->Get_XMin(); x<pTarget->Get_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_Interpolation) ) { pTarget->Set_Value(x, y, z); } } } } return( true ); } return( false ); }
//--------------------------------------------------------- bool CPolygon_Intersection::Get_Difference(CSG_Shapes *pShapes_A, CSG_Shapes *pShapes_B, int Mode) { CSG_Shape *pShape_A; CSG_Shapes Tmp(SHAPE_TYPE_Polygon); m_Mode = Mode; pShape_A = Tmp.Add_Shape(); for(int iShape_A=0; iShape_A<pShapes_A->Get_Count() && Set_Progress(iShape_A, pShapes_A->Get_Count()); iShape_A++) { if( pShapes_B->Select(pShapes_A->Get_Shape(iShape_A)->Get_Extent()) ) { int nIntersections = 0; pShape_A->Assign(pShapes_A->Get_Shape(iShape_A)); for(int iShape_B=0; iShape_B<pShapes_B->Get_Selection_Count(); iShape_B++) { if( GPC_Difference(pShape_A, pShapes_B->Get_Selection(iShape_B)) ) { nIntersections++; } } if( nIntersections && pShape_A->is_Valid() ) { Add_Polygon(pShape_A, iShape_A); } } else { Add_Polygon(pShapes_A->Get_Shape(iShape_A), iShape_A); } } return( m_pShapes_AB->is_Valid() ); }
//--------------------------------------------------------- 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(); y<pGrid->Get_NY() && Set_Progress(y, pGrid->Get_NY()); y++, Point.y+=pGrid->Get_Cellsize()) { for(x=0, Point.x=pGrid->Get_XMin(); x<pGrid->Get_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 ); }
void NewFormat::Read_Persons (void) { int hhold; Person_Data person_rec; Int_Map_Itr map_itr; Household_Data *hhold_ptr; //---- process the person file ---- Show_Message (String ("Reading %s -- Record") % person_file.File_Type ()); Set_Progress (); while (person_file.Read ()) { Show_Progress (); hhold = person_file.Household (); map_itr = hhold_map.find (hhold); if (map_itr == hhold_map.end ()) { Error (String ("Person %d Household %d was Not Found") % Progress_Count () % hhold); } hhold_ptr = &hhold_array [map_itr->second]; person_rec.Person (person_file.Person ()); person_rec.Age (person_file.Age ()); person_rec.Relate (person_file.Relate ()); person_rec.Gender (person_file.Gender ()); person_rec.Work (person_file.Work ()); person_rec.Drive (person_file.Drive ()); hhold_ptr->push_back (person_rec); } End_Progress (); person_file.Close (); Print (2, String ("Number of %s Records = %d") % person_file.File_Type () % Progress_Count ()); }
//--------------------------------------------------------- bool CMRVBF::Get_Flatness(CSG_Grid *pSlopes, CSG_Grid *pPercentiles, CSG_Grid *pCF, CSG_Grid *pVF, CSG_Grid *pRF, double T_Slope) { // const int Interpolation = GRID_INTERPOLATION_Bilinear; const int Interpolation = GRID_INTERPOLATION_BSpline; if( pSlopes && pSlopes->is_Valid() && pPercentiles && pPercentiles->is_Valid() ) { int x, y; double xp, yp, Slope, Percentile, cf, vf, rf; for(y=0, yp=Get_YMin(); y<Get_NY() && Set_Progress(y); y++, yp+=Get_Cellsize()) { for(x=0, xp=Get_XMin(); x<Get_NX(); x++, xp+=Get_Cellsize()) { if( pSlopes ->Get_Value(xp, yp, Slope , Interpolation) && pPercentiles->Get_Value(xp, yp, Percentile, Interpolation) ) { cf = pCF->asDouble(x, y) * Get_Transformation(Slope, T_Slope, m_P_Slope); vf = cf * Get_Transformation( Percentile, m_T_Pctl_V, m_P_Pctl); rf = cf * Get_Transformation(1.0 - Percentile, m_T_Pctl_R, m_P_Pctl); pCF->Set_Value (x, y, cf); pVF->Set_Value (x, y, 1.0 - Get_Transformation(vf, 0.3, 4.0)); pRF->Set_Value (x, y, 1.0 - Get_Transformation(rf, 0.3, 4.0)); } else { pVF->Set_NoData (x, y); pRF->Set_NoData (x, y); } } } return( true ); } return( false ); }
//--------------------------------------------------------- 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; y<Get_NY() && Set_Progress(y); y++) { for(x=0; x<Get_NX(); x++) { switch( m_pChnl->asInt(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; } } } }
void TourData::Attraction_Report (void) { int i, zone, attr; Integers totals; Table_Itr table_itr; Int_Map_Itr map_itr; Show_Message ("Zone Attractions Report -- Record"); Set_Progress (); Header_Number (ATTRACTIONS); New_Page (); totals.assign (table_groups.size (), 0); for (map_itr = zone_map.begin (); map_itr != zone_map.end (); map_itr++) { zone = map_itr->first; Show_Progress (); Print (1, String ("%5d") % zone); for (i=0, table_itr = table_groups.begin (); table_itr != table_groups.end (); table_itr++, i++) { attr = table_itr->zone_wt [zone]; Print (0, String (" %8d") % attr); totals [i] += attr; } } End_Progress (); Print (2, "Total"); for (i=0, table_itr = table_groups.begin (); table_itr != table_groups.end (); table_itr++, i++) { Print (0, String (" %8d") % totals [i]); } Header_Number (0); }
//--------------------------------------------------------- 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; i<pInput->Get_Point_Count() && Set_Progress(i, pInput->Get_Point_Count()); i+=step) { pResult->Del_Point(i); } //----------------------------------------------------- return( true ); }
void ConvertTours::Read_HHList (void) { int hhold; Show_Message ("Reading %s -- Record", hhlist_file.File_Type ()); Set_Progress (100000); //---- read the household list file ---- while (hhlist_file.Read ()) { Show_Progress (); Get_Integer (hhlist_file.Record (), &hhold); if (!hhold_list.Add (hhold)) { Error ("Adding Household List Record"); } if (hhold > max_hhlist) max_hhlist = hhold; } End_Progress (); hhlist_file.Close (); }
void SmoothData::Execute (void) { int n = 0; //---- process each group ---- for (group_ptr = file_group.First (); group_ptr; group_ptr = file_group.Next ()) { if (n++) { Write (1); diurnal_data.Reset (); } Show_Message ("Processing Smooth Group %d -- Record", n); Set_Progress (); num_group = num_ini = num_in = num_out = 0; Read_Input (); End_Progress (); group_ptr->Input_File ()->Close (); group_ptr->Output_File ()->Close (); if (group_ptr->Initial_File () != NULL) { Write (1, "Number of %s Records = %d", group_ptr->Initial_File ()->File_Type (), num_ini); group_ptr->Initial_File ()->Close (); } Write (1, "Number of %s Records = %d", group_ptr->Input_File ()->File_Type (), num_in); Write (1, "Number of %s Records = %d", group_ptr->Output_File ()->File_Type (), num_out); if (num_group > 1) { Write (1, "Number of Smooth Groups within File #%d = %d", n, num_group); } } Exit_Stat (DONE); }
//--------------------------------------------------------- CSG_Shapes * CInterpolation::Get_Points(bool bOnlyNonPoints) { m_pShapes = Parameters("SHAPES") ->asShapes(); if( !bOnlyNonPoints || m_pShapes->Get_Type() != SHAPE_TYPE_Point ) { CSG_Shapes *pPoints = SG_Create_Shapes(SHAPE_TYPE_Point); pPoints->Set_NoData_Value_Range(m_pShapes->Get_NoData_Value(), m_pShapes->Get_NoData_hiValue()); pPoints->Add_Field(SG_T("Z"), SG_DATATYPE_Double); for(int iShape=0; iShape<m_pShapes->Get_Count() && Set_Progress(iShape, m_pShapes->Get_Count()); iShape++) { CSG_Shape *pShape = m_pShapes->Get_Shape(iShape); if( !pShape->is_NoData(m_zField) ) { for(int iPart=0; iPart<pShape->Get_Part_Count(); iPart++) { for(int iPoint=0; iPoint<pShape->Get_Point_Count(iPart); iPoint++) { CSG_Shape *pPoint = pPoints->Add_Shape(); pPoint->Add_Point(pShape->Get_Point(iPoint, iPart)); pPoint->Set_Value(0, pShape->asDouble(m_zField)); } } } } m_zField = 0; m_pShapes = pPoints; } return( m_pShapes ); }
void NetPrep::Write_Link_Nodes (void) { int count = 0; Int_Map_Itr itr; Int_List_Itr list_itr; Link_Nodes *ptr; Link_Data *link_ptr; Show_Message (String ("Writing %s -- Record") % link_node_file.File_Type ()); Set_Progress (); fstream &file = link_node_file.File (); for (itr = link_map.begin (); itr != link_map.end (); itr++) { Show_Progress (); link_ptr = &link_array [itr->second]; if (!drop_flag || link_ptr->Length () > 0) { count++; ptr = &link_node_array [itr->second]; file << ptr->link << " ="; for (list_itr = ptr->nodes.begin (); list_itr != ptr->nodes.end (); list_itr++) { file << " " << *list_itr; } file << endl; } } Show_Progress (count); End_Progress (); link_node_file.Close (); Print (2, String ("%s Records = %d") % link_node_file.File_Type () % count); }
//--------------------------------------------------------- bool CExercise_03::Method_02(void) { int x, y, ix; double a, b, c; //----------------------------------------------------- for(y=0; y<Get_NY() && Set_Progress(y); y++) { x = 0; // initialize x... while( x < Get_NX() - 1 ) // condition for x... { ix = x + 1; if( m_pInput->is_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 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; iPolygon<pPolygons->Get_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 CRealArea::On_Execute(void) { CSG_Grid *pDEM = Parameters("DEM" )->asGrid(); CSG_Grid *pArea = Parameters("AREA")->asGrid(); for(int y=0; y<Get_NY() && Set_Progress(y); y++) { for(int x=0; x<Get_NX(); x++) { double s, a; if( pDEM->Get_Gradient(x, y, s, a) ) { pArea->Set_Value(x, y, Get_System()->Get_Cellarea() / cos(s)); } else { pArea->Set_NoData(x,y); } } } return( true ); }
//--------------------------------------------------------- bool CGW_Multi_Regression_Grid::Get_Model(void) { //----------------------------------------------------- for(int y=0; y<m_dimModel.Get_NY() && Set_Progress(y, m_dimModel.Get_NY()); y++) { for(int x=0; x<m_dimModel.Get_NX(); x++) { double q; CSG_Vector b; if( Get_Regression(x, y, q, b) ) { m_pQuality->Set_Value(x, y, q); m_pModel[m_nPredictors]->Set_Value(x, y, b[0]); for(int i=0; i<m_nPredictors; i++) { m_pModel[i]->Set_Value(x, y, b[i + 1]); } } else { m_pQuality->Set_NoData(x, y); for(int i=0; i<=m_nPredictors; i++) { m_pModel[i]->Set_NoData(x, y); } } } } //----------------------------------------------------- return( true ); }
//--------------------------------------------------------- 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; iPolygon<pPolygons->Get_Count() && Set_Progress(iPolygon, pPolygons->Get_Count()); iPolygon++) { CSG_Shape *pPolygon = pPolygons->Get_Shape(iPolygon); for(int iPart=0; iPart<pPolygon->Get_Part_Count(); iPart++) { CSG_Shape_Part *pPart = ((CSG_Shape_Polygon *)pPolygon)->Get_Part(iPart); for(int iPoint=0, nParts=pDissolved->Get_Part_Count(); iPoint<pPart->Get_Count(); iPoint++) { pDissolved->Add_Point(pPart->Get_Point(iPoint), nParts); } } } return( SG_Polygon_Dissolve(pDissolved) ); }
void ActivityPattern::Write_Count (void) { char buffer [STRING_BUFFER]; Survey_Person *person_ptr; Show_Message ("Writing %s -- Record", count_file.File_Type ()); Set_Progress (10000); for (person_ptr = survey_pop_data.First_Key (); person_ptr; person_ptr = survey_pop_data.Next_Key ()) { Show_Progress (); str_fmt (buffer, sizeof (buffer), "%d\t%d\t%d", person_ptr->Household (), person_ptr->Person (), person_ptr->Count ()); if (!count_file.Write (buffer)) { Error ("Writing %s", count_file.File_Type ()); } } End_Progress (); count_file.Close (); Print (2, "Number of %s Records = %d", count_file.File_Type (), Progress_Count ()); }
void Data_Service::Write_Signs (void) { Sign_File *file = (Sign_File *) System_File_Handle (NEW_SIGN); int dir, index, count; Dir_Data *dir_ptr; Link_Data *link_ptr; Int_Map_Itr itr; count = 0; Show_Message (String ("Writing %s -- Record") % file->File_Type ()); Set_Progress (); for (itr = link_map.begin (); itr != link_map.end (); itr++) { link_ptr = &link_array [itr->second]; for (dir=0; dir < 2; dir++) { index = (dir) ? link_ptr->BA_Dir () : link_ptr->AB_Dir (); if (index < 0) continue; Show_Progress (); dir_ptr = &dir_array [index]; if (dir_ptr->Sign () == NO_CONTROL) continue; count += Put_Sign_Data (*file, *dir_ptr); } } Show_Progress (count); End_Progress (); file->Close (); Print (2, String ("%s Records = %d") % file->File_Type () % count); }
//--------------------------------------------------------- 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; iMultipoint<pMultipoints->Get_Count() && Set_Progress(iMultipoint, pMultipoints->Get_Count()); iMultipoint++) { CSG_Shape *pMultipoint = pMultipoints->Get_Shape(iMultipoint); for(int iPart=0; iPart<pMultipoint->Get_Part_Count(); iPart++) { for(int iPoint=0; iPoint<pMultipoint->Get_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 ); }
//--------------------------------------------------------- bool CDecision_Tree::On_Execute(void) { CSG_Grid *pClasses; //----------------------------------------------------- pClasses = Parameters("CLASSES") ->asGrid(); pClasses ->Set_NoData_Value(-1); //----------------------------------------------------- for(int y=0; y<Get_NY() && Set_Progress(y); y++) { for(int x=0; x<Get_NX(); x++) { pClasses->Set_Value(x, y, Get_Class(Parameters("ROOT")->asParameters(), Get_System()->Get_Grid_to_World(x, y))); } } //----------------------------------------------------- CSG_Parameters P; if( DataObject_Get_Parameters(pClasses, P) && P("COLORS_TYPE") && P("LUT") ) { CSG_Table *pTable = P("LUT")->asTable(); pTable->Del_Records(); Get_Class(Parameters("ROOT")->asParameters(), pTable); P("COLORS_TYPE")->Set_Value(1); // Color Classification Type: Lookup Table DataObject_Set_Parameters(pClasses, P); } //----------------------------------------------------- return( true ); }
bool CProtectionIndex::On_Execute(void){ int x,y; double dProtectionIndex; CSG_Grid* pProtectionIndex = Parameters("PROTECTION")->asGrid(); m_dRadius = Parameters("RADIUS")->asDouble(); m_pDEM = Parameters("DEM")->asGrid(); for(y=0; y<Get_NY() && Set_Progress(y); y++){ for(x=0; x<Get_NX(); x++){ dProtectionIndex = getProtectionIndex(x,y); if (dProtectionIndex == NO_DATA){ pProtectionIndex->Set_NoData(x,y); }//if else{ pProtectionIndex->Set_Value(x,y, dProtectionIndex); }//else }//for }//for return true; }//method
//--------------------------------------------------------- void CGrid_Geometric_Figures::Create_Plane(CSG_Grid *pGrid, double Direction) { int x, y; double xPos, yPos, z, dSin, dCos, Max; //----------------------------------------------------- pGrid->Set_Name(CSG_String::Format(_TL("Plane (%.2fDegree)"), Direction)); Max = sqrt(2.0) * pGrid->Get_Cellsize() * pGrid->Get_Cellsize() / 4.0; dSin = sin(M_DEG_TO_RAD * Direction); dCos = cos(M_DEG_TO_RAD * Direction); //----------------------------------------------------- for(y=0, yPos=0.5-pGrid->Get_Cellsize()*pGrid->Get_NY()/2.0; y<pGrid->Get_NY() && Set_Progress(y, pGrid->Get_NY()); y++, yPos+=pGrid->Get_Cellsize()) { for(x=0, xPos=0.5-pGrid->Get_Cellsize()*pGrid->Get_NX()/2.0; x<pGrid->Get_NX(); x++, xPos+=pGrid->Get_Cellsize()) { // pGrid->Set_NoData(x, y); // z = dCos * xPos - dSin * yPos; // if( z >= -Max && z <= Max ) { // z = dSin * xPos + dCos * yPos; // if( z >= -Max && z <= Max ) { z = xPos * dSin + yPos * dCos; pGrid->Set_Value(x, y, z); } } } } }
//--------------------------------------------------------- bool CSADO_SolarRadiation::Get_Insolation(int Day, double Hour) { double Azimuth, Decline; if( m_bBending ) { bool bGo = false; for(int y=0; y<Get_NY() && Set_Progress(y); y++) { for(int x=0; x<Get_NX(); x++) { Get_Solar_Position(Day, Hour, m_Lat.asDouble(x, y), m_Lon.asDouble(x, y), Decline, Azimuth); m_Azimuth.Set_Value(x, y, Azimuth); m_Decline.Set_Value(x, y, Decline); if( Decline > 0.0 ) { bGo = true; } } } if( bGo ) { return( Set_Insolation(Decline, Azimuth) ); } } else if( Get_Solar_Position(Day, Hour, m_Latitude, 0.0, Decline, Azimuth) ) { return( Set_Insolation(Decline, Azimuth) ); } return( false ); }