/** * Sends a discovery request to search for a UPnP enabled IGD that * contains the WANIPConnection service or WANPPPConnection that will * allow us to recieve the public IP address of the IGD, and control * it for forwarding ports. * * Return the UpnpController for the IGD in the c parameter. * User should call LNat_Upnp_Free() to free the memory allocated for * this UpnpController object. * * Return OK if everything was successful. */ LIBNAT_API int LNat_Upnp_Discover(UpnpController ** c) { int ret; char * ssdp_response; char * desc_url; char * description; /* allocate space for our controller object, and initialize it's members */ *c = (UpnpController *)malloc(sizeof(UpnpController)); if(NULL == *c) { return BAD_MALLOC; } (*c)->control_url = NULL; (*c)->service_type = NULL; /* send a discovery request, and get a response */ if((ret = Send_Ssdp_Discover(*c, &ssdp_response)) != OK) { (void)LNat_Upnp_Controller_Free(c); return ret; } /* get the description URL out of the ssdp discovery request */ if((ret = Get_Description_Url(ssdp_response, &desc_url)) != OK) { free(ssdp_response); (void)LNat_Upnp_Controller_Free(c); return ret; } /* retreive the description from the desc_url */ if((ret = Get_Description(desc_url, &description)) != OK) { free(ssdp_response); free(desc_url); (void)LNat_Upnp_Controller_Free(c); return ret; } /* get the control_url from the description, and store it in c */ if((ret = Get_Control_Url(*c, desc_url, description)) != OK) { free(ssdp_response); free(desc_url); free(description); (void)LNat_Upnp_Controller_Free(c); return ret; } free(ssdp_response); free(desc_url); free(description); return OK; }
//--------------------------------------------------------- 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 ); } }
//--------------------------------------------------------- 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 (SG_T("O. Conrad (c) 2010")); Set_Description (_TW( "Coordinate transformation for grids.\n" )); Set_Description (Get_Description() + "\n" + CSG_CRSProjector::Get_Description()); //----------------------------------------------------- if( m_bList ) { pNode = Parameters.Add_Grid_List( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); Parameters.Add_Grid_List( NULL , "TARGET" , _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); m_Grid_Target.Add_Parameters_User (Add_Parameters("GET_USER" , _TL("User Defined Grid System"), _TL("")), false); m_Grid_Target.Add_Parameters_System(Add_Parameters("GET_SYSTEM", _TL("Select Grid System") , _TL(""))); } //----------------------------------------------------- else { pNode = Parameters.Add_Grid( NULL , "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); m_Grid_Target.Add_Parameters_User (Add_Parameters("GET_USER" , _TL("User Defined Grid"), _TL(""))); m_Grid_Target.Add_Parameters_Grid (Add_Parameters("GET_GRID" , _TL("Select Grid") , _TL(""))); } //----------------------------------------------------- Parameters.Add_Value( pNode , "CREATE_XY" , _TL("Create X/Y Grids"), _TL(""), PARAMETER_TYPE_Bool, false ); Parameters.Add_Grid_Output(NULL, "OUT_X", _TL("X Coordinates"), _TL("")); Parameters.Add_Grid_Output(NULL, "OUT_Y", _TL("Y Coordinates"), _TL("")); //----------------------------------------------------- Parameters.Add_Choice( pNode , "INTERPOLATION" , _TL("Interpolation"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|%s|%s|"), _TL("Nearest Neigbhor"), _TL("Bilinear Interpolation"), _TL("Inverse Distance Interpolation"), _TL("Bicubic Spline Interpolation"), _TL("B-Spline Interpolation") ), 4 ); //----------------------------------------------------- Parameters.Add_Choice( pNode , "TARGET_TYPE" , _TL("Target"), _TL(""), CSG_String::Format(SG_T("%s|%s|%s|"), _TL("user defined grid system"), _TL("existing grid system"), _TL("points") ), 0 ); Parameters.Add_Value( pNode , "TARGET_AREA" , _TL("Use Target Area Polygon"), _TL(""), PARAMETER_TYPE_Bool, false ); //----------------------------------------------------- CSG_Parameters *pParameters = Add_Parameters("POINTS", _TL("Points"), _TL("")); pParameters->Add_Shapes( NULL , "POINTS" , _TL("Points"), _TL(""), PARAMETER_OUTPUT, SHAPE_TYPE_Point ); }
//--------------------------------------------------------- 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 ); }
//--------------------------------------------------------- bool CSG_Grid::_Save_Native(const CSG_String &File_Name, int xA, int yA, int xN, int yN, bool bBinary) { bool bResult = false; CSG_File Stream; if( Stream.Open(File_Name, SG_FILE_W, false) ) { //------------------------------------------------- // Header... Stream.Printf(SG_T("%s\t= %s\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_NAME ], Get_Name() ); Stream.Printf(SG_T("%s\t= %s\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_DESCRIPTION ], Get_Description() ); Stream.Printf(SG_T("%s\t= %s\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_UNITNAME ], Get_Unit() ); Stream.Printf(SG_T("%s\t= %d\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_DATAFILE_OFFSET], 0 ); Stream.Printf(SG_T("%s\t= %s\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_DATAFORMAT ], bBinary ? gSG_Data_Type_Identifier[Get_Type()] : SG_T("ASCII") ); Stream.Printf(SG_T("%s\t= %s\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_BYTEORDER_BIG ], GRID_FILE_KEY_FALSE ); Stream.Printf(SG_T("%s\t= %.10f\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_POSITION_XMIN ], Get_XMin() + Get_Cellsize() * xA ); Stream.Printf(SG_T("%s\t= %.10f\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_POSITION_YMIN ], Get_YMin() + Get_Cellsize() * yA ); Stream.Printf(SG_T("%s\t= %d\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_CELLCOUNT_X ], xN ); Stream.Printf(SG_T("%s\t= %d\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_CELLCOUNT_Y ], yN ); Stream.Printf(SG_T("%s\t= %.10f\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_CELLSIZE ], Get_Cellsize() ); Stream.Printf(SG_T("%s\t= %f\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_Z_FACTOR ], m_zFactor ); Stream.Printf(SG_T("%s\t= %f\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_NODATA_VALUE ], Get_NoData_Value() ); Stream.Printf(SG_T("%s\t= %s\n") , gSG_Grid_File_Key_Names[ GRID_FILE_KEY_TOPTOBOTTOM ], GRID_FILE_KEY_FALSE ); //------------------------------------------------- // Data... if( Stream.Open(SG_File_Make_Path(NULL, File_Name, SG_T("sdat")), SG_FILE_W, true) ) { if( bBinary ) { bResult = _Save_Binary (Stream, xA, yA, xN, yN, Get_Type(), false, false); } else { bResult = _Save_ASCII (Stream, xA, yA, xN, yN); } } } return( bResult ); }
//--------------------------------------------------------- CCRS_Transform_Grid::CCRS_Transform_Grid(bool bList) { 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()); //----------------------------------------------------- Parameters.Add_Node(NULL, "SOURCE_NODE" , _TL("Source"), _TL("") ); if( m_bList ) { Parameters.Add_Grid_List(Parameters("SOURCE_NODE"), "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); } else { Parameters.Add_Grid(Parameters("SOURCE_NODE"), "SOURCE" , _TL("Source"), _TL(""), PARAMETER_INPUT ); } //----------------------------------------------------- Parameters.Add_Node(NULL, "TARGET_NODE" , _TL("Target"), _TL("") ); 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 ); Parameters.Add_Bool(Parameters("TARGET_NODE"), "KEEP_TYPE" , _TL("Preserve Data Type"), _TL(""), false ); Parameters.Add_Bool(Parameters("TARGET_NODE"), "TARGET_AREA" , _TL("Use Target Area Polygon"), _TL("Restricts targeted grid cells to area of the projected bounding rectangle. Useful with certain projections for global data."), false ); //----------------------------------------------------- m_Grid_Target.Create(&Parameters, false, Parameters("TARGET_NODE"), "TARGET_"); if( m_bList ) { Parameters.Add_Grid_List(Parameters("TARGET_NODE"), "GRIDS" , _TL("Target"), _TL(""), PARAMETER_OUTPUT_OPTIONAL ); } else { 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); }