Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WFS Mapserver层未显示在OpenLayers中_Openlayers_Mapserver - Fatal编程技术网

WFS Mapserver层未显示在OpenLayers中

WFS Mapserver层未显示在OpenLayers中,openlayers,mapserver,Openlayers,Mapserver,我目前正在设置PostGIS/Mapserver/OpenLayers应用程序。它可以很好地为我的数据提供一个图像,但我无法在OpenLayers中显示WFS层 我已经讨论了类似的问题,并解决了其中提到的所有问题,如跨域问题、SRS名称等。我已经达到了这样的程度:OpenLayers请求数据,Mapserver使用数据集进行回答,但OpenLayers中仍然没有显示任何内容 这是我的地图文件和OpenLayers测试文件。请注意,基本mapserver图层区域显示正确。保持不可见的是WFS层。非

我目前正在设置PostGIS/Mapserver/OpenLayers应用程序。它可以很好地为我的数据提供一个图像,但我无法在OpenLayers中显示WFS层

我已经讨论了类似的问题,并解决了其中提到的所有问题,如跨域问题、SRS名称等。我已经达到了这样的程度:OpenLayers请求数据,Mapserver使用数据集进行回答,但OpenLayers中仍然没有显示任何内容

这是我的地图文件和OpenLayers测试文件。请注意,基本mapserver图层区域显示正确。保持不可见的是WFS层。非常感谢您的帮助。javascript控制台中没有错误消息

映射文件:

MAP
  NAME        "test"
  STATUS ON
  EXTENT      0 0 100000 100000
  SIZE        1200 800
  IMAGECOLOR  0 40 120

  WEB
    MINSCALE 10
    MAXSCALE 1000000000
    METADATA
        "wfs_title" "Might & Fealty WFS Service"
        "wfs_srs" "EPSG:4326"
        "wfs_onlineresouce" "http://va.mightandfealty.com/mapserver"
        "wfs_enable_request" "*"
    END
  END

  LAYER
    NAME "regions"
    STATUS ON
    METADATA
        "wfs_title" "estates"
        "wfs_srs" "EPSG:4326"
        "gml_featureid" "id"
        "wfs_enable_request" "*"
    END
    TYPE POLYGON
    CONNECTIONTYPE POSTGIS
    CONNECTION "host=127.0.0.1 port=5432 dbname=bm2 user=bm2 password=xxx"
    DATA "poly from geodata"
    FILTER (biome not in ('water','ocean'))
    CLASS
      STYLE
        OUTLINECOLOR 200 20 20
        COLOR 20 200 20
        WIDTH 1
        ANTIALIAS true
      END
    END
  END

   LAYER
    NAME "rivers"
    STATUS ON
    METADATA
        "wfs_title" "rivers"
        "wfs_srs" "EPSG:4326"
        "gml_featureid" "id"
        "wfs_enable_request" "*"
    END
    TYPE LINE
    CONNECTIONTYPE POSTGIS
    CONNECTION "host=127.0.0.1 port=5432 dbname=bm2 user=bm2 password=xxx"
    DATA "course from river"
    CLASS
      STYLE
        COLOR 0 80 160
        WIDTH 2
        ANTIALIAS true
      END
    END
  END
END
以及OpenLayers测试HTML:

<html>
<head>
   <script src="http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body>

<div id="map" style="width:1200px;height:800px"></div>

<script language="javascript" type="text/javascript">
var map, layer;

init();

function init(){
        var mapBounds = new OpenLayers.Bounds(0, 0, 100000, 100000);
        var geojson_format = new OpenLayers.Format.GeoJSON();

        var options = {
                maxExtent: mapBounds,
                projection: new OpenLayers.Projection('EPSG:4326'),
                units: 'm'
        };
        map = new OpenLayers.Map('map', options);

  baselayer = new OpenLayers.Layer.MapServer("Mapserver",
       "http://va.mightandfealty.com/mapserver",
       {map: 'basemap', layers: ['regions']}, {singleTile:true});
  map.addLayer(baselayer);


  var style = new OpenLayers.Style({
    fillColor: '#ffff00',
    strokeColor: '#0040ff',
    strokeWidth: 5
  });

  var style = new OpenLayers.Style({
    fillColor: '#ffff00',
    strokeColor: '#0040ff',
    strokeWidth: 5
  });

   layer = new OpenLayers.Layer.Vector("Rivers", {
    renderers: ["SVG2", "VML", "Canvas"],
    styleMap: new OpenLayers.StyleMap(style),
    strategies: [new OpenLayers.Strategy.BBOX()],
    protocol: new OpenLayers.Protocol.WFS({
      url: "http://va.mightandfealty.com/mapserver?map=basemap&service=wfs&srsName=EPSG:4326",
      featureType: "rivers",
      featureNS: "http://va.mightandfealty.com/maplayers/rivers",
      srsName: "EPSG:4326",
      geometryName: "course",
      version: "1.1.0"
    }),
  });
  map.addLayer(layer);
  layer.setVisibility(true);

  map.zoomToMaxExtent();

};

</script>
</body>
</html>
我可以想象,引起问题的是坐标系。我相信我应该使用EPSG:404000,因为我的坐标是从任意0点开始的m,所以范围是0到大约100000-但是因为它似乎对图像工作得很好,而且Mapserver和OpenLayers都没有抱怨,所以我目前正在测试这种方法

更新: 以下是WFS服务器响应的第一部分:

<wfs:FeatureCollection xmlns:ms="http://mapserver.gis.umn.edu/mapserver" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs http://schemas.opengis.net/wfs/1.0.0/WFS-basic.xsd                         http://mapserver.gis.umn.edu/mapserver http://va.mightandfealty.com/mapserver?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=feature:rivers&amp;OUTPUTFORMAT=XMLSCHEMA">
  <gml:boundedBy>
    <gml:Box srsName="EPSG:4326">
        <gml:coordinates>9870.500000,11393.700000 89396.100000,82458.000000</gml:coordinates>
    </gml:Box>
  </gml:boundedBy>
<gml:featureMember>
  <ms:rivers fid="rivers.56288">
    <gml:boundedBy>
        <gml:Box srsName="EPSG:4326">
            <gml:coordinates>30170.100000,36050.400000 33748.000000,42180.900000</gml:coordinates>
        </gml:Box>
    </gml:boundedBy>
    <ms:msGeometry>
    <gml:LineString srsName="EPSG:4326">
      <gml:coordinates>30170.100000,42180.900000 30638.666606,42145.195547 31092.384113,42022.852978 31541.532887,42110.569985 31998.200000,41998.700000 31982.139081,41544.379665 32041.352331,41093.103418 32150.754503,40642.976204 32175.600000,40200.500000 32217.079394,40152.159753 32264.056250,40095.565900 32311.261782,40056.552423 32364.300000,40011.900000 32669.068387,39950.658606 32967.946875,39965.794791 33268.616917,39823.880529 33589.700000,39722.200000 33560.642536,39352.254679 33714.125000,38989.478112 33634.090702,38633.521408 33748.000000,38273.400000 33232.041223,38066.279559 32676.456250,37646.200251 32160.021640,37573.382959 31663.300000,37339.200000 31802.023226,37019.298307 31883.325000,36677.163326 31937.030313,36378.729052 32022.800000,36050.400000 </gml:coordinates>
    </gml:LineString>
    </ms:msGeometry>
  </ms:rivers>
</gml:featureMember>
<gml:featureMember>
  <ms:rivers fid="rivers.56291">
    <gml:boundedBy>
        <gml:Box srsName="EPSG:4326">
            <gml:coordinates>33843.100000,48178.700000 36248.400000,52306.300000</gml:coordinates>
        </gml:Box>
    </gml:boundedBy>

layer.features.length说什么?0,在发布帖子之前和之后。所以我猜它加载了数据,但无论出于什么原因都无法正确解释它?我做了更多的测试和研究。我的mapserver和mapfile与uDig一起工作,因此我现在相当确定问题出在OpenLayers设置的某个地方。