Ejemplo n.º 1
0
/*!
 * \brief Check if pole is in polygon
 *
 * For latitude-longitude coordinates, this routine determines if the polygon
 * defined by the <i>n</i> coordinate vertices <i>x,y</i> contains one of the
 * poles.
 *
 * <b>Note:</b> Use this routine only if the projection is PROJECTION_LL.
 *
 *  \param x array of x coordinates
 *  \param y array of y coordinates
 *  \param n number of coordinates
 * 
 * \return -1 if it contains the south pole
 * \return 1 if it contains the north pole
 * \return 0 if it contains neither pole.
 */
int G_pole_in_polygon(const double *x, const double *y, int n)
{
    int i;
    double len, area, total_len, total_area;

    if (n <= 1)
	return 0;

    mystats(x[n - 1], y[n - 1], x[0], y[0], &total_len, &total_area);
    for (i = 1; i < n; i++) {
	mystats(x[i - 1], y[i - 1], x[i], y[i], &len, &area);
	total_len += len;
	total_area += area;
    }

    /* if polygon contains a pole then the x-coordinate length of
     * the perimeter should compute to 0, otherwise it should be about 360
     * (or -360, depending on the direction of perimeter traversal)
     *
     * instead of checking for exactly 0, check from -1 to 1 to avoid
     * roundoff error.
     */
    if (total_len < 1.0 && total_len > -1.0)
	return 0;

    return total_area >= 0.0 ? 1 : -1;
}
Ejemplo n.º 2
0
    int CStatsUtil::DoExportGameStrings()
    {
        Poco::Path inpath(m_inputPath);
        Poco::Path outpath;

        if( m_outputPath.empty() )
        {
            outpath = inpath.parent().append(DefExportStrName).makeFile();
        }
        else
        {
            Poco::File outfilecheck(m_outputPath);  //Check if output is a directory

            if( outfilecheck.exists() && outfilecheck.isDirectory() )
                outpath = Poco::Path(m_outputPath).append(DefExportStrName).makeFile();
            else
                outpath = Poco::Path(m_outputPath);
        }

        if( !m_forcedLocale )
        {
            cout << "Detecting game language...\n";
            GameStats mystats( m_inputPath, m_langconf );
            mystats.LoadStrings();
            cout << "Writing...\n";
            mystats.ExportStrings( outpath.toString() );
        }
        else
        {
            cout << "A forced locale string was specified! Skipping game language detection.\n";
            vector<string> gamestrings;
            pmd2::filetypes::ParseTextStrFile( inpath.toString(), std::locale(m_flocalestr) );
            WriteTextFileLineByLine( gamestrings, outpath.toString() );
        }
        return 0;
    }