//--------------------------------------------------------- bool CSG_HTTP::Request(const CSG_String &Request, CSG_String &Answer) { wxInputStream *pStream = _Request(Request); if( !pStream ) { return( false ); } //if( pStream->GetSize() == ((size_t)-1) ) //{ // delete(pStream); // return( false ); //} Answer.Clear(); while( pStream->CanRead() ) { char Byte; pStream->Read(&Byte, sizeof(Byte)); Answer += Byte; } delete(pStream); return( true ); }
//--------------------------------------------------------- bool CSG_Shapes_OGIS_Converter::_WKT_Read_Polygon(const CSG_String &Text, CSG_Shape *pShape) { CSG_String Part; for(int i=0, Level=-2; i<(int)Text.Length(); i++) { if( Text[i] == '(' ) { Level++; } else if( Text[i] == ')' ) { if( Level == 0 ) { Part += Text[i]; _WKT_Read_Parts(Part, pShape); Part.Clear(); } Level--; } if( Level >= 0 ) { Part += Text[i]; } } return( pShape->Get_Part_Count() > 0 ); }
//--------------------------------------------------------- int CSG_ODBC_Connections::Get_Connections(CSG_String &Connections) { CSG_Strings s = Get_Connections(); Connections.Clear(); for(int i=0; i<s.Get_Count(); i++) { Connections += CSG_String::Format(SG_T("%s|"), s[i].c_str()); } return( s.Get_Count() ); }
//--------------------------------------------------------- int CTL_Extract::Read_Text(const SG_Char *String, CSG_String &Text) { int n, Level; Text.Clear(); for(n=0, Level=-1; String[n]!='\0' && Level<2; n++) { if( Level < 0 ) { if( String[n] == '(' ) { Level = 0; } else if( isspace(String[n]) ) { Level = 2; // exit ! } } else if( Level == 0 ) { switch( String[n] ) { case '\"': Level = 1; break; case ')': Level = 2; break; } } else switch( String[n] ) { case '\"': Level = 0; break; case '\\': Text.Append(String[n++]); Text.Append(String[n]); break; default: Text.Append(String[n]); break; } } return( n ); }
//--------------------------------------------------------- bool CSG_CURL::Request(const CSG_String &Request, CSG_String &Answer) { if( !is_Connected() ) { return( false ); } Answer.Clear(); CSG_String URL = m_Server + "/" + Request; CURL_SET_OPT(1, CURLOPT_URL , URL.b_str()); CURL_SET_OPT(1, CURLOPT_FOLLOWLOCATION, 1L); CURL_SET_OPT(1, CURLOPT_WRITEFUNCTION , _Callback_Write_String); CURL_SET_OPT(1, CURLOPT_WRITEDATA , &Answer); return( _Perform() ); }
//--------------------------------------------------------- const SG_Char * CSG_Formula::Get_Used_Variables(void) { static CSG_String ret; ret.Clear(); for(int i=0; i<'z'-'a'; i++) { if( m_Vars_Used[i] == true ) { ret.Append((SG_Char)(i + 'a')); } } return( ret ); }
//--------------------------------------------------------- bool SG_Read_Line(FILE *Stream, CSG_String &Line) { char c; if( Stream && !feof(Stream) ) { Line.Clear(); while( !feof(Stream) && (c = fgetc(Stream)) != 0x0A && c != 0x0D ) { Line.Append(c); } return( true ); } return( false ); }
bool CSG_File::Scan(CSG_String &Value, SG_Char Separator) const { if( m_pStream && !feof(m_pStream) ) { int c; Value.Clear(); while( !feof(m_pStream) && (c = fgetc(m_pStream)) != Separator && c != EOF ) { Value += c; } return( true ); } return( false ); }
//--------------------------------------------------------- bool CSG_File::Read_Line(CSG_String &sLine) const { int c; if( m_pStream && !feof(m_pStream) ) { sLine.Clear(); while( !feof(m_pStream) && (c = fgetc(m_pStream)) != 0x0A && c != EOF ) { if( c != 0x0D ) { sLine.Append(SG_STR_MBTOSG(c)); } } return( true ); } return( false ); }
//--------------------------------------------------------- int CDecision_Tree::Get_Class(CSG_Parameters *pDecision, const TSG_Point &Point) { double Value; CSG_Grid *pGrid = pDecision->Get_Parameter("GRID")->asGrid(); if( pGrid && pGrid->Get_Value(Point, Value) ) { CSG_String ID = pDecision->Get_Identifier(); if( !ID.Cmp(SG_T("ROOT")) ) ID.Clear(); ID += Value < pDecision->Get_Parameter("THRESHOLD")->asDouble() ? SG_T("A") : SG_T("B"); if( pDecision->Get_Parameter(ID + SG_T("|NODE"))->asBool() ) { return( Get_Class(pDecision->Get_Parameter(ID)->asParameters(), Point) ); } else { return( Get_Class(ID) ); } } return( -1 ); }