Now I'm using tinyxml2 library for merge several xml files.
I want to checking xml files in same folder(I will use absolute path).
And when I combine several xml files, I will remove the duplicates and merge them by comparing the values of Firstchild Element and its first attribute.
I tried many cases, but not sure about which can be merged in an accurate and fast way.
Now I will show what I want to get.
First xml file
<?xml version='1.0' encoding='utf-8'?>
<osm version="0.6" generator=" ">
<node id="147782" visible="true" version="1" />
<node id="147788" visible="true" version="1" />
<node id="147794" visible="true" version="1" />
<node id="147829" visible="true" version="1" />
<node id="147835" visible="true" version="1" />
<node id="147843" visible="true" version="1" />
<node id="147850" visible="true" version="1" />
<way id="10808" visible="true" version="1">
<nd ref="147788" />
<nd ref="150133" />
<nd ref="150145" />
</way>
<way id="10824" visible="true" version="1">
<nd ref="156232" />
<nd ref="156240" />
<nd ref="156251" />
</way>
Second xml file
<?xml version='1.0' encoding='utf-8'?>
<osm version="0.6" generator=" ">
<node id="147843" visible="true" version="1" />
<node id="147850" visible="true" version="1" />
<node id="438198" visible="true" version="1" />
<node id="438199" visible="true" version="1" />
<way id="10808" visible="true" version="1">
<nd ref="147788" />
<nd ref="150133" />
<nd ref="150145" />
</way>
<way id="10821" visible="true" version="1">
<nd ref="153211" />
<nd ref="153230" />
<nd ref="153243" />
</way>
Merged xml file
<?xml version='1.0' encoding='utf-8'?>
<osm version="0.6" generator=" ">
<node id="147782" visible="true" version="1" />
<node id="147788" visible="true" version="1" />
<node id="147794" visible="true" version="1" />
<node id="147829" visible="true" version="1" />
<node id="147835" visible="true" version="1" />
<node id="147843" visible="true" version="1" />
<node id="147850" visible="true" version="1" />
<node id="438198" visible="true" version="1" />
<node id="438199" visible="true" version="1" />
<way id="10808" visible="true" version="1">
<nd ref="147788" />
<nd ref="150133" />
<nd ref="150145" />
</way>
<way id="10824" visible="true" version="1">
<nd ref="156232" />
<nd ref="156240" />
<nd ref="156251" />
</way>
<way id="10821" visible="true" version="1">
<nd ref="153211" />
<nd ref="153230" />
<nd ref="153243" />
</way>
Like that Merged xml file, I want merge them without overlapping. In those case, it can be compare with node id and way id.
I'm sorry if my question sounded ambiguous. If there is something wrong, I will correct it as soon as possible.
Related
I used ffplay to play mpd stream and successed,
Here the MPD file:
<?xml version="1.0" encoding="utf-8"?>
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:mpeg:dash:schema:mpd:2011"
xmlns:xlink="http://www.w3.org/1999/xlink"
xsi:schemaLocation="urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd"
profiles="urn:mpeg:dash:profile:isoff-live:2011"
type="static"
mediaPresentationDuration="PT1M8.7S"
maxSegmentDuration="PT5.0S"
minBufferTime="PT12.5S">
<ProgramInformation>
</ProgramInformation>
<ServiceDescription id="0">
</ServiceDescription>
<Period id="0" start="PT0.0S">
<AdaptationSet id="0" contentType="video" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" frameRate="24000/1001" maxWidth="1280" maxHeight="720" par="16:9">
<Representation id="0" mimeType="video/mp4" codecs="avc1.4d401f" bandwidth="10237" width="480" height="270" sar="1:1">
<SegmentTemplate timescale="24000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
<SegmentTimeline>
<S t="0" d="150150" r="9" />
<S d="149149" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="2" mimeType="video/mp4" codecs="avc1.4d401f" bandwidth="60882" width="1280" height="720" sar="1:1">
<SegmentTemplate timescale="24000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
<SegmentTimeline>
<S t="0" d="150150" r="9" />
<S d="149149" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="audio" startWithSAP="1" segmentAlignment="true" bitstreamSwitching="true" lang="und">
<Representation id="1" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audioSamplingRate="32000">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
<SegmentTemplate timescale="32000" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
<SegmentTimeline>
<S t="0" d="159744" />
<S d="160768" r="11" />
<S d="111915" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
<Representation id="3" mimeType="audio/mp4" codecs="mp4a.40.2" bandwidth="128000" audioSamplingRate="44100">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2" />
<SegmentTemplate timescale="44100" initialization="init-stream$RepresentationID$.m4s" media="chunk-stream$RepresentationID$-$Number%05d$.m4s" startNumber="1">
<SegmentTimeline>
<S t="0" d="220160" />
<S d="221184" r="11" />
<S d="158713" />
</SegmentTimeline>
</SegmentTemplate>
</Representation>
</AdaptationSet>
</Period>
this dash stream contains 2 vindeos(480P and 720P), and 2 audios.The videos always starts low quality(480P), I want to change the video resolution to the high quality(720P) during playing process, what should i do?
I have a text file with the following data format
<create>
<way id="-200341" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106862"/>
<nd ref="-106343"/>
<nd ref="-107240"/>
<nd ref="-107241"/>
<nd ref="-106863"/>
<nd ref="-106858"/>
<nd ref="-106866"/>
<nd ref="-106263"/>
<nd ref="-106868"/>
<nd ref="-106857"/>
<nd ref="-107242"/>
<nd ref="-106867"/>
<nd ref="-106865"/>
<nd ref="-107243"/>
<nd ref="-107244"/>
<nd ref="-106864"/>
<tag k="shelter" v="yes"/>
<tag k="highway" v="footway"/>
</way>
<way id="-200340" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106853"/>
<nd ref="-106852"/>
<tag k="shelter" v="yes"/>
<tag k="highway" v="footway"/>
</way>
<way id="-200277" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106228"/>
<nd ref="8236806130"/>
<tag k="highway" v="footway"/>
</way>
<way id="-200253" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106766"/>
<nd ref="-106765"/>
<nd ref="-106226"/>
<nd ref="-106769"/>
<nd ref="-106228"/>
<nd ref="-106773"/>
<nd ref="-106230"/>
<nd ref="-106771"/>
<nd ref="-106768"/>
<tag k="highway" v="footway"/>
<tag k="shelter" v="yes"/>
</way>
<way id="-200219" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-107148"/>
<nd ref="-106747"/>
<tag k="shelter" v="yes"/>
<tag k="highway" v="footway"/>
</way>
<way id="-200218" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106766"/>
<nd ref="-106755"/>
<tag k="shelter" v="yes"/>
<tag k="highway" v="footway"/>
</way>
<way id="-200066" version="0" timestamp="1970-01-01T00:00:00Z">
<nd ref="-106755"/>
<nd ref="-107148"/>
<nd ref="-106760"/>
<nd ref="-106764"/>
<nd ref="-106762"/>
<nd ref="-107115"/>
<nd ref="-106197"/>
<tag k="highway" v="footway"/>
<tag k="shelter" v="yes"/>
</way>
<way id="543558082" version="1" timestamp="2017-11-29T19:30:02Z" uid="0" user="">
<nd ref="1314909074"/>
<nd ref="5254615443"/>
<nd ref="5254615442"/>
<nd ref="5254615441"/>
<nd ref="5254615440"/>
<nd ref="-106516"/>
<nd ref="5254615439"/>
<nd ref="5254615438"/>
<nd ref="5254615437"/>
<nd ref="5254615436"/>
<nd ref="5254615435"/>
<tag k="service" v="driveway"/>
<tag k="highway" v="service"/>
<tag k="oneway" v="yes"/>
</way>
I have a unordered_map std::unordered_map<int, std::string> uMapID_feats{}; declared like this.
Assuming that my map has all of these ID numbers ref="XXXXX" numbers stored, and a defaulted string stored in it, like "unknownplace".
what I want to do is map the ID (called "ref=XXXXXX") to the tags that are listed under it. So the tags eg. for the first ID ref=106862, the tags that are connected to it are 200341, shelter, highway, footway, yes
So in the map, the first 3 pairs would look like this:
"106862" , "200341,shelter,highway,footway,yes"
"106343" , "200341,shelter,highway,footway,yes"
"107240" , "200341,shelter,highway,footway,yes"
Some sets have more tags than others and some have only 2 tags, hence why I would like it all to be written to a string and stored in this unordered_map, the tags separated by commas.
How should I go about parsing this data and getting it stored in the unordered_map correctly?
any help is appreciated, thank you!
Use an xml parsing Library like plugixml, or you could build your own one.
There are many libraries which parses xml. Chose the one which fits your needs.
This may help you: What XML parser should I use in C++?
Following is a event handler used in a xml file in config folder.
<event-handler name="survey.completioninf">
<broadcasts>
<message name="checkLogin">
<argument name="role" value="suadmin,manager" />
</message>
<message name="getPrograms" />
</broadcasts>
<results>
<result name="NotLoggedIn" do="user.login" redirect="true" />
<result name="NotAuthorized" do="user.notauthorized" redirect="true" />
<result do="view.template" />
</results>
<views>
<include name="body" template="survey/completioninf.cfm" />
</views>
</event-handler>
Is there any way I can include a different view file based on a result value or attribute?
I need to keep the event name consistent.
You can create a new result for each include you need (based on result value or attribute). If you set redirect="false" then it will stay under your survey.completioninf event name. Basically this event becomes a filter and redirects to the appropriate include silently.
<event-handler name="survey.completioninf">
<broadcasts>
<message name="checkLogin">
<argument name="role" value="suadmin,manager" />
</message>
<message name="getPrograms" />
</broadcasts>
<results>
<result name="NotLoggedIn" do="user.login" redirect="true" />
<result name="NotAuthorized" do="user.notauthorized" redirect="true" />
<!-- Add your new results here and redirect to the desired events -->
<result name="SurveyIsNotComplete" do="survey.ContinueSurvey" redirect="false">
<result name="SurveyIsComplete" do="survey.CompletedSurvey" redirect="false">
</results>
</event-handler>
<!-- You will need to create new events to handle these results -->
<event-handler name="survey.CompletedSurvey">
<broadcasts>
<message name="checkLogin">
<argument name="role" value="suadmin,manager" />
</message>
<message name="getPrograms" />
</broadcasts>
<results>
<result name="NotLoggedIn" do="user.login" redirect="true" />
<result name="NotAuthorized" do="user.notauthorized" redirect="true" />
<result do="view.template" />
</results>
<views>
<include name="body" template="survey/completioninf.cfm" />
</views>
</event-handler>
<event-handler name="survey.ContinueSurvey">
<broadcasts>
<message name="checkLogin">
<argument name="role" value="suadmin,manager" />
</message>
<message name="getPrograms" />
</broadcasts>
<results>
<result name="NotLoggedIn" do="user.login" redirect="true" />
<result name="NotAuthorized" do="user.notauthorized" redirect="true" />
<result do="view.template" />
</results>
<views>
<include name="body" template="survey/continueSurvey.cfm" />
</views>
</event-handler>
Can any body help me to understand the flow of model-glue event handler......its so confusing or simplify bellow code......
<event-handler name="Shipment.List" type="templatedPage">
<broadcasts>
<message name="needShipmentList" />
</broadcasts>
<views>
<include name="Primary" template="List.Shipment.cfm">
<value name="xe_Display" value="Shipment.Display" />
<value name="xe_Form" value="Shipment.Form" />
</include>
</views>
</event-handler>
<event-handler name="Shipment.Display" type="templatedPage">
<broadcasts>
<message name="needShipmentDetail" />
</broadcasts>
<views>
<include name="primary" template="Display.Shipment.cfm">
<value name="xe_ShipmentList" value="Shipment.List" />
<value name="xe_ItemForm" value="Item.Form" />
<value name="xe_ShipmentDisplay" value="Shipment.Display" />
<value name="xe_ItemRemove" value="doItem.Remove" />
</include>
</views>
</event-handler>
When you call for event "Shipment.List", it will broadcasts "needShipmentList" function of ShipmentController, after execution it will return on List.Shipment.cfm from on "Primary" layout of master page.
"List.Shipment.cfm" has a link whicj is triggered for needShipmentDetail function
"List.Shipment.cfm" fatches values from "Shipment.Display"-->needShipmentDetail
on display page(Display.Shipment.cfm), there are some links for remove, for listing...etc
"xe" is a convention for eXit Events
I am new to xml. I am trying to read an xml file taken from openstreetmaps. it looks as follow
<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="CGImap 0.0.2">
<bounds minlat="48.3994690" minlon="9.9897780" maxlat="48.3998220" maxlon="9.9898260"/>
<node id="149248718" lat="48.3994984" lon="9.9897961" user="Matthias Frank" uid="287306" visible="true" version="7" changeset="7966729" timestamp="2011-04-25T18:01:43Z"/>
<node id="1831376336" lat="48.3995041" lon="9.9898087" user="NUP" uid="168758" visible="true" version="1" changeset="12345652" timestamp="2012-07-19T20:02:51Z"/>
<node id="1831376346" lat="48.3995599" lon="9.9902392" user="NUP" uid="168758" visible="true" version="1" changeset="12345652" timestamp="2012-07-19T20:02:52Z"/>
<node id="1831376331" lat="48.3993243" lon="9.9898198" user="NUP" uid="168758" visible="true" version="1" changeset="12345652" timestamp="2012-07-19T20:02:51Z"/>
<node id="1831376349" lat="48.3996127" lon="9.9906471" user="NUP" uid="168758" visible="true" version="1" changeset="12345652" timestamp="2012-07-19T20:02:52Z"/>
<node id="1831376348" lat="48.3996044" lon="9.9910549" user="NUP" uid="168758" visible="true" version="1" changeset="12345652" timestamp="2012-07-19T20:02:52Z"/>
<node id="1831376418" lat="48.4000685" lon="9.9897909" user="NUP" uid="168758" visible="true" version="1" changeset="12345652" timestamp="2012-07-19T20:02:55Z"/>
<node id="1831376350" lat="48.3996158" lon="9.9908451" user="NUP" uid="168758" visible="true" version="1" changeset="12345652" timestamp="2012-07-19T20:02:52Z"/>
<node id="1831376374" lat="48.3999450" lon="9.9897917" user="NUP" uid="168758" visible="true" version="1" changeset="12345652" timestamp="2012-07-19T20:02:54Z"/>
<way id="172207897" user="NUP" uid="168758" visible="true" version="1" changeset="12345652" timestamp="2012-07-19T20:02:59Z">
<nd ref="1831376348"/>
<nd ref="1831376350"/>
<nd ref="1831376349"/>
<nd ref="1831376346"/>
<nd ref="1831376336"/>
<tag k="bicycle" v="yes"/>
<tag k="highway" v="living_street"/>
<tag k="name" v="Hintere Rebengasse"/>
<tag k="oneway" v="yes"/>
</way>
<way id="172207928" user="NUP" uid="168758" visible="true" version="1" changeset="12345652" timestamp="2012-07-19T20:03:01Z">
<nd ref="1831376331"/>
<nd ref="1831376336"/>
<nd ref="1831376374"/>
<nd ref="1831376418"/>
<tag k="bicycle" v="yes"/>
<tag k="highway" v="living_street"/>
<tag k="name" v="Pfauengasse"/>
<tag k="oneway" v="yes"/>
</way>
</osm>
What is the the simplest and shortest way to read the the data e.g. from node i want to read id, lat, lon and for each node I want to save that information as well. also for elements as "way" I want to read the ref and "tag" elements attached to it.
I am using simple fstream but it doesn't look the most efficient way.
please help
Instead of inventing the wheel again you could and should use a XML parser:
http://lars.ruoff.free.fr/xmlcpp/
For light weight parsing I usually use RapidXml. It's fast and is easy to use (at least from my point of view)
You should use an XML parsing library. Which one is up to you. Currently, I'm looking at tinyxml but I haven't used it yet so I can't endorse it. It does look very simple to incorporate into a project though.