上节讲到了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使用数组+数组列说明的数据结构,怎么突然感觉跟哈希表差不多呢!如果我们使用哈希表实现这个功能会怎样?有什么弊端吗?各位大神或是有想法的同学块来教教我吧!