コード例 #1
0
ファイル: scene.cpp プロジェクト: andrejsavikin/mishira
/// <summary>
/// Returns what index the specified item would be if the entire scene was
/// represented in a linear list.
/// </summary>
int Scene::listIndexOfItem(SceneItem *item) const
{
	int index = 0;
	for(int i = 0; i < m_groups.count(); i++) {
		const GroupInfo &group = m_groups.at(i);
		if(item == group.sceneItem)
			return index;
		index++;
		LayerList layers = group.group->getLayers();
		for(int j = 0; j < layers.count(); j++) {
			if(item == itemForLayer(layers.at(j)))
				return index;
			index++;
		}
	}
	return -1; // Not found
}
コード例 #2
0
ファイル: scene.cpp プロジェクト: andrejsavikin/mishira
/// <summary>
/// Returns the item at the specified index if the entire scene was represented
/// in a linear list.
/// </summary>
SceneItem *Scene::itemAtListIndex(int index) const
{
	int item = 0;
	for(int i = 0; i < m_groups.count(); i++) {
		const GroupInfo &group = m_groups.at(i);
		if(item == index)
			return group.sceneItem;
		item++;
		LayerList layers = group.group->getLayers();
		for(int j = 0; j < layers.count(); j++) {
			Layer *layer = layers.at(j);
			if(item == index)
				return itemForLayer(layer);
			item++;
		}
	}
	return NULL; // Not found
}
コード例 #3
0
ファイル: Wms.cpp プロジェクト: nmandery/openlayers-wms
void Wms::getCapabilities()
{
  QByteArray data;
  QTextStream out(&data);
  QString wmsurl = Qt::escape(m_request->url(FastCgiQt::LocationUrl).toEncoded()); 

  QString proj = renderer.map.getProjection();
  LayerList layers = renderer.map.getLayerList();

  //out << XML_HEADER << endl;
  out << "<WMT_MS_Capabilities version=\"1.1.1\">";

  // service info

  out << "<Service>"
      << "<Name>OGC:WMS</Name>"
      << "<Title>" << Qt::escape(renderer.title()) << "</Title>"
      << "<Abstract/>"
      << "<OnlineResource " << XML_XLINK_NS << " xlink:href=\"" << wmsurl << "\"/>"
      << "<ContactInformation/>"
      << "<Fees/>"
      << "<AccessConstraints/>"
      << "<KeywordList>";
  
  out << "<Keyword>" << "</Keyword>"; // TODO

  out << "</KeywordList>"
      << "</Service>";

  out << "<Capability>" 
      << "<Request>" 
      << "<GetCapabilities>" 
      << "<Format>" << MIMETYPE_GC << "</Format>" 
      << "<DCPType><HTTP><Get>"
      << "<OnlineResource " << XML_XLINK_NS
      <<   " xlink:href=\"" << wmsurl << "?Service=WMS&amp;"
      <<   "\"/></Get></HTTP></DCPType>"
      << "</GetCapabilities>" 
      << "<GetMap>";

  // image formats
  QList<QByteArray> formats = renderer.getImageFormats();
  for (QList<QByteArray>::ConstIterator fit = formats.constBegin();
    fit != formats.constEnd();
    ++fit) {
    QByteArray fb = *fit;
    QString outf;

    // ony return a few formats we want to support
    if (fb == "png") {
      outf = MIMETYPE_PNG;
    }
    else if (fb == "jpg") {
      outf = MIMETYPE_JPG;
    }
    else if (fb == "tiff") {
      outf = MIMETYPE_TIF;
    }

    if (!outf.isEmpty()) {
      out << "<Format>" << QString(outf) << "</Format>";  
    }
  }
  
  out << "<DCPType><HTTP><Get>" 
      << "<OnlineResource " << XML_XLINK_NS
      <<  " xlink:href=\"" << wmsurl << "?SERVICE=WMS&amp;\"/>"
      << "</Get></HTTP></DCPType>"
      << "</GetMap>"
      << "</Request>"; 

  out << "<Exception><Format>" << MIMETYPE_SE << "</Format></Exception>";

  out << "<Layer>" 
      << "<Title>" << Qt::escape(renderer.title()) << "</Title>" 
      << "<SRS>" << Qt::escape(proj) << "</SRS>"; 
      //<LatLonBoundingBox minx="-179.992" miny="-90.008" maxx="180.008" maxy="89.992"/> 
      //
   // layers

/*  for (LayerList::ConstIterator layer_it = layers.constBegin();
              layer_it != layers.constEnd();
              ++layer_it) {
    Layer layer = **layer_it;
*/
  for(int i = 0; i < layers.count(); ++i) {
    Layer* layer = layers[i];

    out << "<Layer queryable=\"0\">" 
        << "<Name>" << Qt::escape(layer->name) << "</Name>"
        << "<Title>" << Qt::escape(layer->title) << "</Title>"
        << "<SRS>" << Qt::escape(proj) << "</SRS>";

    out << "<LatLonBoundingBox minx=\"" << layer->bbox.left << "\" miny=\""
        << layer->bbox.bottom << "\" maxx=\"" << layer->bbox.right 
        << "\" maxy=\"" << layer->bbox.top << "\"/>" 
        << "<BoundingBox SRS=\"" << Qt::escape(proj) << "\" minx=\"" << layer->bbox.left 
        << "\" miny=\"" << layer->bbox.bottom << "\" maxx=\"" 
        << layer->bbox.right << "\" maxy=\"" << layer->bbox.top << "\"/>"; 

    out << "</Layer>";

  }

  out << "</Layer>"
      << "</Capability>"
      << "</WMT_MS_Capabilities>";

  out.flush();

  m_request->setHeader(HTTP_CONTENT_TYPE, MIMETYPE_GC);
  QByteArray content_length = QByteArray::number(data.length());
  m_request->setHeader(HTTP_CONTENT_LEN, content_length );
  m_request->write(data);
}