Пример #1
0
/**
  * Check if point is inside polgone.
  * @param in *cp array of polygon vertex coordinates
  * @param in count count of polygon vertexes
  * @param in *c point coordinates 
  * @returns 1 - inside, 0 - outside
  */
int
geom_poly_point_inside(struct coord *cp, int count, struct coord *c)
{
	int ret=0;
	struct coord *last=cp+count-1;
	while (cp < last) {
		if ((cp[0].y > c->y) != (cp[1].y > c->y) &&
			c->x < ((long long)cp[1].x-cp[0].x)*(c->y-cp[0].y)/(cp[1].y-cp[0].y)+cp[0].x) {
#if 0
			fprintf(stderr," cross 0x%x,0x%x-0x%x,0x%x %dx%d",cp,cp[0].x,cp[0].y,cp[1].x,cp[1].y,cp[1].x-cp[0].x,c->y-cp[0].y);
			printf("type=selected_line\n");
			coord_print(projection_mg, &cp[0], stdout);
			coord_print(projection_mg, &cp[1], stdout);
#endif
			ret=!ret;
		}
		cp++;
	}
	return ret;
}
Пример #2
0
void
bookmarks_write_center_to_file(struct bookmarks *this_, char *file)
{
	dbg(0,"EEnter\n");

	FILE *f;
	enum projection pro;
	struct coord *center;

	f = fopen(file, "w+");
	if (f)
	{
		// save (pixel-on-screen width/2 height/2) screen center
		struct coord_geo g22;
		struct coord c22;
		struct point p;

		int width, height;
		transform_get_size(this_->trans, &width, &height);
		p.x=width/2;
		p.y=height/2;

		transform_reverse(this_->trans, &p, &c22);
		//dbg(0,"%f, %f\n",a, b);
		//dbg(0,"%d, %d\n",p.x, p.y);
		// * transform_to_geo(projection_mg, &c22, &g22);
		//dbg(0,"%d, %d, %f, %f\n",c22.x, c22.y, g22.lat, g22.lng);
		// * result=g_strdup_printf("%f:%f",g22.lat,g22.lng);

		// + center = transform_center(this_->trans);
		pro = transform_get_projection(this_->trans);
		// + coord_print(pro, center, f);
		coord_print(pro, &c22, f);
		fclose(f);
		dbg(0,"******** write center to file *********\n");
	}
	else
	{
		perror(file);
	}

	dbg(0,"ready\n");

	return;
}