- /* Split and count polygons */
- gchar **spolys = g_strsplit(str, poly_sep, -1);
- int npolys = g_strv_length(spolys);
-
- GritsBounds bounds = {-90, 90, -180, 180};
- gdouble (**polys)[3] = (gpointer)g_new0(double*, npolys+1);
- for (int pi = 0; pi < npolys; pi++) {
- /* Split and count coordinates */
- gchar **scoords = g_strsplit(spolys[pi], point_sep, -1);
- int ncoords = g_strv_length(scoords);
-
- /* Create binary coords */
- gdouble (*coords)[3] = (gpointer)g_new0(gdouble, 3*(ncoords+1));
- for (int ci = 0; ci < ncoords; ci++) {
- gdouble lat, lon;
- sscanf(scoords[ci], "%lf,%lf", &lat, &lon);
- if (lat > bounds.n) bounds.n = lat;
- if (lat < bounds.s) bounds.s = lat;
- if (lon > bounds.e) bounds.e = lon;
- if (lon < bounds.w) bounds.w = lon;
- lle2xyz(lat, lon, 0,
- &coords[ci][0],
- &coords[ci][1],
- &coords[ci][2]);
- }
-
- /* Insert coords into poly array */
- polys[pi] = coords;
- g_strfreev(scoords);
- }
- g_strfreev(spolys);
+ GritsPoint center;
+ gdouble (**polys)[3] = parse_points(str,
+ poly_sep, point_sep, coord_sep, NULL, ¢er);