Browse Source

调整遍历要素及属性的逻辑

liwh 1 year ago
parent
commit
e9dea069a9

+ 11 - 12
cql-service/src/main/java/cn/com/taiji/cql/service/impl/ECqlServiceImpl.java

@@ -98,28 +98,27 @@ public class ECqlServiceImpl implements IECqlService{
 
 
 
-                SimpleFeatureCollection fCollection =fSource.getFeatures(query);
+                SimpleFeatureCollection simpleFeatureCollection =fSource.getFeatures(query);
 
-                if(fCollection !=null){
+                if(simpleFeatureCollection !=null){
 
+                    // 获取当前矢量数据有哪些属性字段值
+                    List<AttributeDescriptor> attributeList = simpleFeatureCollection.getSchema().getAttributeDescriptors();
 
-                    SimpleFeatureIterator itertor = fCollection.features();
 
-                    while (itertor.hasNext()){
+                    SimpleFeatureIterator simpleFeatureIterator = simpleFeatureCollection.features();
+
+                    while (simpleFeatureIterator.hasNext()){
                         //获取每一个要素
-                        SimpleFeature feature = itertor.next();
+                        SimpleFeature simpleFeature = simpleFeatureIterator.next();
 
                         Map<String, Object> dataMap = new HashMap<String, Object>();
 
-                        SimpleFeatureType simpleFeatureType = feature.getFeatureType();
-
-                        List<AttributeDescriptor> attributeList = simpleFeatureType.getAttributeDescriptors();
-                        for(AttributeDescriptor ad:attributeList){
+                        for(AttributeDescriptor attribute:attributeList){
 
-                            String key_ = ad.getName().toString();
-                            Object value_ = feature.getAttribute(key_);
+                            System.out.println(attribute.getLocalName() + ":" + simpleFeature.getAttribute(attribute.getLocalName()));
 
-                            dataMap.put(key_,value_);
+                            dataMap.put(attribute.getLocalName(),simpleFeature.getAttribute(attribute.getLocalName()));
 
                         }