Esri geometry api java 学习 数据结构 (3) 点的数据结构 (Point)

上节讲到了VertexDescription,它规定了Esri以顶点为单位组成的几何结构。

从今天起我们来依次分析各个几何类的数据结构,就由最简单的Point来开始吧~

 

Point

首先Point构建了数组   double[] m_attributes;  double数组来存储 everything!everything!

m_attributes(类似存储单元)的数据顺序和语义,是由VertexDescription(类似建表语句)来描述的。所以每次初始化Point时都是一个建表过程!(double[] + Description)

        double[] m_attributes;    //建数组存储数据

	    m_description = VertexDescriptionDesignerImpl.getDefaultDescriptor2D();
        //如果没有description就建立

		if (vd == null)
			throw new IllegalArgumentException();
		m_description = vd;
        //如果外部输入description就使用

		m_description = VertexDescriptionDesignerImpl.getDefaultDescriptor2D();
		setXY(x, y);
        //如果输入函数有xy就先建好description,再存好xy

		m_description = VertexDescriptionDesignerImpl.getDefaultDescriptor2D();
		Point3D pt = new Point3D();
		pt.setCoords(x, y, z);
		setXYZ(pt);
        //如果输入函数有xyz就先建好description,再向description加入Z,最后存好xyz

这样一个简单明快的Point就建好了!

 

最后看看这个结构是怎么使用的~

getAttribute:getAttributeAsDbl(返回double)+getAttributeAsInt(返回int)(int semantics语义, int ordinate第几个组件)

    先到Description查一下有没有这个属性,计算该属性在m_attributes的哪一列中,然后返回m_attributes中查到的值

setAttribute:setAttribute(int semantics, int ordinate, double value)

    先到Description查一下有没有这个属性,如果没有添加属性addAttribute,计算该属性在m_attributes的哪一列中,再插入值value到m_attributes中

 

这就是最简单的Point使用数组+数组列说明的数据结构,怎么突然感觉跟哈希表差不多呢!如果我们使用哈希表实现这个功能会怎样?有什么弊端吗?各位大神或是有想法的同学块来教教我吧!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值