热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

地图上2不同区域内的路网存储过程

createprocedurerelation_line@Intersectionsvarchar(500),@StartpointXint,@StartpointYint,@

create procedure relation_line
@Intersections varchar(500),
@StartpointX int,
@StartpointY int,
@EndpointX int,
@EndpointY int,
@Split varchar(1)=';',
@SplitXY varchar(1)=',',
@XYarea int =100,
@area decimal(18,6) =0.00001,
@Usefulline varchar(255) output
as
begin
  declare @Oldintersections varchar(500)
  declare @Length int
  declare @CommaLocation int
  declare @FirstPoint varchar(18)
  declare @Longitude varchar(9)
  declare @latitude varchar(9)
  declare @logicalx varchar(6)
  declare @logicaly varchar(6)
  declare @LengthXY int
  declare @LengthFirstSplit int
  declare @LastLineids varchar(16)
  declare @ThisLineids varchar(16)
  declare @isExistLine varchar(2)
  declare @Index_line int
  declare @Clineid  int
  declare @Cpointid int
    ----对线路中所有路口点处理
    select @OldintersectiOns=@Intersections
    select @CommaLocation=CHARINDEX(@Split, @Oldintersections)
    while(@CommaLocation>0) and (@Oldintersections is not null)
    begin
        set @isExistLine='no'
        select @CommaLocation=CHARINDEX(@Split, @Oldintersections)
        select @Length=DATALENGTH(@Oldintersections)
        select @FirstPoint=SUBSTRING(@Oldintersections,1,@CommaLocation-1)
        print @FirstPoint
        if @FirstPoint is not null
        begin
            select @LengthXY=DATALENGTH(@FirstPoint)
            select @LengthFirstSplit=CHARINDEX(@SplitXY,@FirstPoint)
        end
        if @LengthXY>0
        begin
            select @LOngitude=SUBSTRING(@FirstPoint,1,@LengthFirstSplit-1)
            select @latitude=SUBSTRING(@FirstPoint,@LengthFirstSplit+1,@LengthXY-@LengthFirstSplit)
            if @ThisLineids is not null
            begin
                  select @LastLineids=@ThisLineids
                set @ThisLineids=null
            end
            declare curPointline cursor  for
            select kr.lineid,kr.pointid from kangaroo_roadnet as kr,kangaroo_roadnet_point as krp where kr.pointid=krp.pointid
                and krp.longitude>=cast(@Longitude as decimal(18,6))-@area  and krp.longitude<=cast(@Longitude as decimal(18,6))+@area
                and krp.latitude>=cast(@latitude as decimal(18,6))-@area and krp.latitude<=cast(@latitude as decimal(18,6))+@area
                and krp.pointtype=1
            declare @lineid int
            declare @pointid int
            declare @SubUsefulline varchar(255)
            declare @templp varchar(255)
            declare @lastpointid varchar(5)
            open curPointline
            fetch next from curPointline into @lineid,@pointid
            while ( @@Fetch_Status=0 )
            begin
                if @lineid is not null
                begin
                    select @ThisLineids=@ThisLineids+',l'+@lineid+',p'+@pointid
                end
                else
                begin
                    select @ThisLineids='l'+@lineid+',p'+@pointid
                end
                if @LastLineids is not null
                begin
                    select @Index_line= CHARINDEX('l'+ cast(@lineid as varchar(4)),@LastLineids)
                    if  @Index_line>0
                    begin
                    set @isExistLine='ye'
                    set @templp=substring(@LastLineids,@Index_line+DATALENGTH('l'+cast(@lineid as varchar(4)))+1,DATALENGTH(@LastLineids))
                    set @lastpointid=substring(@templp,2,CHARINDEX(',',@templp)-1)
                          declare getPointXY cursor for
                        select krp.logicalx,krp.logicaly from kangaroo_roadnet as kr,kangaroo_roadnet_point as krp where kr.lineid=@lineid
                             AND (kr.ordernum BETWEEN @lastpointid AND @pointid) ORDER BY kr.ordernum DESC

                        open getPointXY
                        fetch next from getPointXY
                        into @logicalx, @logicaly
                        if @SubUsefulline is not null
                        begin
                            select @SubUsefulline=@SubUsefulline+','+@logicalx+','+@logicaly
                        end
                        else
                        begin
                            select @SubUsefulline=@logicalx+','+@logicaly
                        end
                        close getPointXY
                          deallocate getPointXY   
                    end
                end
            end
            close curPointline
              deallocate curPointline
        end
        if(@isExistLine='ye')
        begin
            set @area=0.00001
            select @OldintersectiOns=SUBSTRING(@Oldintersections, @CommaLocation + 1, @Length - @CommaLocation)
            select @CommaLocation = CHARINDEX(@Split, @Oldintersections)
            if @Usefulline is not null
            begin
                    select @Usefulline=@Usefulline+';'+@SubUsefulline
            end
            else
            begin
                    select @Usefulline=@SubUsefulline
            end
        end
        else
        begin
            set @area=@area+0.00001
        end
    end
    ----对起始终止点处理
    if (@StartpointX is not null) and (@EndpointX is not null) and (@StartpointY is not null) and (@EndpointY is not null)
    begin
       
         if @Usefulline is not null
        declare @Subuserline varchar(255)
        declare @FSubuserline varchar(255)
        declare @FirstX varchar(9)
        declare @FirstY varchar(9)
        declare @LastX varchar(9)
        declare @LastY varchar(9)
        declare @Clogicalx varchar(9)
        declare @Clogicaly varchar(9)
        declare @LinePoints varchar(255)
        declare @int int
        begin
            set @FirstX=left(@Usefulline, charindex(',',@Usefulline)-1)
            set @Subuserline=substring(@Usefulline,charindex(',',@Usefulline)+1,len(@Usefulline))
            --select substring(@Usefulline,charindex(',',@Usefulline)+1,len(@Usefulline))
            set @FirstY=left(@Subuserline, charindex(',',@Subuserline)-1)   
            set @XYarea=100
            set @int=0
            while @int<3
            begin
                set @isExistLine='no'
                declare StartFirstline cursor  for
                SELECT kr1.lineid,krp1.pointid
                FROM kangaroo_roadnet kr1
                INNER JOIN
                      kangaroo_roadnet_point krp1 ON kr1.pointid = krp1.pointid
                where (krp1.logicalx <= @StartpointX+@XYarea and krp1.logicalx >= @StartpointX-@XYarea)

                    AND (krp1.logicaly <= @StartpointY+@XYarea and krp1.logicaly >= @StartpointY-@XYarea)

                    and kr1.lineid in(
                SELECT kr.lineid
                FROM kangaroo_roadnet kr INNER JOIN
                      kangaroo_roadnet_point krp ON kr.pointid = krp.pointid
                WHERE (krp.logicalx = @FirstX) AND (krp.logicaly = @FirstY))
   
                open StartFirstline
                fetch next from StartFirstline into @Clineid,@Cpointid
                while ( @@Fetch_Status=0 )
                begin
                    if @Clineid is not null and @Cpointid is not null
                      begin
                        set @isExistLine='ye'
                        declare StartFirstPoints cursor for
                        select krp1.logicalx,krp1.logicaly from kangaroo_roadnet_point as krp1 where krp1.pointid between @Cpointid and
                        (select krp.pointid from kangaroo_roadnet_point as krp,kangaroo_roadnet as kr
                        where  krp.logicalx=@FirstX and krp.logicaly=@FirstY and krp.pointid=kr.pointid
                        and kr.lineid=@Clineid)
                        open StartFirstPoints
                        fetch next from StartFirstPoints into @Clogicalx,@Clogicaly
                        while ( @@Fetch_Status=0 )
                        begin
                            if @LinePoints is not null
                            begin
                                select @LinePoints=@LinePoints+','+@Clogicalx+','+@Clogicaly
                            end
                            else
                            begin
                                select @LinePoints=@Clogicalx+','+@Clogicaly
                            end
                        end
                        close StartFirstPoints
                          deallocate StartFirstPoints
                    end
                    else
                    begin
                        set @XYarea=@XYarea+100
                    end
                   
                end
                close StartFirstline
                  deallocate StartFirstline
                if(@isExistLine='ye')
                begin
                    if(@Usefulline is not null)
                    begin
                        select @Usefulline=@LinePoints+';'+@Usefulline
                    end
                    else
                    begin
                        select @Usefulline=@LinePoints
                    end
                    break
                end
                else
                begin
                    set @int=@int+1
                end
               
            end
            set @XYarea=100
            set @int=0
            while @int<3
            begin
                set @isExistLine='no'
                set @LastY=right(@Usefulline, charindex(',',reverse(@Usefulline))-1)
                set @FSubuserline=substring(@Usefulline,1,len(@Usefulline)-charindex(',',reverse(@Usefulline)))
                --select substring(@s,1,len(@s)-charindex('-',reverse(@s)))
                set @LastX=right(@FSubuserline, charindex(',',reverse(@FSubuserline))-1)
                declare EndLastline cursor  for
                SELECT kr1.lineid,krp1.pointid
                FROM kangaroo_roadnet kr1
                INNER JOIN
                      kangaroo_roadnet_point krp1 ON kr1.pointid = krp1.pointid
                where (krp1.logicalx <= @StartpointX+@XYarea and krp1.logicalx >= @StartpointX-@XYarea)
                    AND (krp1.logicaly <= @StartpointY+@XYarea and krp1.logicaly >= @StartpointY-@XYarea)
                    and kr1.lineid in(
                SELECT kr.lineid
                FROM kangaroo_roadnet kr INNER JOIN
                      kangaroo_roadnet_point krp ON kr.pointid = krp.pointid
                WHERE (krp.logicalx = @FirstX) AND (krp.logicaly = @FirstY))
   
                open EndLastline
                fetch next from EndLastline into @Clineid,@Cpointid
   
                while ( @@Fetch_Status=0 )
                begin
                    if @Clineid is not null and @Cpointid is not null
                      begin
                        set @isExistLine='ye'
                        declare EndLastPoints cursor for
                        select krp1.logicalx,krp1.logicaly from kangaroo_roadnet_point as krp1 where krp1.pointid between @Cpointid and
                        (select krp.pointid from kangaroo_roadnet_point as krp,kangaroo_roadnet as kr
                        where  krp.logicalx=@FirstX and krp.logicaly=@FirstY and krp.pointid=kr.pointid
                        and kr.lineid=@Clineid)
                        open EndLastPoints
                        fetch next from EndLastPoints into @Clogicalx,@Clogicaly
                        while ( @@Fetch_Status=0 )
                        begin   
                            if @LinePoints is not null
                            begin
                                select @LinePoints=@LinePoints+','+@Clogicalx+','+@Clogicaly
                            end
                            else
                            begin
                                select @LinePoints=@Clogicalx+','+@Clogicaly
                            end
                        end
                        close EndLastPoints
                          deallocate EndLastPoints
                    end
                    else
                    begin
                        set @XYarea=@XYarea+100
                    end
                end
                close EndLastline
                  deallocate EndLastline
                if(@isExistLine='ye')
                begin
                    if(@Usefulline is not null)
                    begin
                        select @Usefulline=@Usefulline+';'+@LinePoints
                    end
                    else
                    begin
                        select @Usefulline=@LinePoints
                    end
                    break
                end
                else
                begin
                    set @int=@int+1
                end
               
            end
           
        end
       
    end
       

end

GO


推荐阅读
  • 在Android开发中,使用Picasso库可以实现对网络图片的等比例缩放。本文介绍了使用Picasso库进行图片缩放的方法,并提供了具体的代码实现。通过获取图片的宽高,计算目标宽度和高度,并创建新图实现等比例缩放。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • MPLS VP恩 后门链路shamlink实验及配置步骤
    本文介绍了MPLS VP恩 后门链路shamlink的实验步骤及配置过程,包括拓扑、CE1、PE1、P1、P2、PE2和CE2的配置。详细讲解了shamlink实验的目的和操作步骤,帮助读者理解和实践该技术。 ... [详细]
  • 重入锁(ReentrantLock)学习及实现原理
    本文介绍了重入锁(ReentrantLock)的学习及实现原理。在学习synchronized的基础上,重入锁提供了更多的灵活性和功能。文章详细介绍了重入锁的特性、使用方法和实现原理,并提供了类图和测试代码供读者参考。重入锁支持重入和公平与非公平两种实现方式,通过对比和分析,读者可以更好地理解和应用重入锁。 ... [详细]
  • linux进阶50——无锁CAS
    1.概念比较并交换(compareandswap,CAS),是原⼦操作的⼀种,可⽤于在多线程编程中实现不被打断的数据交换操作࿰ ... [详细]
  • 本文主要介绍了gym102222KVertex Covers(高维前缀和,meet in the middle)相关的知识,包括题意、思路和解题代码。题目给定一张n点m边的图,点带点权,定义点覆盖的权值为点权之积,要求所有点覆盖的权值之和膜qn小于等于36。文章详细介绍了解题思路,通过将图分成两个点数接近的点集L和R,并分别枚举子集S和T,判断S和T能否覆盖所有内部的边。文章还提到了使用位运算加速判断覆盖和推导T'的方法。最后给出了解题的代码。 ... [详细]
  • 在本教程中,我们将看到如何使用FLASK制作第一个用于机器学习模型的RESTAPI。我们将从创建机器学习模型开始。然后,我们将看到使用Flask创建AP ... [详细]
  • 求数组中字符串的最长公共前缀(Java)
    求数组中字符串的最长公共前缀(牛客网—牛客题霸算法篇—NC55)题目描述给你一个大小为n的字符串数组strs,其中包含n个字符串,编写一个函数来查找字符串数组中的最长公共前缀,返回 ... [详细]
  • mysql  GROUP_CONCAT获取分组的前几名
    如果是oracle应该很容易用Partition By实现。比如说要获取班级的前3名,就可以用GROUP_CONCAT+ GROUPBY + substring_index实现。考 ... [详细]
  • 获取时间的函数js代码,js获取时区代码
    本文目录一览:1、js获取服务器时间(动态)2 ... [详细]
  • Thisissuewasoriginallyopenedbyashashicorp/terraform#5664.Itwasmigratedhe ... [详细]
  • Birthdate ... [详细]
  • Ihavethisfollowinginputfile:我有以下输入文件:test.csvdone_cfg,,,,port<0>,clk_in,subcktA,ins ... [详细]
  • 题目描述:一个DNA序列由ACGT四个字母的排列组合组成。G和C的比例(定义为GC-Ratio)是序列中G和C两个字母的总的出现次数除以总的字母数目(也就是序列长度)。在基因工程中,这个 ... [详细]
  • Mysql调优的顺序及面试问题总结
    文章目录一、调优相关1.第一步:本地explain线上查询遇到的第一个坑:遇到的第二个坑:2.第二步:覆盖索引3.第三步&# ... [详细]
author-avatar
LBM-痕迹
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有