亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mitab_geometry.cpp

?? 支持各種柵格圖像和矢量圖像讀取的庫
?? CPP
字號:
/********************************************************************** * $Id: mitab_geometry.cpp,v 1.5 2004/06/30 20:29:04 dmorissette Exp $ * * Name:     mitab_geometry.cpp * Project:  MapInfo TAB Read/Write library * Language: C++ * Purpose:  Geometry manipulation functions. * Author:   Daniel Morissette, dmorissette@dmsolutions.ca *           Based on functions from mapprimitive.c/mapsearch.c in the source *           of UMN MapServer by Stephen Lime (http://mapserver.gis.umn.edu/) ********************************************************************** * Copyright (c) 1999-2001, Daniel Morissette * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: *  * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. *  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER  * DEALINGS IN THE SOFTWARE. ********************************************************************** * * $Log: mitab_geometry.cpp,v $ * Revision 1.5  2004/06/30 20:29:04  dmorissette * Fixed refs to old address danmo@videotron.ca * * Revision 1.4  2001/12/18 23:42:28  daniel * Added a test in OGRPolygonLabelPoint() to prevent returning a point * outside of the polygon MBR (bug 673). * * Revision 1.3  2001/01/22 16:03:58  warmerda * expanded tabs * * Revision 1.2  2000/09/28 16:39:44  warmerda * avoid warnings for unused, and unitialized variables * * Revision 1.1  2000/09/19 17:19:40  daniel * Initial Revision * **********************************************************************/#include "ogr_geometry.h"#define OGR_NUM_RINGS(poly)   (poly->getNumInteriorRings()+1)#define OGR_GET_RING(poly, i) (i==0?poly->getExteriorRing():poly->getInteriorRing(i-1))/********************************************************************** *                   OGRPointInRing() * * Returns TRUE is point is inside ring, FALSE otherwise * * Adapted version of msPointInPolygon() from MapServer's mapsearch.c **********************************************************************/GBool OGRPointInRing(OGRPoint *poPoint, OGRLineString *poRing){    int i, j, numpoints;    GBool status = FALSE;    double x, y;    numpoints = poRing->getNumPoints();    x = poPoint->getX();    y = poPoint->getY();    for (i = 0, j = numpoints-1; i < numpoints; j = i++)     {        if ((((poRing->getY(i)<=y) && (y<poRing->getY(j))) ||              ((poRing->getY(j)<=y) && (y<poRing->getY(i)))) &&             (x < (poRing->getX(j) - poRing->getX(i)) * (y - poRing->getY(i)) /                  (poRing->getY(j) - poRing->getY(i)) + poRing->getX(i)))            status = !status;    }    return status;}/********************************************************************** *                   OGRIntersectPointPolygon() * * Instead of using ring orientation we count the number of parts the * point falls in. If odd the point is in the polygon, if 0 or even * then the point is in a hole or completely outside. * * Returns TRUE is point is inside polygon, FALSE otherwise * * Adapted version of msIntersectPointPolygon() from MapServer's mapsearch.c **********************************************************************/GBool OGRIntersectPointPolygon(OGRPoint *poPoint, OGRPolygon *poPoly) {    int i;    GBool status = FALSE;    for(i=0; i<OGR_NUM_RINGS(poPoly); i++)     {        if (OGRPointInRing(poPoint, OGR_GET_RING(poPoly, i)))         {            /* ok, the point is in a line */            status = !status;        }    }    return status;}/********************************************************************** *                   OGRPolygonLabelPoint() * * Generate a label point on the surface of a polygon. *  * The function is based on a scanline conversion routine used for polygon  * fills.  Instead of processing each line the as with drawing, the * polygon is sampled. The center of the longest sample is chosen for the  * label point. The label point is guaranteed to be in the polygon even if  * it has holes assuming the polygon is properly formed. *  * Returns OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise. * * Adapted version of msPolygonLabelPoint() from MapServer's mapprimitive.c **********************************************************************/typedef enum {CLIP_LEFT, CLIP_MIDDLE, CLIP_RIGHT} CLIP_STATE;#define CLIP_CHECK(min, a, max) ((a) < (min) ? CLIP_LEFT : ((a) > (max) ? CLIP_RIGHT : CLIP_MIDDLE));#define ROUND(a)       ( (a) + 0.5 )#define SWAP( a, b, t) ( (t) = (a), (a) = (b), (b) = (t) )#define EDGE_CHECK( x0, x, x1) ((x) < MIN( (x0), (x1)) ? CLIP_LEFT : ((x) > MAX( (x0), (x1)) ? CLIP_RIGHT : CLIP_MIDDLE ))#define NUM_SCANLINES 5int OGRPolygonLabelPoint(OGRPolygon *poPoly, OGRPoint *poLabelPoint){    double        slope;    OGRRawPoint   point1, point2;    int           i, j, k, nfound;    double        x, y, *xintersect, temp;    double        hi_y, lo_y;    int           wrong_order, n;    double        len, max_len=0;    double        skip;    OGREnvelope   oEnv;    if (poPoly == NULL)        return OGRERR_FAILURE;    poPoly->getEnvelope(&oEnv);    poLabelPoint->setX((oEnv.MaxX + oEnv.MinX)/2.0);    poLabelPoint->setY((oEnv.MaxY + oEnv.MinY)/2.0);    //if(get_centroid(p, lp, &miny, &maxy) == -1) return(-1);    if(OGRIntersectPointPolygon(poLabelPoint, poPoly) == TRUE) /* cool, done */        return OGRERR_NONE;    /* do it the hard way - scanline */    skip = (oEnv.MaxY - oEnv.MinY)/NUM_SCANLINES;    n=0;    for(j=0; j<OGR_NUM_RINGS(poPoly); j++)     {        /* count total number of points */        n += OGR_GET_RING(poPoly, j)->getNumPoints();    }    xintersect = (double *)calloc(n, sizeof(double));    if (xintersect == NULL)        return OGRERR_FAILURE;    for(k=1; k<=NUM_SCANLINES; k++)     {         /* sample the shape in the y direction */            y = oEnv.MaxY - k*skip;         /* need to find a y that won't intersect any vertices exactly */          hi_y = y - 1; /* first initializing lo_y, hi_y to be any 2 pnts on either side of lp->y */        lo_y = y + 1;        for(j=0; j<OGR_NUM_RINGS(poPoly); j++)         {            OGRLinearRing *poRing = OGR_GET_RING(poPoly,j);            if((lo_y < y) && (hi_y >= y))                 break; /* already initialized */            for(i=0; i < poRing->getNumPoints(); i++)             {                   if((lo_y < y) && (hi_y >= y))                     break; /* already initialized */                if(poRing->getY(i) < y)                    lo_y = poRing->getY(i);                if(poRing->getY(i) >= y)                    hi_y = poRing->getY(i);            }        }        n=0;        for(j=0; j<OGR_NUM_RINGS(poPoly); j++)         {            OGRLinearRing *poRing = OGR_GET_RING(poPoly,j);            for(i=0; i < poRing->getNumPoints(); i++)             {                if((poRing->getY(i) < y) &&                    ((y - poRing->getY(i)) < (y - lo_y)))                    lo_y = poRing->getY(i);                if((poRing->getY(i) >= y) &&                    ((poRing->getY(i) - y) < (hi_y - y)))                    hi_y = poRing->getY(i);            }              }        if(lo_y == hi_y)             return OGRERR_FAILURE;        else              y = (hi_y + lo_y)/2.0;                nfound = 0;        for(j=0; j<OGR_NUM_RINGS(poPoly); j++)   /* for each line */        {            OGRLinearRing *poRing = OGR_GET_RING(poPoly,j);            point1.x = poRing->getX(poRing->getNumPoints()-1);            point1.y = poRing->getY(poRing->getNumPoints()-1);            for(i=0; i < poRing->getNumPoints(); i++)             {                point2.x = poRing->getX(i);                point2.y = poRing->getY(i);                        if(EDGE_CHECK(point1.y, y, point2.y) == CLIP_MIDDLE)                 {                    if(point1.y == point2.y)                        continue; /* ignore horizontal edges */                    else                        slope = (point2.x - point1.x) / (point2.y - point1.y);                              x = point1.x + (y - point1.y)*slope;                    xintersect[nfound++] = x;                } /* End of checking this edge */                        point1 = point2;  /* Go on to next edge */            }        } /* Finished the scanline */            /* First, sort the intersections */        do         {            wrong_order = 0;            for(i=0; i < nfound-1; i++)             {                if(xintersect[i] > xintersect[i+1])                 {                    wrong_order = 1;                    SWAP(xintersect[i], xintersect[i+1], temp);                }            }        } while(wrong_order);            /* Great, now find longest span */        point1.y = point2.y = y;        for(i=0; i < nfound; i += 2)         {            point1.x = xintersect[i];            point2.x = xintersect[i+1];            /* len = length(point1, point2); */            len = ABS((point2.x - point1.x));            if(len > max_len)             {                max_len = len;                poLabelPoint->setX( (point1.x + point2.x)/2 );                poLabelPoint->setY( y );            }        }    }    free(xintersect);    /* __TODO__ Bug 673     * There seem to be some polygons for which the label is returned     * completely outside of the polygon's MBR and this messes the      * file bounds, etc.     * Until we find the source of the problem, we'll at least validate     * the label point to make sure that it overlaps the polygon MBR.     */    if( poLabelPoint->getX() < oEnv.MinX        || poLabelPoint->getY() < oEnv.MinY        || poLabelPoint->getX() > oEnv.MaxX        || poLabelPoint->getY() > oEnv.MaxY )    {        // Reset label coordinates to center of MBR, just in case        poLabelPoint->setX((oEnv.MaxX + oEnv.MinX)/2.0);        poLabelPoint->setY((oEnv.MaxY + oEnv.MinY)/2.0);        // And return an error        return OGRERR_FAILURE;    }    if(max_len > 0)        return OGRERR_NONE;    else        return OGRERR_FAILURE;}/********************************************************************** *                   OGRGetCentroid() * * Calculate polygon gravity center. *  * Returns OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise. * * Adapted version of get_centroid() from MapServer's mapprimitive.c **********************************************************************/int OGRGetCentroid(OGRPolygon *poPoly, OGRPoint *poCentroid){    int i,j;    double cent_weight_x=0.0, cent_weight_y=0.0;    double len, total_len=0;    for(i=0; i<OGR_NUM_RINGS(poPoly); i++)     {        double x1, y1, x2, y2;        OGRLinearRing *poRing = OGR_GET_RING(poPoly, i);        x2 = poRing->getX(0);        y2 = poRing->getY(0);        for(j=1; j<poRing->getNumPoints(); j++)         {            x1 = x2;            y1 = y2;            x2 = poRing->getX(j);            y2 = poRing->getY(j);            len = sqrt( pow((x2-x1),2) + pow((y2-y1),2) );            cent_weight_x += len * ((x1 + x2)/2.0);            cent_weight_y += len * ((y1 + y2)/2.0);            total_len += len;        }    }    if(total_len == 0)        return(OGRERR_FAILURE);    poCentroid->setX( cent_weight_x / total_len );    poCentroid->setY( cent_weight_y / total_len );      return OGRERR_NONE;}/********************************************************************** *                   OGRPolylineCenterPoint() * * Return the center point of a polyline. * * In MapInfo, for a simple or multiple polyline (pline), the center point  * in the object definition is supposed to be either the center point of  * the pline or the first section of a multiple pline (if an odd number of  * points in the pline or first section), or the midway point between the  * two central points (if an even number of points involved).  * * Returns OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise. **********************************************************************/int OGRPolylineCenterPoint(OGRLineString *poLine, OGRPoint *poLabelPoint){    if (poLine == NULL || poLine->getNumPoints() < 2)        return OGRERR_FAILURE;    if (poLine->getNumPoints() % 2 == 0)    {        // Return the midway between the 2 center points        int i = poLine->getNumPoints()/2;        poLabelPoint->setX( (poLine->getX(i-1) + poLine->getX(i))/2.0 );        poLabelPoint->setY( (poLine->getY(i-1) + poLine->getY(i))/2.0 );    }    else    {        // Return the center point        poLine->getPoint(poLine->getNumPoints()/2, poLabelPoint);    }        return OGRERR_NONE;}/********************************************************************** *                   OGRPolylineLabelPoint() * * Generate a label point on a polyline: The center of the longest segment. * * Returns OGRERR_NONE if it succeeds or OGRERR_FAILURE otherwise. **********************************************************************/int OGRPolylineLabelPoint(OGRLineString *poLine, OGRPoint *poLabelPoint){    double      segment_length, max_segment_length = 0.0;    double      x1, y1, x2, y2;    if (poLine == NULL || poLine->getNumPoints() < 2)        return OGRERR_FAILURE;    max_segment_length = -1.0;    x2 = poLine->getX(0);    y2 = poLine->getY(0);    for(int i=1; i<poLine->getNumPoints(); i++)     {        x1 = x2;        y1 = y2;        x2 = poLine->getX(i);        y2 = poLine->getY(i);        segment_length = pow((x2-x1),2) + pow((y2-y1),2);        if (segment_length > max_segment_length)        {            max_segment_length = segment_length;            poLabelPoint->setX( (x1 + x2)/2.0 );            poLabelPoint->setY( (y1 + y2)/2.0 );        }    }        return OGRERR_NONE;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品亚洲一区二区在线播放| 国产一区二区在线免费观看| jvid福利写真一区二区三区| 欧美r级在线观看| 亚洲天天做日日做天天谢日日欢 | 国产精品久线观看视频| 久久99久久99精品免视看婷婷 | 丝袜美腿亚洲色图| 欧美日韩在线一区二区| 亚洲一区二区三区自拍| 欧美日韩一二区| 日本免费在线视频不卡一不卡二| 久久久久久久久久看片| 国产精品久久久久7777按摩| 国产福利一区二区| 日韩精品一区二区三区在线播放 | 91精品国产综合久久精品图片 | 亚洲色图另类专区| 91黄色激情网站| 亚洲综合男人的天堂| 精品视频999| 一区二区三区四区av| 欧美精品丝袜久久久中文字幕| 亚洲国产精品自拍| 欧美卡1卡2卡| 亚洲国产精品久久一线不卡| 欧美日本国产一区| 日本人妖一区二区| 国产拍揄自揄精品视频麻豆| 91尤物视频在线观看| 亚洲高清视频的网址| 99精品久久99久久久久| 性做久久久久久免费观看| 99re这里都是精品| 五月天激情综合网| 亚洲精品一区二区三区精华液| 高清国产一区二区| 亚洲v中文字幕| 欧美高清精品3d| 另类中文字幕网| 欧美一区二区三区白人| 激情综合色综合久久| 国产欧美一区二区三区在线老狼| 91首页免费视频| 一区二区高清免费观看影视大全 | 毛片一区二区三区| 国产精品午夜免费| 91毛片在线观看| 欧美96一区二区免费视频| 国产农村妇女精品| 欧美一区二区成人| 色一区在线观看| 国产另类ts人妖一区二区| 亚洲制服丝袜av| 欧美一级xxx| 成人深夜视频在线观看| 偷拍与自拍一区| 中文字幕一区二区不卡| 日韩一区二区三区免费看| 91老司机福利 在线| 免费观看在线综合| 一区二区三区四区av| 日本一区二区三区在线不卡| 欧美群妇大交群的观看方式| 成人黄色在线视频| 久久99精品久久久久久| 亚洲久草在线视频| 日韩视频免费直播| 欧美性大战久久久| eeuss鲁一区二区三区| 国产一区二区三区国产| 热久久一区二区| 午夜一区二区三区在线观看| 国产日韩综合av| 久久先锋影音av| 日韩欧美国产一区在线观看| 欧美日韩视频在线观看一区二区三区 | 国产无遮挡一区二区三区毛片日本| 99久久精品免费看| 国产成人一级电影| 免费观看30秒视频久久| 日韩黄色在线观看| 亚洲福利一二三区| 亚洲在线免费播放| 亚洲嫩草精品久久| 亚洲丝袜精品丝袜在线| 欧美激情一区在线观看| 国产精品丝袜一区| 欧美韩国日本综合| 中文字幕av一区二区三区| 国产午夜精品一区二区| 久久精品综合网| 国产欧美久久久精品影院 | 欧美精品久久99久久在免费线| 91在线porny国产在线看| 色综合天天综合色综合av| 91免费版在线看| 欧美色精品在线视频| 欧美三日本三级三级在线播放| 91日韩在线专区| 色噜噜久久综合| 欧美在线不卡视频| 欧美日韩日本视频| 欧洲另类一二三四区| 日本丰满少妇一区二区三区| 色天天综合久久久久综合片| 99精品视频免费在线观看| 成人av网址在线| 91福利在线导航| 欧美男男青年gay1069videost| 538prom精品视频线放| 日韩欧美国产不卡| 国产亚洲欧美在线| 亚洲视频一二区| 亚洲一区二区综合| 激情欧美一区二区| www.成人网.com| 欧美日韩一区二区在线观看视频| 欧美日韩国产系列| 欧美综合久久久| 欧美区一区二区三区| 久久久精品免费免费| 欧美国产日产图区| 亚洲一区二区成人在线观看| 日日夜夜精品视频免费| 轻轻草成人在线| av中文字幕不卡| 制服丝袜亚洲色图| 亚洲国产成人私人影院tom| 亚洲午夜久久久久久久久电影院| 日本不卡一二三区黄网| 成人午夜电影小说| 欧美狂野另类xxxxoooo| 欧美激情一区二区在线| 亚洲va天堂va国产va久| 国产精品羞羞答答xxdd| 欧美日韩一区二区三区免费看 | 精品国产乱子伦一区| 中文字幕一区在线观看| 欧美aaa在线| 91久久精品一区二区二区| 欧美精品一区二区高清在线观看| 亚洲欧洲精品天堂一级 | 这里只有精品电影| 久久久国产精品麻豆| 亚洲va欧美va国产va天堂影院| 国产成人一区在线| 在线观看一区日韩| 久久精品在线免费观看| 午夜伦欧美伦电影理论片| 99视频精品免费视频| 欧美一区二区三区啪啪| 亚洲精品日韩一| 国产91在线观看| 欧美电视剧免费全集观看| 亚洲在线观看免费视频| 99久久精品一区二区| 26uuu欧美| 免费在线观看精品| 在线观看91精品国产入口| 国产日韩欧美亚洲| 国内成人免费视频| 精品人在线二区三区| 偷拍亚洲欧洲综合| 欧美日韩国产美| 亚洲三级在线播放| 成人蜜臀av电影| 欧美精品一区二区三区蜜臀| 香蕉成人啪国产精品视频综合网| 91色porny蝌蚪| 亚洲欧洲国产日本综合| 成人在线一区二区三区| 久久久久国产精品人| 久国产精品韩国三级视频| 欧美一区二区免费| 日本亚洲三级在线| 欧美一级日韩免费不卡| 日本视频一区二区三区| 欧美日韩高清在线播放| 天天综合天天做天天综合| 欧美日韩一区二区在线视频| 亚洲国产三级在线| 欧美久久免费观看| 日韩精品电影在线观看| 欧美日韩在线不卡| 亚洲高清免费观看高清完整版在线观看| 成人激情免费视频| 自拍偷在线精品自拍偷无码专区 | 欧美一级在线视频| 蜜臀久久99精品久久久画质超高清 | 久久免费美女视频| 国产福利一区二区三区视频在线| 欧美一区二区女人| 午夜久久久久久电影| 欧美日韩免费一区二区三区| 亚洲国产成人高清精品| 欧美日韩一区二区电影| 天天综合色天天综合色h| 制服视频三区第一页精品| 国产美女娇喘av呻吟久久|