Пример #1
0
/*!
   \brief (Re)Attach isles in given bounding box to areas
   
   The warning for Vect_attach_centroids() applies here as well

   \param Map vector map
   \param box bounding box

   \return 0
 */
int Vect_attach_isles(struct Map_info *Map, const struct bound_box *box)
{
    int i, isle, area;
    struct bound_box abox;
    static struct boxlist *List = NULL;
    struct Plus_head *plus;

    G_debug(3, "Vect_attach_isles()");
      
    plus = &(Map->plus);

    if (!List)
	List = Vect_new_boxlist(TRUE);

    Vect_select_isles_by_box(Map, box, List);
    G_debug(3, "  number of isles to attach = %d", List->n_values);

    for (i = 0; i < List->n_values; i++) {
	isle = List->id[i];

	area = plus->Isle[isle]->area;

	if (area > 0) {
	    /* if the area box is not fully inside the box, detach
	     * this might detach more than needed, 
	     * but all that need to be reattached and
	     * is faster than reattaching all */
	    Vect_get_area_box(Map, area, &abox);
	    if (box->W < abox.W && box->E > abox.E &&
	        box->S < abox.S && box->N > abox.N) {
		G_debug(3, "Outer area is fully inside search box");
	    }
	    else {
		dig_area_del_isle(plus, area, isle);
		plus->Isle[isle]->area = 0;
		area = 0;
	    }
	}

	if (area == 0)
	    Vect_attach_isle(Map, isle, &List->box[i]);
    }
    return 0;
}
Пример #2
0
/*!
 * \brief Delete island from Plus_head structure
 *
 * Reset references to it in lines and area outside.
 *
 * \param[in] plus pointer to Plus_head structure
 * \param[in] isle isle id
 *
 * \return 1
 */
int dig_del_isle(struct Plus_head *plus, int isle)
{
    int i, line;
    struct P_line *Line;
    struct P_isle *Isle;
    struct P_topo_b *topo;

    G_debug(3, "dig_del_isle() isle =  %d", isle);
    Isle = plus->Isle[isle];

    dig_spidx_del_isle(plus, isle);

    /* Set area for all lines to 0 */
    for (i = 0; i < Isle->n_lines; i++) {
	line = Isle->lines[i];	/* >0 = clockwise -> right, <0 = counterclockwise ->left */
	Line = plus->Line[abs(line)];
	topo = (struct P_topo_b *)Line->topo;
	if (plus->do_uplist)
	    dig_line_add_updated(plus, abs(line));
	if (line > 0)
	    topo->right = 0;
	else
	    topo->left = 0;
    }

    /* Delete reference from area it is within */
    G_debug(3, "  area outside isle = %d", Isle->area);
    if (Isle->area > 0) {
	if (plus->Area[Isle->area] == NULL) {
	    G_fatal_error(_("Attempt to delete isle %d info from dead area %d"),
			  isle, Isle->area);
	}
	else {
	    dig_area_del_isle(plus, Isle->area, isle);
	}
    }

    /* free structures */
    dig_free_isle(Isle);
    plus->Isle[isle] = NULL;

    return 1;
}