Esempio n. 1
0
  Datum  spherepoly_in(PG_FUNCTION_ARGS)
  {
    SPOLY * poly ;
    char  * c  = PG_GETARG_CSTRING(0);
    static int32  i, nelem;

    void sphere_yyparse( void );
    init_buffer ( c );
    sphere_yyparse() ;

    nelem = get_path_count( ) ;
    if ( nelem > 2 ){
      SPoint arr[nelem];
      for ( i = 0; i<nelem ; i++ ){
         get_path_elem ( i , &arr[i].lng , &arr[i].lat );
      }
      poly  = spherepoly_from_array ( &arr[0], nelem );
    } else {
      reset_buffer();
      elog ( ERROR , "spherepoly_in: more than two points needed" );
      PG_RETURN_NULL();
    }
    reset_buffer();

    PG_RETURN_POINTER( poly );
  }
Esempio n. 2
0
main()
{
	int srcrow,srccol,destrow,destcol;
	char sinput[10];

	show_menu();

	scanf("%s",sinput);
	while(stricmp(sinput,"q")!=0)
	{
		if(stricmp(sinput,"p")==0)
		{
			printf("$ input src point :  col(a~h) >");
			scanf("%s",sinput);				
			srccol=sinput[0]-96;

			printf("$ input src point :  row(1~8) >");
			scanf("%d",&srcrow);

			printf("$ input dest point : col(a~h) >");
			scanf("%s",sinput);
			destcol=sinput[0]-96;

			printf("$ input dest point : row(1~8) >");
			scanf("%d",&destrow);

			//求解
			int nMinStep=knight_walk(srcrow,srccol,destrow,destcol);
			int nMinStepCount=min_step_count(nMinStep);

			//显示最短路径
			printf("\n%c%d to %c%d : min step = %d\n",srccol+96,srcrow,destcol+96,destrow,nMinStep);
			
			//显示要搜索的路径个数及其最短路径个数
			printf("path number searched =%d, min path number = %d\n\n",pathcount,nMinStepCount);			

			printf("$ display All searched path,Min path or Return (A,M,R)? >");
			scanf("%s",sinput);
			while(stricmp(sinput,"r")!=0)
			{
				if(stricmp(sinput,"a")==0)		//显示所有路径
				{
					//输出所有路径
					output_all_path(srcrow,srccol,destrow,destcol,pathcount,nMinStep,nMinStepCount);

					//输入命令
					printf("$ display All searched path,Min path or Return (A,M,R)? >");
					scanf("%s",sinput);
				}
				else if(stricmp(sinput,"m")==0)	//显示最短路径
				{
					//输出最短路径
					output_min_path(srcrow,srccol,destrow,destcol,pathcount,nMinStep,nMinStepCount);

					//输入命令
					printf("$ display All searched path,Min path or Return (A,M,R)? >");
					scanf("%s",sinput);
				}
				else if(stricmp(sinput,"r")==0)
					break;
			}
		}
		else if(stricmp(sinput,"g")==0)
		{
			//得到所有任意两点间路径个数
			get_path_count();

			printf("max path number searched of all two points: %d\n",maxpathcount);
			printf("max path number of all min step count : %d\n\n",maxminstep);
		}
		else if(stricmp(sinput,"w")==0)
		{
			//得到所有任意两点间路径个数并写入文件
			get_and_write_path_count();

			printf("max path number searched of all two points: %d\n",maxpathcount);
			printf("max path number of all min step count : %d\n\n",maxminstep);
		}

		//输入命令
		printf("$ input command >");
		scanf("%s",sinput);
	}

	return 0;
}